-
Notifications
You must be signed in to change notification settings - Fork 96
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
Separate handling of internal tags #661
Conversation
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.
I've added a warning in case an internal tag is unhandled (eg. @inline
on an item that isn't an include
or @canonical
on a value), for the same reason as for removing the placeholder in case of syntax error.
@@ -4,6 +4,8 @@ top-comment. | |||
The module Test__X is expected to be referenced through Test.X. | |||
|
|||
$ compile test__x.mli test.ml | |||
File "test.ml", line 15, characters 6-24: | |||
Unexpected tag '@canonical' at this location. |
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.
This is expected. This @canonical
tag is indeed unhandled.
This PR implements the required refactoring to fix this easily, though.
Error.warning status.warnings e; | ||
let placeholder = [ `Word "@canonical"; `Space " "; `Code_span s ] in | ||
let placeholder = List.map (Location.at location) placeholder in | ||
Error (Location.at location (`Paragraph placeholder))) |
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.
I've removed this placeholder logic. This tag isn't intended to be rendered. If it contains a syntax error, only the programmer need to be informed (through a warning) and not users reading the documentation.
Internal tags are used to change Odoc's behavior and are never rendered (@canonical, @inline, @OPEN and @closed). This handles them earlier and removes them from the description of comments.
Handle tags as soon as possible instead of passing them around. This ensures that internal tags are always handled.
It was possible to attach those tags to anything and would be ignored if unecessary. This emits a warning in this case.
Other than that minor point, I think this is a really nice change. |
test/xref2/module_preamble.t/run.t
Outdated
File "a.mli", line 4, characters 4-17: | ||
Unexpected tag '@canonical' at this location. |
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.
This isn't expected however. This is caused by `Root
paths to not be valid canonical paths, I'll add a different warning for this case.
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.
I've just added a specific warning for this case.
This case was ignored until now. Since the warning about unexpected tag was added, this case is reported incorrectly.
Fixes #632 (comment)
Internal tags are used to change Odoc's behavior and are never rendered. This caused Stdlib modules to have no synopsis because the
@canonical
tag was found before any synopsis could be extracted.This PR handles these tags (
@canonical
,@inline
,@open
and@closed
) earlier in the pipeline and removes them from the model.This isn't the only solution to this problem but I think it's a nice refactoring to have. I believe regular tags should also be handled (previous discussion).