Skip to content

Commit 1d08e6e

Browse files
committed
Render documentation attached to includes
Before, the attached documentation was removed and the synopsis from the includee top-comment was used instead. Now, the attached documentation is rendered entirely and the includee top-comment is not. There is an exception, if there is no documentation attached to the include, we render the synopsis extracted from the includee top-comment, as before.
1 parent bd92aa6 commit 1d08e6e

File tree

12 files changed

+17
-28
lines changed

12 files changed

+17
-28
lines changed

src/document/generator.ml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,16 @@ module Make (Syntax : SYNTAX) = struct
15451545
let content = { Include.content; status; summary } in
15461546
let attr = [ "include" ] in
15471547
let anchor = None in
1548-
let doc = Comment.synopsis ~decl_doc:[] ~expansion_doc:(Some sg_doc) in
1548+
let doc =
1549+
(* Documentation attached to includes behave differently than other
1550+
declarations, which show only the synopsis. We can't only show the
1551+
synopsis because no page is generated to render it and we'd loose
1552+
the full documentation.
1553+
As an exception, the synopsis from the expansion is used iff there
1554+
is no documentation. *)
1555+
if t.doc <> [] then Comment.to_ir t.doc
1556+
else Comment.synopsis ~decl_doc:[] ~expansion_doc:(Some sg_doc)
1557+
in
15491558
Item.Include { attr; anchor; doc; content }
15501559
end
15511560

test/html/expect/test_package+ml/Include2/Y_include_doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>
2626
<div class="odoc-include">
2727
<div class="spec-doc">
2828
<p>
29-
Top-comment of Y.
29+
Doc attached to <code>include Y</code>. <code>Y</code>'s top-comment shouldn't appear here.
3030
</p>
3131
</div>
3232
<details open="open">

test/html/expect/test_package+ml/Toplevel_comments/Include_inline'/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>
3232
<div class="odoc-include">
3333
<div class="spec-doc">
3434
<p>
35-
Doc of <code>T</code>, part 2.
35+
part 3
3636
</p>
3737
</div>
3838
<div class="odoc-spec">

test/html/expect/test_package+ml/Toplevel_comments/Include_inline/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ <h1>
2424
</header>
2525
<div class="odoc-content">
2626
<div class="odoc-include">
27-
<div class="spec-doc">
28-
<p>
29-
Doc of <code>T</code>, part 2.
30-
</p>
31-
</div>
3227
<div class="odoc-spec">
3328
<div class="spec type" id="type-t">
3429
<a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code>

test/html/expect/test_package+ml/Toplevel_comments/module-type-Include_inline_T'/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>
3232
<div class="odoc-include">
3333
<div class="spec-doc">
3434
<p>
35-
Doc of <code>T</code>, part 2.
35+
part 3
3636
</p>
3737
</div>
3838
<div class="odoc-spec">

test/html/expect/test_package+ml/Toplevel_comments/module-type-Include_inline_T/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ <h1>
2424
</header>
2525
<div class="odoc-content">
2626
<div class="odoc-include">
27-
<div class="spec-doc">
28-
<p>
29-
Doc of <code>T</code>, part 2.
30-
</p>
31-
</div>
3227
<div class="odoc-spec">
3328
<div class="spec type" id="type-t">
3429
<a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code>

test/html/expect/test_package+re/Include2/Y_include_doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>
2626
<div class="odoc-include">
2727
<div class="spec-doc">
2828
<p>
29-
Top-comment of Y.
29+
Doc attached to <code>include Y</code>. <code>Y</code>'s top-comment shouldn't appear here.
3030
</p>
3131
</div>
3232
<details open="open">

test/html/expect/test_package+re/Toplevel_comments/Include_inline'/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>
3232
<div class="odoc-include">
3333
<div class="spec-doc">
3434
<p>
35-
Doc of <code>T</code>, part 2.
35+
part 3
3636
</p>
3737
</div>
3838
<div class="odoc-spec">

test/html/expect/test_package+re/Toplevel_comments/Include_inline/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ <h1>
2424
</header>
2525
<div class="odoc-content">
2626
<div class="odoc-include">
27-
<div class="spec-doc">
28-
<p>
29-
Doc of <code>T</code>, part 2.
30-
</p>
31-
</div>
3227
<div class="odoc-spec">
3328
<div class="spec type" id="type-t">
3429
<a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span>;</span></code>

test/html/expect/test_package+re/Toplevel_comments/module-type-Include_inline_T'/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>
3232
<div class="odoc-include">
3333
<div class="spec-doc">
3434
<p>
35-
Doc of <code>T</code>, part 2.
35+
part 3
3636
</p>
3737
</div>
3838
<div class="odoc-spec">

0 commit comments

Comments
 (0)