diff --git a/CHANGES.md b/CHANGES.md index baab008aba..5470cc1bbb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/src/xref2/tools.ml b/src/xref2/tools.ml index cbea616aa1..fc5dc4200e 100644 --- a/src/xref2/tools.ml +++ b/src/xref2/tools.ml @@ -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))) @@ -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 -> diff --git a/test/generators/html/Include2.html b/test/generators/html/Include2.html index 89c41d0344..5348dbadc1 100644 --- a/test/generators/html/Include2.html +++ b/test/generators/html/Include2.html @@ -40,7 +40,6 @@

Module Include2

-

Comment about X that should not appear when including X below.

diff --git a/test/generators/html/Ocamlary-FunctorTypeOf-argument-1-Collection.html b/test/generators/html/Ocamlary-FunctorTypeOf-argument-1-Collection.html index 8461006cae..cad2ebe40c 100644 --- a/test/generators/html/Ocamlary-FunctorTypeOf-argument-1-Collection.html +++ b/test/generators/html/Ocamlary-FunctorTypeOf-argument-1-Collection.html @@ -15,9 +15,9 @@

Parameter FunctorTypeOf.Collection

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-Recollection-argument-1-C.html b/test/generators/html/Ocamlary-Recollection-argument-1-C.html index a9a318ca46..f638dba191 100644 --- a/test/generators/html/Ocamlary-Recollection-argument-1-C.html +++ b/test/generators/html/Ocamlary-Recollection-argument-1-C.html @@ -14,9 +14,9 @@

Parameter Recollection.C

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-Recollection.html b/test/generators/html/Ocamlary-Recollection.html index fa50f669bc..3a83d9ebe4 100644 --- a/test/generators/html/Ocamlary-Recollection.html +++ b/test/generators/html/Ocamlary-Recollection.html @@ -13,6 +13,7 @@

Module Ocamlary.Recollection

+

This comment is for CollectionModule.

Signature

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-A-Q.html b/test/generators/html/Ocamlary-module-type-A-Q.html index 48e5b7aaeb..fe376cff93 100644 --- a/test/generators/html/Ocamlary-module-type-A-Q.html +++ b/test/generators/html/Ocamlary-module-type-A-Q.html @@ -13,9 +13,9 @@ A » Q

Module A.Q

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-A.html b/test/generators/html/Ocamlary-module-type-A.html index 4ea5f2f2b0..6970097cbf 100644 --- a/test/generators/html/Ocamlary-module-type-A.html +++ b/test/generators/html/Ocamlary-module-type-A.html @@ -32,6 +32,9 @@

Module type Ocamlary.A

+
+

This comment is for CollectionModule.

+
diff --git a/test/generators/html/Ocamlary-module-type-B-Q.html b/test/generators/html/Ocamlary-module-type-B-Q.html index 427abfe7c0..42342c8df9 100644 --- a/test/generators/html/Ocamlary-module-type-B-Q.html +++ b/test/generators/html/Ocamlary-module-type-B-Q.html @@ -13,9 +13,9 @@ B » Q

Module B.Q

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-B.html b/test/generators/html/Ocamlary-module-type-B.html index f27836fb02..d55dec2999 100644 --- a/test/generators/html/Ocamlary-module-type-B.html +++ b/test/generators/html/Ocamlary-module-type-B.html @@ -32,6 +32,9 @@

Module type Ocamlary.B

+
+

This comment is for CollectionModule.

+
diff --git a/test/generators/html/Ocamlary-module-type-C-Q.html b/test/generators/html/Ocamlary-module-type-C-Q.html index 3b143f68b4..4112a7274c 100644 --- a/test/generators/html/Ocamlary-module-type-C-Q.html +++ b/test/generators/html/Ocamlary-module-type-C-Q.html @@ -13,9 +13,9 @@ C » Q

Module C.Q

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-C.html b/test/generators/html/Ocamlary-module-type-C.html index 80ae739b51..4bd5874bab 100644 --- a/test/generators/html/Ocamlary-module-type-C.html +++ b/test/generators/html/Ocamlary-module-type-C.html @@ -50,6 +50,9 @@

