Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown generator #791

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6ddcac7
add markup module
lubegasimon Dec 19, 2021
c40ab7c
add markdown generator
lubegasimon Dec 19, 2021
dc8604b
add simple test module for ease PR review
lubegasimon Dec 19, 2021
1a934c6
promote tests
lubegasimon Dec 19, 2021
508704e
some code improvements
lubegasimon Jan 5, 2022
06c6159
Fix path handling
Julow Jan 18, 2022
6021e82
Improve indentation of headings
Julow Jan 18, 2022
812289d
Don't render alternatives as code
Julow Jan 19, 2022
e80d5a0
Render 6-heading only for declarations
Julow Jan 19, 2022
46e8f80
Improve test case
Julow Jan 19, 2022
cba655d
Take code from inlined expansions
Julow Jan 19, 2022
91e7cb0
Render formatted code out of headings
Julow Jan 19, 2022
0d5e556
Render formatted code in quote blocks
Julow Jan 19, 2022
0c45ebb
Disable inlining of expansions
Julow Jan 28, 2022
749fead
Generate correct links to other pages
Julow Feb 2, 2022
d2c2dca
Enable generator tests for markdown
Julow Feb 2, 2022
0da2e62
Cleanup blocks concatenation
Julow Feb 2, 2022
1fc35ec
Cleanup iteration code
Julow Feb 3, 2022
654d4a0
Make sure noops are removed from concatenations
Julow Feb 3, 2022
69a08be
Document: Remove empty text nodes
Julow Feb 3, 2022
9bbc31a
Fix bits of source code incorrectly removed
Julow Feb 3, 2022
b559088
Fix printing of code blocks
Julow Feb 3, 2022
a8a859d
Fix printing of code spans
Julow Feb 3, 2022
c4922c8
Fix printing of documentation comments
Julow Feb 3, 2022
3c2a8d9
Fix rendering of nested and documented items
Julow Feb 4, 2022
7449b4a
Fix spacing after quote blocks
Julow Feb 7, 2022
27a972c
Fix rendering of spaces between inlines
Julow Feb 7, 2022
5726a9b
Remove inlines concatenation with spaces
Julow Feb 7, 2022
b4d5f6d
document: Remove extra space after class keyword
Julow Feb 7, 2022
0b10e6f
remove unnecessary block_separator
lubegasimon Feb 11, 2022
93c66f6
Escape backticks
Julow Feb 11, 2022
b38f9b6
Use Astring
Julow Feb 11, 2022
4389a34
Properly handle HTML entities
Julow Feb 11, 2022
6627327
block quote variant constructors
lubegasimon Feb 11, 2022
67077ec
add brackets back to record types and variants
lubegasimon Feb 11, 2022
be8a615
mark up record and variant closing brackets that are blocks
lubegasimon Feb 15, 2022
ab13bf8
remove redundant brackets
lubegasimon Feb 15, 2022
0968555
promote tests after a rebase
lubegasimon Feb 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions src/document/codefmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ module State = struct
())

let leave state =
if state.ignore_all = 0 then (
if state.ignore_all = 0 then
let current_elt = List.rev state.current in
let previous_elt, tag = Stack.pop state.context in
state.current <- Tag (tag, current_elt) :: previous_elt;
())
match current_elt with
| [] -> state.current <- previous_elt
| _ -> state.current <- Tag (tag, current_elt) :: previous_elt

let rec flush state =
if Stack.is_empty state.context then List.rev state.current
Expand Down Expand Up @@ -151,7 +152,9 @@ let make () =
let open Inline in
let state0 = State.create () in
let push elt = State.push state0 (Elt elt) in
let push_text s = if state0.ignore_all = 0 then push [ inline @@ Text s ] in
let push_text s =
if state0.ignore_all = 0 && s <> "" then push [ inline @@ Text s ]
in

let formatter =
let out_string s i j = push_text (String.sub s i j) in
Expand Down
17 changes: 12 additions & 5 deletions src/document/generator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,11 @@ module Make (Syntax : SYNTAX) = struct

let class_ (t : Odoc_model.Lang.Class.t) =
let name = Paths.Identifier.name t.id in
let params = format_params ~delim:`brackets t.params in
let params =
match t.params with
| [] -> O.noop
| params -> format_params ~delim:`brackets params ++ O.txt " "
in
let virtual_ =
if t.virtual_ then O.keyword "virtual" ++ O.txt " " else O.noop
in
Expand All @@ -1041,8 +1045,7 @@ module Make (Syntax : SYNTAX) = struct
expansion summary
in
let content =
O.documentedSrc
(O.keyword "class" ++ O.txt " " ++ virtual_ ++ params ++ O.txt " ")
O.documentedSrc (O.keyword "class" ++ O.txt " " ++ virtual_ ++ params)
@ cname @ cd
in
let attr = [ "class" ] in
Expand All @@ -1052,7 +1055,11 @@ module Make (Syntax : SYNTAX) = struct

let class_type (t : Odoc_model.Lang.ClassType.t) =
let name = Paths.Identifier.name t.id in
let params = format_params ~delim:`brackets t.params in
let params =
match t.params with
| [] -> O.noop
| params -> format_params ~delim:`brackets params ++ O.txt " "
in
let virtual_ =
if t.virtual_ then O.keyword "virtual" ++ O.txt " " else O.noop
in
Expand All @@ -1074,7 +1081,7 @@ module Make (Syntax : SYNTAX) = struct
let content =
O.documentedSrc
(O.keyword "class" ++ O.txt " " ++ O.keyword "type" ++ O.txt " "
++ virtual_ ++ params ++ O.txt " ")
++ virtual_ ++ params)
@ cname @ expr
in
let attr = [ "class-type" ] in
Expand Down
6 changes: 6 additions & 0 deletions src/markdown/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name odoc_markdown)
(public_name odoc.markdown)
(instrumentation
(backend bisect_ppx))
(libraries odoc_model odoc_document))
Loading