-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc should understand javadoc-style comments #2498
Comments
The other downside is that this will make it more difficult to extract docs from compiled crates (which we can't actually do yet). Possibly we could have a rustc pass to promote doc comments to doc attributes. |
Maybe we should just treat Rustdoc comments as a kind of attribute and embed them in the AST/metadata like other attributes. |
I kind of like the |
OK then, given that this is marked easy, id like to work on it. Could @brson please point me in the right direction? |
The basic strategy that I recommend is to modify the parser to treat doc comments as a special type of attribute, so that they are easily and automatically associated with the appropriate AST nodes. The one significant wrinkle is that we have to distinguish, like attributes, between docs that apply to the thing that follows and docs that apply to the preceding thing. With attributes we currently use the trailing semi:
Which is also how we distinguish crate attributes (semi-terminated attributes at the top of a .rc file apply to the 'containing' crate). I do want to change this syntax in a separate issue (#2569). I suggest for doc comments that we use doxygen's convention for specifying docs that come after the thing they document:
It's unfortunate to have to distinguish between the two but not doing so would probably require much more subtle heuristics. So here is an approximate plan of action:
@Dretch hopefully this is enough to get started |
@graydon you might want to be aware of this issue |
Thanks. I am fine with reforming the applies-to-next / applies-to-enclosing syntax, but not sure angle bracket is the most suggestive. Don't feel Doxygen is an important enough precedent to drive this choice. Maybe play with a couple other variants visually in a scratch buffer to see if anything else looks a little better? |
Also note that the lexer already has logic to extract comments and in particular grab the indentation-wall out of the way, it does so during the scan for comments-and-literals that it transplants into pretty-printed source. |
I have made some changes to hopefully fix this issue. You can see them here: Dretch@df2f4bb Unfortunately I can't seem to make a pull request of just this commit - i keep getting this commit in the pull request too: Dretch@986662c. I think this may be because I have screwed up the branching somehow. |
I did notice that the patch included a fix for a commented-out comment ( |
To avoid this, how about having |
I agree with @brson, not too keen on I'd suggest either inserting an extra space in that testcase (i.e. writing it as (I gather sometimes people want long lines of |
I was going to go with:
..but then I noticed that this conflicts with the So how about using |
I would rather change the error comment syntax in the test suite. Anything will do since it's not part of the language. How about |
That sounds ok to me. |
…omments.py (and manually tweaking) - for issue #2498
I have updated https://github.com/mozilla/rust/wiki/Doc-using-rustdoc to reflect the new syntax. |
Thanks, Dretch! Closing. |
Both
/** ... */
and///
syntaxes.It should be relatively simple to write a rustdoc pass to pull out these comments. The only complications are that we need to heuristically associate comments with AST nodes, and we have to be able to identify and strip the common wall of stars:
The text was updated successfully, but these errors were encountered: