-
Notifications
You must be signed in to change notification settings - Fork 86
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
Ignore non doc attributes at top level genrated by ppx #819
Ignore non doc attributes at top level genrated by ppx #819
Conversation
src/loader/doc_attr.ml
Outdated
@@ -139,7 +139,7 @@ let extract_top_comment internal_tags ~classify parent items = | |||
let rec extract ~classify = function | |||
| hd :: tl as items -> ( | |||
match classify hd with | |||
| Some (`Attribute attr) -> ( | |||
| Some (`Attribute ({ Parsetree.attr_name = { txt = "ocaml.text" ; _ }; _ } as attr)) -> ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching this is already the responsibility of parse_attribute
. I think what you mean is to change the None
case below to continue iterating rather than stopping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - nice find though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, i missed that. Thanks !
eed0688
to
03b4dc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some documentation about this in doc/odoc_for_authors.mld
in section top_comment
that should be updated (where it talks about the exception for open
statements).
Otherwise the code looks good.
|
I mean that there's documentation about what is "ignored" at the beginning of a file in |
We could also do with a CHANGES entry. |
Thanks @jorisgio ! |
CHANGES: Additions - New subcommand to resolve references (@panglesd, @lubega-simon, ocaml/odoc#812) - Improved rendering of long signatures (@panglesd, ocaml/odoc#782) - Handle comments attached to open statement as floating comment, instead of dropping them (@panglesd, ocaml/odoc#797) - Empty includes (containing entirely shadowed entries) are now hidden (@panglesd, ocaml/odoc#798) Bugs fixed - Fix a missing Result constructor during compile. This will cause some functor arguments to have different filenames (@jonludlam, ocaml/odoc#795) - Better memory/disk space usage when handling module alias chains (@jonludlam, ocaml/odoc#799) - Resolving class-type paths (ie., `val x : #c`) (@jonludlam, ocaml/odoc#809) - Skip top-level attributes while extracting the top comment. Fix top-comment extraction with PPX preprocessing (@jorisgio, ocaml/odoc#819) - Better handling of @canonical tags (@jonludlam, ocaml/odoc#820) - css: improved layout (@jonludlam, @Julow, ocaml/odoc#822)
Currently, odoc fails to extract synopsis from a signature pre-processed by a ppx. This is because ppx add a "ocaml.ppx.context" attribute at top level before the top comment.
I'm not sure the current fix is the best way to fix, since it uses string matching "ocaml.text" to continue unrolling the list of items until it finds an attribute that is a document.