Module type Ocamlary.C

+
+

This comment is for CollectionModule.

+
diff --git a/test/generators/html/Ocamlary-module-type-COLLECTION.html b/test/generators/html/Ocamlary-module-type-COLLECTION.html index d7e16b53e5..0c7d81a231 100644 --- a/test/generators/html/Ocamlary-module-type-COLLECTION.html +++ b/test/generators/html/Ocamlary-module-type-COLLECTION.html @@ -14,9 +14,9 @@

Module type Ocamlary.COLLECTION

module type of

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-MMM-C.html b/test/generators/html/Ocamlary-module-type-MMM-C.html index 2034b9261e..c2caf8dafa 100644 --- a/test/generators/html/Ocamlary-module-type-MMM-C.html +++ b/test/generators/html/Ocamlary-module-type-MMM-C.html @@ -14,9 +14,9 @@

Module MMM.C

+

This comment is for CollectionModule.

-

This comment is for CollectionModule.

diff --git a/test/generators/html/Ocamlary-module-type-MMM.html b/test/generators/html/Ocamlary-module-type-MMM.html index 28a623b3bf..7ff937d665 100644 --- a/test/generators/html/Ocamlary-module-type-MMM.html +++ b/test/generators/html/Ocamlary-module-type-MMM.html @@ -26,6 +26,9 @@

Module type Ocamlary.MMM

+
+

This comment is for CollectionModule.

+
diff --git a/test/generators/html/Ocamlary.html b/test/generators/html/Ocamlary.html index 5391f2470f..75072ec4a2 100644 --- a/test/generators/html/Ocamlary.html +++ b/test/generators/html/Ocamlary.html @@ -718,6 +718,9 @@

+
+

This comment is for CollectionModule.

