Skip to content

Commit cba655d

Browse files
committed
Take code from inlined expansions
1 parent 46e8f80 commit cba655d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/markdown/generator.ml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ and item (l : Item.t list) args nesting_level =
249249
| None -> paragraph title
250250
in
251251
blocks heading' (continue rest)
252-
| Declaration { attr = _; anchor; content; doc } -> (
252+
| Declaration { attr = _; anchor; content; doc } ->
253253
(*
254-
A declaration render like this:
254+
Declarations render like this:
255255
256256
{v
257257
<a id="<id>"></a>
@@ -271,14 +271,21 @@ and item (l : Item.t list) args nesting_level =
271271
in
272272
paragraph (anchor' anchor)
273273
else noop
274+
and begin_code, content =
275+
match take_code content with
276+
| [], _ -> assert false (* Content doesn't begin with code ? *)
277+
| begin_code, Alternative (Expansion e) :: tl
278+
when should_inline e.url ->
279+
(* Take the code from inlined expansion. For example, to catch
280+
[= sig]. *)
281+
let e_code, e_tl = take_code e.expansion in
282+
(begin_code @ e_code, e_tl @ tl)
283+
| begin_code, content -> (begin_code, content)
274284
in
275-
match take_code content with
276-
| [], _ -> assert false (* Content doesn't begin with code ? *)
277-
| begin_code, tl ->
278-
anchor
279-
+++ item_heading nesting_level (source_code begin_code args)
280-
+++ documented_src tl args nesting_level
281-
+++ doc +++ continue rest)
285+
anchor
286+
+++ item_heading nesting_level (source_code begin_code args)
287+
+++ documented_src content args nesting_level
288+
+++ doc +++ continue rest
282289
| Include { content = { summary; status; content }; _ } ->
283290
let inline_subpage = function
284291
| `Inline | `Open | `Default -> true

test/integration/markdown.t/run.t

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@
108108

109109
<a id="module-type-S"></a>
110110

111-
###### module type S
112-
113-
= sig
111+
###### module type S = sig
114112

115113
<a id="type-t"></a>
116114

0 commit comments

Comments
 (0)