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 ----- 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 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)