Skip to content

Ignore non doc attributes at top level genrated by ppx #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
4 changes: 3 additions & 1 deletion doc/odoc_for_authors.mld
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/loader/doc_attr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down