-
Notifications
You must be signed in to change notification settings - Fork 124
Need ability to create library-level API docs without an explicit library tag. #1082
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
Comments
dartdoc gets the doc comment for all elements from the analyzer. So analyzer would need to be modified to support getting doc comments from a dart file before the first declaration. @Sfshaza, could you open a issue for the analyzer and link it in here? Thanks! |
After some discussion, the new proposed rule is simpler: Use the first doc comment attached to any directive (import, export, etc.). |
This fix has been made to the analyzer. Upgrading to new analyzer package, current 0.27.1+2, will fix this issue. |
I think this is fixed? |
I don't know if it was ever fixed. I don't see any library comments for the stagehand docs unless I add a library statement ( |
You're right, we still require the library statement -- if it was fixed at one point, it was before I took over. |
And I'm actually not right at all. This does work in dartdoc's internal tests to my surprise. Don't know why it doesn't work in your case, will require some investigation. |
Very strange. Thanks for looking into this. Please let me know if there's anything I can do to help. |
Any update here? |
AFAIK state has not changed. |
I think we'd want this: dart-lang/language#1073 |
@kevmoo Note that we do recognize and generate docs for the library, this issue is a request to notice a comment block at the beginning of the file without a library tag and pretend it is a library documentation comment. |
Yup. But I find a lot of folks are blocked on what to name their libraries. If it could just be "naked" so we'd have a place to hang things – it'd be nice. Less guessing for things like dartdoc and test |
@kevmoo The proposed solution in dart-lang/language#1073 (have a library tag with no name, e.g. |
If you don't include a library statement, then the library is implicitly named as the filename, right? Like |
@Levi-Lesches No particular reason, other than the language needs to support having a |
Yeah I totally agree -- so is that what you would expect a |
From my perspective, it eliminates hacks we have now to allow "floating" annotations – without having to think about the name of the library. |
@Levi-Lesches Pretty much. The only difference would be the analyzer would be able to connect not only annotations but also documentation specifically to that statement, and therefore to returned |
A A library with no library declaration has the empty name, and |
Another workaround for libraries that don't have any Regarding a bare |
You're suggesting that in a file with no That's ... not impossible. It's more significance than we usually assign to whitespace (which is "none, whatsoever"), but it's also against normal style rules/formatter dictate to have empty lines between metadata and what they annotate. That means that it usually won't happen by acccident (and if it does, the formatter will retain that empty line so you can see that something is going on.) I'm not sold on the idea ("prefer explicit to implicit" etc.), but if that is what people really want, and our parser and formatter people think they can handle it, then it's probably acceptable. The failure mode is to accidentally add an empty line between an annotation and the import (or other declaration, if you have no imports) that it's intended to annotate, and then nothing warns you that it's not where it's supposed to be. |
I think the implicit behavior would not as easy to learn as a line with |
While /// My library.
/// My function.
void foo() {} is much more natural (and wouldn't require changes to the language spec). |
I tend to agree with the principle of explicit rather than implicit -- having special, magical behavior for docs is something we want to move away from rather than add to. To deal with the "something to learn" problem, I could imagine a lint that detects the example @jamesderlin mentions and redirects users to use a bare |
IMHO the rule that first doc-comment block in the file followed by a blank line is-a library description is not at all magic, it feels natural. While sourcing the docs heading name from the file's name is a bit magic, it also is not that uncommon in other languages. Then "add a If it should be explicit, I would suggest use yet more explicit |
Seems the choice was to go for an empty Tracking new documentation in dart-lang/site-www#4314 |
@srawlins – can we close this out? |
Ah ha, yes! |
Bob suggests:
Then we treat that as the doc comment for the library.
The text was updated successfully, but these errors were encountered: