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 @@
Include2Comment about X that should not appear when including X below.
FunctorTypeOf.CollectionThis comment is for CollectionModule.
This comment is for CollectionModule.
Recollection.CThis comment is for CollectionModule.
This comment is for CollectionModule.
Ocamlary.RecollectionThis comment is for CollectionModule.
This comment is for CollectionModule.
A.QThis comment is for CollectionModule.
This comment is for CollectionModule.
Ocamlary.AThis comment is for CollectionModule.