Skip to content

Commit e8e3b81

Browse files
Julowjonludlam
authored andcommitted
Fix top-comment computation before a stop-comment
The code for collecting alerts and attaching them to the toplevel unit is messing with stop-comments.
1 parent 94e62f1 commit e8e3b81

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/loader/doc_attr.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let parse_attribute : Parsetree.attribute -> parsed_attribute option =
9292
| Some p -> Some (`Text p)
9393
| None -> None)
9494
| "doc" | "ocaml.doc" -> (
95+
(* We don't expect a stop-comment here. *)
9596
match load_payload attr_payload with
9697
| Some p -> Some (`Doc p)
9798
| None -> None)
@@ -211,8 +212,9 @@ let extract_top_comment internal_tags ~classify parent items =
211212
let p = match p with Some (p, _) -> Some p | None -> None in
212213
let attr_loc = read_location attr_loc in
213214
`Alert (Location_.at attr_loc (`Tag (`Alert (name, p))))
214-
| Some (`Stop _) | None -> `Skip)
215-
| Some `Open -> `Skip
215+
| Some (`Stop _) -> `Return (* Stop at stop-comments. *)
216+
| None -> `Skip (* Skip unrecognized attributes. *))
217+
| Some `Open -> `Skip (* Skip open statements *)
216218
| None -> `Return
217219
in
218220
let rec extract_tail_alerts acc = function

test/generators/html/Stop-P.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
</nav>
1313
<header class="odoc-preamble">
1414
<h1>Module <code><span>Stop.P</span></code></h1><p>Doc.</p>
15-
</header><div class="odoc-content"></div>
15+
</header>
16+
<div class="odoc-content">
17+
<div class="odoc-spec">
18+
<div class="spec value anchored" id="val-bar">
19+
<a href="#val-bar" class="anchor"></a>
20+
<code><span><span class="keyword">val</span> bar : int</span></code>
21+
</div>
22+
</div>
23+
</div>
1624
</body>
1725
</html>

test/generators/latex/Stop.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ \section{Module \ocamlinlinecode{Stop}}\label{module-Stop}%
2020
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
2121
The top-comment computation must not mess with stop comments.
2222

23-
\label{module-Stop-module-P}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Stop-module-P]{\ocamlinlinecode{P}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\end{ocamlindent}%
23+
\label{module-Stop-module-P}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Stop-module-P]{\ocamlinlinecode{P}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Stop-module-P-val-bar}\ocamlcodefragment{\ocamltag{keyword}{val} bar : int}\\
24+
\end{ocamlindent}%
2425
\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}Doc.\end{ocamlindent}%
2526
\medbreak
2627

test/generators/man/Stop.P.3o

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Doc\.
1414
.SH Documentation
1515
.sp
1616
.nf
17-
17+
\f[CB]val\fR bar : int

0 commit comments

Comments
 (0)