Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
- Fixed title content not being picked up across pages when rendering references
(#1116, @panglesd)
- Fix wrong links to standalone comments in search results (#1118, @panglesd)
- Remove duplicated or unwanted comments (@Julow, #1133)
This could happen with inline includes.


# 2.4.0
Expand Down
21 changes: 13 additions & 8 deletions src/xref2/tools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1576,14 +1576,10 @@ and expansion_of_module_path :
in
expansion_of_module_cached env p' m >>= function
| Signature sg ->
let sg' =
match m.doc with
| [] -> sg
| docs -> { sg with items = Comment (`Docs docs) :: sg.items }
let sg =
if strengthen then Strengthen.signature (`Resolved p') sg else sg
in
if strengthen then
Ok (Signature (Strengthen.signature (`Resolved p') sg'))
else Ok (Signature sg')
Ok (Signature sg)
| Functor _ as f -> Ok f)
| Error _ when Cpath.is_module_forward path -> Error `UnresolvedForwardPath
| Error e -> Error (`UnresolvedPath (`Module (path, e)))
Expand Down Expand Up @@ -1719,7 +1715,16 @@ and expansion_of_module :
Env.t ->
Component.Module.t ->
(expansion, expansion_of_module_error) Result.result =
fun env m -> expansion_of_module_decl env m.type_
fun env m ->
expansion_of_module_decl env m.type_ >>= function
| Signature sg ->
let sg =
(* Override the signature's documentation when the module also has
a comment attached. *)
match m.doc with [] -> sg | doc -> { sg with doc }
in
Ok (Signature sg)
| Functor _ as f -> Ok f

and expansion_of_module_cached :
Env.t ->
Expand Down
1 change: 0 additions & 1 deletion test/generators/html/Include2.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h1>Module <code><span>Include2</span></code></h1>
</span>
</code>
</summary>
<p>Comment about X that should not appear when including X below.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-t">
<a href="#type-t" class="anchor"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</nav>
<header class="odoc-preamble">
<h1>Parameter <code><span>FunctorTypeOf.Collection</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</nav>
<header class="odoc-preamble">
<h1>Parameter <code><span>Recollection.C</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-Recollection.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</nav>
<header class="odoc-preamble">
<h1>Module <code><span>Ocamlary.Recollection</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<nav class="odoc-toc">
<ul><li><a href="#parameters">Parameters</a></li>
Expand All @@ -33,7 +34,6 @@ <h2 id="parameters"><a href="#parameters" class="anchor"></a>Parameters
</div>
</div>
<h2 id="signature"><a href="#signature" class="anchor"></a>Signature</h2>
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-module-type-A-Q.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<a href="Ocamlary-module-type-A.html">A</a> &#x00BB; Q
</nav>
<header class="odoc-preamble"><h1>Module <code><span>A.Q</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
3 changes: 3 additions & 0 deletions test/generators/html/Ocamlary-module-type-A.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ <h1>Module type <code><span>Ocamlary.A</span></code></h1>
</span>
</code>
</div>
<div class="spec-doc">
<p>This comment is for <code>CollectionModule</code>.</p>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-module-type-B-Q.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<a href="Ocamlary-module-type-B.html">B</a> &#x00BB; Q
</nav>
<header class="odoc-preamble"><h1>Module <code><span>B.Q</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
3 changes: 3 additions & 0 deletions test/generators/html/Ocamlary-module-type-B.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ <h1>Module type <code><span>Ocamlary.B</span></code></h1>
</span>
</code>
</div>
<div class="spec-doc">
<p>This comment is for <code>CollectionModule</code>.</p>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-module-type-C-Q.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<a href="Ocamlary-module-type-C.html">C</a> &#x00BB; Q
</nav>
<header class="odoc-preamble"><h1>Module <code><span>C.Q</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
3 changes: 3 additions & 0 deletions test/generators/html/Ocamlary-module-type-C.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ <h1>Module type <code><span>Ocamlary.C</span></code></h1>
</span>
</code>
</div>
<div class="spec-doc">
<p>This comment is for <code>CollectionModule</code>.</p>
</div>
</div>
</details>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-module-type-COLLECTION.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<header class="odoc-preamble">
<h1>Module type <code><span>Ocamlary.COLLECTION</span></code></h1>
<p>module type of</p>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
2 changes: 1 addition & 1 deletion test/generators/html/Ocamlary-module-type-MMM-C.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</nav>
<header class="odoc-preamble">
<h1>Module <code><span>MMM.C</span></code></h1>
<p>This comment is for <code>CollectionModule</code>.</p>
</header>
<div class="odoc-content">
<p>This comment is for <code>CollectionModule</code>.</p>
<div class="odoc-spec">
<div class="spec type anchored" id="type-collection">
<a href="#type-collection" class="anchor"></a>
Expand Down
3 changes: 3 additions & 0 deletions test/generators/html/Ocamlary-module-type-MMM.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ <h1>Module type <code><span>Ocamlary.MMM</span></code></h1>
</span>
</code>
</div>
<div class="spec-doc">
<p>This comment is for <code>CollectionModule</code>.</p>
</div>
</div>
</div>
</body>
Expand Down
3 changes: 3 additions & 0 deletions test/generators/html/Ocamlary.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ <h4 id="advanced-module-stuff">
</span>
</code>
</div>
<div class="spec-doc">
<p>This comment is for <code>CollectionModule</code>.</p>
</div>
</div>
<div class="odoc-spec">
<div class="spec module-type anchored" id="module-type-MMM">
Expand Down
4 changes: 1 addition & 3 deletions test/generators/latex/Include2.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ \section{Module \ocamlinlinecode{Include2}}\label{module-Include2}%
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}Comment about X that should not appear when including X below.\end{ocamlindent}%
\medbreak
\ocamltag{keyword}{include} \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \ocamltag{keyword}{struct} \ocamltag{keyword}{include} \hyperref[module-Include2-module-X]{\ocamlinlinecode{X}} \ocamltag{keyword}{end}Comment about X that should not appear when including X below.

\label{module-Include2-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = int}\\
\ocamltag{keyword}{include} \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \ocamltag{keyword}{struct} \ocamltag{keyword}{include} \hyperref[module-Include2-module-X]{\ocamlinlinecode{X}} \ocamltag{keyword}{end}\label{module-Include2-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = int}\\
\label{module-Include2-module-Y}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Include2-module-Y]{\ocamlinlinecode{Y}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Include2-module-Y-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}Top-comment of Y.\end{ocamlindent}%
Expand Down
4 changes: 1 addition & 3 deletions test/generators/latex/Ocamlary.FunctorTypeOf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ \section{Module \ocamlinlinecode{Ocamlary.\allowbreak{}FunctorTypeOf}}\label{mod
This comment is for \ocamlinlinecode{FunctorTypeOf}.

\subsection{Parameters\label{parameters}}%
\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-FunctorTypeOf-argument-1-Collection]{\ocamlinlinecode{Collection}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.

\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}%
\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-FunctorTypeOf-argument-1-Collection]{\ocamlinlinecode{Collection}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}%
\medbreak
\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\
\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-FunctorTypeOf-argument-1-Collection-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}%
Expand Down
8 changes: 3 additions & 5 deletions test/generators/latex/Ocamlary.Recollection.tex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
\section{Module \ocamlinlinecode{Ocamlary.\allowbreak{}Recollection}}\label{module-Ocamlary-module-Recollection}%
\subsection{Parameters\label{parameters}}%
\label{module-Ocamlary-module-Recollection-argument-1-C}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-Recollection-argument-1-C]{\ocamlinlinecode{C}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.
This comment is for \ocamlinlinecode{CollectionModule}.

\label{module-Ocamlary-module-Recollection-argument-1-C-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}%
\subsection{Parameters\label{parameters}}%
\label{module-Ocamlary-module-Recollection-argument-1-C}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-Recollection-argument-1-C]{\ocamlinlinecode{C}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-Recollection-argument-1-C-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}%
\medbreak
\label{module-Ocamlary-module-Recollection-argument-1-C-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\
\label{module-Ocamlary-module-Recollection-argument-1-C-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-Recollection-argument-1-C-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-Recollection-argument-1-C-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}%
Expand All @@ -25,8 +25,6 @@ \subsection{Parameters\label{parameters}}%
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\subsection{Signature\label{signature}}%
This comment is for \ocamlinlinecode{CollectionModule}.

\label{module-Ocamlary-module-Recollection-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-element]{\ocamlinlinecode{C.\allowbreak{}element}} list}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}%
\medbreak
\label{module-Ocamlary-module-Recollection-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-collection]{\ocamlinlinecode{C.\allowbreak{}collection}}}\\
Expand Down
Loading