+
diff --git a/test/generators/latex/Include2.tex b/test/generators/latex/Include2.tex index 4e1bdcf245..da62fe9b78 100644 --- a/test/generators/latex/Include2.tex +++ b/test/generators/latex/Include2.tex @@ -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}% diff --git a/test/generators/latex/Ocamlary.FunctorTypeOf.tex b/test/generators/latex/Ocamlary.FunctorTypeOf.tex index d68098c1f1..fe97f00d5a 100644 --- a/test/generators/latex/Ocamlary.FunctorTypeOf.tex +++ b/test/generators/latex/Ocamlary.FunctorTypeOf.tex @@ -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}% diff --git a/test/generators/latex/Ocamlary.Recollection.tex b/test/generators/latex/Ocamlary.Recollection.tex index 0b52efb305..ade30ac653 100644 --- a/test/generators/latex/Ocamlary.Recollection.tex +++ b/test/generators/latex/Ocamlary.Recollection.tex @@ -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}% @@ -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}}}\\ diff --git a/test/generators/latex/Ocamlary.tex b/test/generators/latex/Ocamlary.tex index 864571623f..8daea9d864 100644 --- a/test/generators/latex/Ocamlary.tex +++ b/test/generators/latex/Ocamlary.tex @@ -225,9 +225,7 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% \medbreak -\label{module-Ocamlary-module-type-COLLECTION}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-COLLECTION]{\ocamlinlinecode{COLLECTION}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}. - -\label{module-Ocamlary-module-type-COLLECTION-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% +\label{module-Ocamlary-module-type-COLLECTION}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-COLLECTION]{\ocamlinlinecode{COLLECTION}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-COLLECTION-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% \medbreak \label{module-Ocamlary-module-type-COLLECTION-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\ \label{module-Ocamlary-module-type-COLLECTION-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-COLLECTION-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-COLLECTION-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-COLLECTION-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% @@ -254,10 +252,9 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% (\hyperref[module-Ocamlary-module-Recollection-argument-1-C]{\ocamlinlinecode{C}} : \hyperref[module-Ocamlary-module-type-COLLECTION]{\ocamlinlinecode{COLLECTION}}) : \hyperref[module-Ocamlary-module-type-COLLECTION]{\ocamlinlinecode{COLLECTION}} \ocamltag{keyword}{with} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-COLLECTION-type-collection]{\ocamlinlinecode{collection}} = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-element]{\ocamlinlinecode{C.\allowbreak{}element}} list - \ocamltag{keyword}{and} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-COLLECTION-type-element]{\ocamlinlinecode{element}} = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-collection]{\ocamlinlinecode{C.\allowbreak{}collection}}}\\ -\label{module-Ocamlary-module-type-MMM}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-MMM]{\ocamlinlinecode{MMM}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-MMM-module-C}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-MMM-module-C]{\ocamlinlinecode{C}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}. - -\label{module-Ocamlary-module-type-MMM-module-C-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% + \ocamltag{keyword}{and} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-COLLECTION-type-element]{\ocamlinlinecode{element}} = \hyperref[module-Ocamlary-module-Recollection-argument-1-C-type-collection]{\ocamlinlinecode{C.\allowbreak{}collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% +\medbreak +\label{module-Ocamlary-module-type-MMM}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-MMM]{\ocamlinlinecode{MMM}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-MMM-module-C}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-MMM-module-C]{\ocamlinlinecode{C}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-MMM-module-C-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% \medbreak \label{module-Ocamlary-module-type-MMM-module-C-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\ \label{module-Ocamlary-module-type-MMM-module-C-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-MMM-module-C-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-MMM-module-C-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-MMM-module-C-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% @@ -278,7 +275,8 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \label{module-Ocamlary-module-type-MMM-module-C-module-type-InnerModuleTypeA}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} InnerModuleTypeA = \hyperref[module-Ocamlary-module-type-MMM-module-C-module-InnerModuleA-module-type-InnerModuleTypeA']{\ocamlinlinecode{InnerModuleA.\allowbreak{}InnerModuleTypeA'}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{InnerModuleTypeA}.\end{ocamlindent}% \medbreak \end{ocamlindent}% -\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% +\medbreak \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Ocamlary-module-type-RECOLLECTION}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-RECOLLECTION]{\ocamlinlinecode{RECOLLECTION}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-RECOLLECTION-module-C}\ocamlcodefragment{\ocamltag{keyword}{module} C = \hyperref[module-Ocamlary-module-Recollection]{\ocamlinlinecode{Recollection(CollectionModule)}}}\\ @@ -306,9 +304,7 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Ocamlary-module-type-A}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-A]{\ocamlinlinecode{A}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-A-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ -\label{module-Ocamlary-module-type-A-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-A-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}. - -\label{module-Ocamlary-module-type-A-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% +\label{module-Ocamlary-module-type-A-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-A-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-A-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% \medbreak \label{module-Ocamlary-module-type-A-module-Q-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\ \label{module-Ocamlary-module-type-A-module-Q-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-A-module-Q-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-A-module-Q-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-A-module-Q-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% @@ -329,13 +325,12 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \label{module-Ocamlary-module-type-A-module-Q-module-type-InnerModuleTypeA}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} InnerModuleTypeA = \hyperref[module-Ocamlary-module-type-A-module-Q-module-InnerModuleA-module-type-InnerModuleTypeA']{\ocamlinlinecode{InnerModuleA.\allowbreak{}InnerModuleTypeA'}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{InnerModuleTypeA}.\end{ocamlindent}% \medbreak \end{ocamlindent}% -\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% +\medbreak \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Ocamlary-module-type-B}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-B]{\ocamlinlinecode{B}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-B-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ -\label{module-Ocamlary-module-type-B-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-B-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}. - -\label{module-Ocamlary-module-type-B-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% +\label{module-Ocamlary-module-type-B-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-B-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-B-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% \medbreak \label{module-Ocamlary-module-type-B-module-Q-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\ \label{module-Ocamlary-module-type-B-module-Q-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-B-module-Q-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-B-module-Q-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-B-module-Q-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% @@ -356,13 +351,12 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \label{module-Ocamlary-module-type-B-module-Q-module-type-InnerModuleTypeA}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} InnerModuleTypeA = \hyperref[module-Ocamlary-module-type-B-module-Q-module-InnerModuleA-module-type-InnerModuleTypeA']{\ocamlinlinecode{InnerModuleA.\allowbreak{}InnerModuleTypeA'}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{InnerModuleTypeA}.\end{ocamlindent}% \medbreak \end{ocamlindent}% -\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% +\medbreak \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Ocamlary-module-type-C}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-C]{\ocamlinlinecode{C}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\ocamltag{keyword}{include} \hyperref[module-Ocamlary-module-type-A]{\ocamlinlinecode{A}}\label{module-Ocamlary-module-type-C-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ -\label{module-Ocamlary-module-type-C-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-C-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}. - -\label{module-Ocamlary-module-type-C-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% +\label{module-Ocamlary-module-type-C-module-Q}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-C-module-Q]{\ocamlinlinecode{Q}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-C-module-Q-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection}\begin{ocamlindent}This comment is for \ocamlinlinecode{collection}.\end{ocamlindent}% \medbreak \label{module-Ocamlary-module-type-C-module-Q-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element}\\ \label{module-Ocamlary-module-type-C-module-Q-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-C-module-Q-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-C-module-Q-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-C-module-Q-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% @@ -383,7 +377,8 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \label{module-Ocamlary-module-type-C-module-Q-module-type-InnerModuleTypeA}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} InnerModuleTypeA = \hyperref[module-Ocamlary-module-type-C-module-Q-module-InnerModuleA-module-type-InnerModuleTypeA']{\ocamlinlinecode{InnerModuleA.\allowbreak{}InnerModuleTypeA'}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{InnerModuleTypeA}.\end{ocamlindent}% \medbreak \end{ocamlindent}% -\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This comment is for \ocamlinlinecode{CollectionModule}.\end{ocamlindent}% +\medbreak \ocamltag{keyword}{include} \hyperref[module-Ocamlary-module-type-B]{\ocamlinlinecode{B}} \ocamltag{keyword}{with} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-B-type-t]{\ocamlinlinecode{t}} := \hyperref[module-Ocamlary-module-type-C-type-t]{\ocamlinlinecode{t}} \ocamltag{keyword}{and} \ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-B-module-Q]{\ocamlinlinecode{Q}} := \hyperref[module-Ocamlary-module-type-C-module-Q]{\ocamlinlinecode{Q}}\end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This module type includes two signatures.\end{ocamlindent}% \medbreak diff --git a/test/generators/man/Include2.3o b/test/generators/man/Include2.3o index 061e07b196..82282441ad 100644 --- a/test/generators/man/Include2.3o +++ b/test/generators/man/Include2.3o @@ -18,10 +18,6 @@ Include2 Comment about X that should not appear when including X below\. .nf .sp -.fi -Comment about X that should not appear when including X below\. -.nf -.sp \f[CB]type\fR t = int .sp \f[CB]module\fR Y : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Ocamlary.3o b/test/generators/man/Ocamlary.3o index da0e4c711b..1ef3504938 100644 --- a/test/generators/man/Ocamlary.3o +++ b/test/generators/man/Ocamlary.3o @@ -495,11 +495,6 @@ This comment is for CollectionModule\. \f[CB]module\fR \f[CB]type\fR COLLECTION = \f[CB]sig\fR .br .ti +2 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +2 \f[CB]type\fR collection .fi .br @@ -591,6 +586,11 @@ module type of COLLECTION \f[CB]with\fR \f[CB]type\fR collection = C\.element list \f[CB]and\fR \f[CB]type\fR element = C\.collection +.fi +.br +.ti +2 +This comment is for CollectionModule\. +.nf .sp \f[CB]module\fR \f[CB]type\fR MMM = \f[CB]sig\fR .br @@ -598,11 +598,6 @@ module type of \f[CB]module\fR C : \f[CB]sig\fR .br .ti +4 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +4 \f[CB]type\fR collection .fi .br @@ -684,6 +679,12 @@ This comment is for InnerModuleTypeA\. .br .ti +2 \f[CB]end\fR +.fi +.br +.ti +4 +This comment is for CollectionModule\. +.nf + .br \f[CB]end\fR .sp @@ -782,11 +783,6 @@ This comment is for InnerModuleTypeA\. \f[CB]module\fR Q : \f[CB]sig\fR .br .ti +4 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +4 \f[CB]type\fR collection .fi .br @@ -868,6 +864,12 @@ This comment is for InnerModuleTypeA\. .br .ti +2 \f[CB]end\fR +.fi +.br +.ti +4 +This comment is for CollectionModule\. +.nf + .br \f[CB]end\fR .sp @@ -880,11 +882,6 @@ This comment is for InnerModuleTypeA\. \f[CB]module\fR Q : \f[CB]sig\fR .br .ti +4 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +4 \f[CB]type\fR collection .fi .br @@ -966,6 +963,12 @@ This comment is for InnerModuleTypeA\. .br .ti +2 \f[CB]end\fR +.fi +.br +.ti +4 +This comment is for CollectionModule\. +.nf + .br \f[CB]end\fR .sp @@ -978,11 +981,6 @@ This comment is for InnerModuleTypeA\. \f[CB]module\fR Q : \f[CB]sig\fR .br .ti +4 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +4 \f[CB]type\fR collection .fi .br @@ -1064,6 +1062,11 @@ This comment is for InnerModuleTypeA\. .br .ti +2 \f[CB]end\fR +.fi +.br +.ti +4 +This comment is for CollectionModule\. +.nf .sp .ti +2 diff --git a/test/generators/man/Ocamlary.FunctorTypeOf.3o b/test/generators/man/Ocamlary.FunctorTypeOf.3o index b64014925f..1e60c212c4 100644 --- a/test/generators/man/Ocamlary.FunctorTypeOf.3o +++ b/test/generators/man/Ocamlary.FunctorTypeOf.3o @@ -22,11 +22,6 @@ This comment is for FunctorTypeOf\. \f[CB]module\fR Collection : \f[CB]sig\fR .br .ti +2 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +2 \f[CB]type\fR collection .fi .br diff --git a/test/generators/man/Ocamlary.Recollection.3o b/test/generators/man/Ocamlary.Recollection.3o index be2ab27396..48406df06d 100644 --- a/test/generators/man/Ocamlary.Recollection.3o +++ b/test/generators/man/Ocamlary.Recollection.3o @@ -8,6 +8,9 @@ Ocamlary\.Recollection \fBModule Ocamlary\.Recollection\fR .in .sp +.fi +This comment is for CollectionModule\. +.nf .SH Documentation .sp .nf @@ -19,11 +22,6 @@ Ocamlary\.Recollection \f[CB]module\fR C : \f[CB]sig\fR .br .ti +2 -.fi -This comment is for CollectionModule\. -.nf -.sp -.ti +2 \f[CB]type\fR collection .fi .br @@ -109,10 +107,6 @@ This comment is for InnerModuleTypeA\. \fB2 Signature\fR .in .sp -.fi -This comment is for CollectionModule\. -.nf -.sp \f[CB]type\fR collection = C\.element list .fi .br diff --git a/test/xref2/dune b/test/xref2/dune index 58c41be63d..2a08c364ae 100644 --- a/test/xref2/dune +++ b/test/xref2/dune @@ -42,7 +42,8 @@ shadow5 js_stack_overflow expansion - github_issue_1066) + github_issue_1066 + include_module_type_of_preamble) (enabled_if (>= %{ocaml_version} 4.08.0))) diff --git a/test/xref2/include_module_type_of_preamble.t/bar.ml b/test/xref2/include_module_type_of_preamble.t/bar.ml new file mode 100644 index 0000000000..127b93cd96 --- /dev/null +++ b/test/xref2/include_module_type_of_preamble.t/bar.ml @@ -0,0 +1,10 @@ +include Foo + +module P = struct + (** Preamble for P. *) +end + +(** Outside preamble for Q. *) +module Q = struct + (** Inside preamble for Q. *) +end diff --git a/test/xref2/include_module_type_of_preamble.t/foo.mli b/test/xref2/include_module_type_of_preamble.t/foo.mli new file mode 100644 index 0000000000..dcd8fff3a4 --- /dev/null +++ b/test/xref2/include_module_type_of_preamble.t/foo.mli @@ -0,0 +1,8 @@ +(** Preamble for Foo. *) + +(** Preamble for O. *) +module O : sig + val x : int +end + +include module type of O (** @inline *) diff --git a/test/xref2/include_module_type_of_preamble.t/run.t b/test/xref2/include_module_type_of_preamble.t/run.t new file mode 100644 index 0000000000..4f35f10805 --- /dev/null +++ b/test/xref2/include_module_type_of_preamble.t/run.t @@ -0,0 +1,165 @@ + $ compile foo.mli bar.ml + $ odoc html-generate -o html --indent foo.odocl + $ odoc html-generate -o html --indent bar.odocl + +Foo contains "Preamble for O" once. + + $ cat html/test/Foo/index.html + + + Foo (test.Foo) + + + + + + + + +

Module Foo

+

Preamble for Foo.

+
+
+
+
+ + + module O + + : sig ... + end + + +

Preamble for O.

+
+
+
+ + val x : int +
+
+
+ + + +Bar includes Foo and should also contain "Preamble for O" once. +Bar doesn't contain "Preamble for Foo" on purpose. + + $ cat html/test/Bar/index.html + + + Bar (test.Bar) + + + + + + + + +

Module Bar

+
+
+
+
+ + + include + module type + of struct + include + Foo end + + + +
+
+ + module O + = Foo.O + +

Preamble for O.

+
+
+
+ + val x : int +
+
+
+
+
+
+ + + module P + + : sig ... + end + + +

Preamble for P.

+
+
+
+ + + module Q + + : sig ... + end + + +

Outside preamble for Q.

+
+
+ + + +Check the preambles: + + $ cat html/test/Bar/Q/index.html + + + Q (test.Bar.Q) + + + + + + + + +
+

Module Bar.Q

+

Outside preamble for Q.

Inside preamble for Q.

+
+ + + $ cat html/test/Bar/P/index.html + + + P (test.Bar.P) + + + + + + + + +
+

Module Bar.P

Preamble for P.

+
+ + diff --git a/test/xref2/module_list.t/run.t b/test/xref2/module_list.t/run.t index ddd882d3a6..91966549fc 100644 --- a/test/xref2/module_list.t/run.t +++ b/test/xref2/module_list.t/run.t @@ -36,9 +36,9 @@ Everything should resolve: {"`Resolved":{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"With_type"]}}} {"Some":[{"`Word":"Doc"},"`Space",{"`Word":"for"},"`Space",{"`Code_span":"T"},{"`Word":"."}]} {"`Resolved":{"`Alias":[{"`Module":[{"`Identifier":{"`Root":[{"Some":{"`Page":["None","test"]}},"External"]}},"X"]},{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"Alias"]}}]}} - "None" + {"Some":[{"`Word":"Doc"},"`Space",{"`Word":"for"},"`Space",{"`Code_span":"X"},{"`Word":"."}]} {"`Resolved":{"`Alias":[{"`Canonical":[{"`Module":[{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"Internal"]}},"C1"]},{"`Resolved":{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"C1"]}}}]},{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"C1"]}}]}} - "None" + {"Some":[{"`Word":"Doc"},"`Space",{"`Word":"for"},"`Space",{"`Code_span":"C1"},{"`Word":"."}]} {"`Resolved":{"`Alias":[{"`Canonical":[{"`Module":[{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"Internal"]}},"C2"]},{"`Resolved":{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"C2"]}}}]},{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"C2"]}}]}} "None" {"`Resolved":{"`Identifier":{"`Module":[{"`Root":[{"Some":{"`Page":["None","test"]}},"Main"]},"Inline_include"]}}}