Skip to content
New issue

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

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

Already on GitHub? # to your account

Design lexical structure for documentation comments #2371

Open
Tracked by #3921
kritzcreek opened this issue Feb 19, 2021 · 1 comment
Open
Tracked by #3921

Design lexical structure for documentation comments #2371

kritzcreek opened this issue Feb 19, 2021 · 1 comment
Labels
language design Requires design work P3 low priority, resolve when there is time tools Motoko-related tooling

Comments

@kritzcreek
Copy link
Contributor

kritzcreek commented Feb 19, 2021

I don't think this is high priority.
The current implementation works well enough that we can document base and users can document their libraries, but it would be nice to do things "properly" at some point.
Right now the rules for what constitutes a documentation comment only exist as code inside mo_frontend/lexer.ml -> doc_comment_from_trivia.
Once we've come up with a coherent design we should implement it and document the rules in the language manual.

Current state and tricky issues

Currently documentation comments must start with /// followed by a space and text until the end of line.
An exception about the trailing space is made for /// without text after it. That constitutes a newline.

We also have /// @deprecated comments which use the same rules as above, and can be used to deprecate fields.

We also allow /** doc_comment */ but only strip leading and trailing whitespace for the whole multiline comment not for individual lines. There is no @deprecated equivalent for multi-line comments.
If we want multiline documentation comments to work well we'll have to come up with a ruleset for stripping indentation.

The comments contents are treated as Markdown for the Html output and passed through verbatim for the Asciidoc output.
This means we're trying to use the subset of Markdown that is also valid Asciidoc in the base library documentation.
Part of the reason for this being tricky is that I couldn't find a good Markdown, or any Asciidoc parser for OCaml.

@kritzcreek kritzcreek added language design Requires design work tools Motoko-related tooling P3 low priority, resolve when there is time labels Feb 19, 2021
@nomeata
Copy link
Collaborator

nomeata commented Feb 19, 2021

As for the markers, maybe worth doing what rust does, and hoping they thought a lot about it, so we don’t have to

@crusso crusso mentioned this issue Apr 4, 2023
79 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
language design Requires design work P3 low priority, resolve when there is time tools Motoko-related tooling
Projects
None yet
Development

No branches or pull requests

2 participants