Skip to content

Commit 812289d

Browse files
committed
Don't render alternatives as code
1 parent 6021e82 commit 812289d

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

src/markdown/generator.ml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,8 @@ let rec documented_src (l : DocumentedSrc.t) args nesting_level =
166166
let noop = paragraph noop in
167167
let take_code l =
168168
let c, _, rest =
169-
let expansion_not_inlined url = not (should_inline url) in
170169
Take.until l ~classify:(function
171170
| DocumentedSrc.Code c -> Accum c
172-
| DocumentedSrc.Alternative (Expansion e) ->
173-
if expansion_not_inlined e.url then Accum e.summary
174-
else Rec e.expansion
175171
| _ -> Stop_and_keep)
176172
in
177173
(c, rest)
@@ -190,7 +186,9 @@ let rec documented_src (l : DocumentedSrc.t) args nesting_level =
190186
(item_heading nesting_level (source_code c args))
191187
(continue rest)
192188
else noop
193-
| Alternative _ -> continue rest
189+
| Alternative (Expansion { url; expansion; _ }) ->
190+
if should_inline url then documented_src expansion args nesting_level
191+
else continue rest
194192
| Subpage p ->
195193
blocks (subpage p.content args (nesting_level + 1)) (continue rest)
196194
| Documented _ | Nested _ ->

test/integration/markdown.t/run.t

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,35 @@
2727

2828
###### type y'
2929

30-
###### module type Foo' = sig
30+
###### module type Foo'
31+
32+
###### = sig
3133

3234
######    type foo
3335

3436
###### end
3537

36-
###### module Bar : sig ... end
38+
###### module Bar
39+
40+
###### module type Bar'
3741

38-
###### module type Bar' = sig
42+
###### = sig
3943

4044
######    type bar'
4145

4246
###### end
4347

44-
###### module type Foo = sig
48+
###### module type Foo
49+
50+
###### = sig
4551

4652
######    type foo
4753

4854
######    type bar'
4955

50-
######    module type Foo' = sig
56+
######    module type Foo'
57+
58+
######    = sig
5159

5260
######      type foo'
5361

@@ -142,7 +150,7 @@
142150

143151
@author: David Sheets
144152

145-
###### module Foo : sig ... end
153+
###### module Foo
146154

147155
The end foo end keyword in doc comment.
148156

@@ -201,7 +209,9 @@
201209

202210
<a id="module-type-Foo'"></a>
203211

204-
###### module type Foo' = sig
212+
###### module type Foo'
213+
214+
###### = sig
205215

206216
<a id="type-foo"></a>
207217

@@ -211,11 +221,13 @@
211221

212222
<a id="module-Bar"></a>
213223

214-
###### module Bar : sig ... end
224+
###### module Bar
215225

216226
<a id="module-type-Bar'"></a>
217227

218-
###### module type Bar' = sig
228+
###### module type Bar'
229+
230+
###### = sig
219231

220232
<a id="type-bar'"></a>
221233

@@ -225,7 +237,9 @@
225237

226238
<a id="module-type-Foo"></a>
227239

228-
###### module type Foo = sig
240+
###### module type Foo
241+
242+
###### = sig
229243

230244
<a id="type-foo"></a>
231245

@@ -237,7 +251,9 @@
237251

238252
<a id="module-type-Foo'"></a>
239253

240-
######    module type Foo' = sig
254+
######    module type Foo'
255+
256+
######    = sig
241257

242258
<a id="type-foo'"></a>
243259

@@ -358,7 +374,7 @@
358374

359375
<a id="module-Foo"></a>
360376

361-
###### module Foo : sig ... end
377+
###### module Foo
362378

363379
The end foo end keyword in doc comment.
364380

0 commit comments

Comments
 (0)