From 03b4dc515ffffc705b373fa99517422a5b82524b Mon Sep 17 00:00:00 2001 From: Joris Giovannangeli Date: Fri, 4 Feb 2022 14:06:07 +0100 Subject: [PATCH 1/3] ignore top ppx generated attributes in top comment extraction --- src/loader/doc_attr.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/loader/doc_attr.ml b/src/loader/doc_attr.ml index c3cb178fb2..b55820e0fe 100644 --- a/src/loader/doc_attr.ml +++ b/src/loader/doc_attr.ml @@ -147,7 +147,9 @@ let extract_top_comment internal_tags ~classify parent items = |> Error.raise_parser_warnings in (tl, ast_docs) - | None -> (items, [])) + | None -> + let items, ast_docs = extract ~classify tl in + (hd :: items, ast_docs)) | Some `Open -> let items, ast_docs = extract ~classify tl in (hd :: items, ast_docs) From 64efc45f6842ccb4f67fdf49930bf71ca9c1ae59 Mon Sep 17 00:00:00 2001 From: Joris Giovannangeli Date: Fri, 4 Feb 2022 18:53:40 +0100 Subject: [PATCH 2/3] add changes entry for #819 --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index b231cfd6e6..0296ba54c4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Bugs fixed functor arguments to have different filenames (@jonludlam, #795) - Better memory/disk space usage when handling module alias chains (@jonludlam, #799) - Resolving class-type paths (ie., `val x : #c`) (@jonludlam, #???) +- Skip top-level attributes while extracting the top comment. Fix top-comment extraction with PPX preprocessing (@jorisgio, #819) 2.0.2 ----- From d6132e2391ffe1a722eb3b4913c9d7eebcd336b4 Mon Sep 17 00:00:00 2001 From: Joris Giovannangeli Date: Fri, 4 Feb 2022 19:01:44 +0100 Subject: [PATCH 3/3] odoc_for_author: document top-level attributes being ignored for top comments extraction --- doc/odoc_for_authors.mld | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/odoc_for_authors.mld b/doc/odoc_for_authors.mld index c9a49f9d83..76448b635b 100644 --- a/doc/odoc_for_authors.mld +++ b/doc/odoc_for_authors.mld @@ -576,10 +576,12 @@ module M : sig end ]} -As an exception, [open] statements are allowed to be placed before the top-comment. +As an exception, [open] statements and attributes are allowed to be placed before the top-comment. For example: {[ +[@@@ocaml.warning "-6"] + (* Copyright header *) open Base