Although Dart supports two syntaxes of doc comments (/// and /**), we prefer using /// for doc comments.
For an example of a class description with example code, see Completer (generated doc, source code).
The Dart Style Guide says:Although Dart supports two syntaxes of doc comments (/// and /**), we prefer using /// for doc comments.In a separate article, Guidelines for Doc Comments, the examples show /// comments but this convention is not explicitly stated. Confusingly, this article says:For an example of a class description with example code, see Completer (generated doc, source code).The link leads to the source code for Completer, which only uses /** comments, not ///. In fact, glancing through various parts of the Dart library, I can't find *any* source code that uses /// comments.
Is this a convention that has changed recently?
The reason I ask is that my text editor does not handle '///' comments correctly, and before I file a bug report I want to make sure that I understand that /// comments are actually a real convention.
Also, what is the justification for the /// convention? I find /** to be more readable and more consistent with the conventions of other languages.
Besides the 'preference' stated in the Dart style guide, is there any technical reason to prefer /// to /**?
/** This is a doc comment that is starting to get pretty long and near the end
/*** This is a doc comment that is starting to get pretty long and near the end
/*** This is a doc comment that is starting to get pretty long and near the end* of the line.*/
/// This is a doc comment that is starting to get pretty long and near the end
/// This is a doc comment that is starting to get pretty long and near the end/// of the line.
/// Groceries:////// * Gruyère/// * Ham/// * Sourdough/// * Eggs
/*** Groceries:** * Gruyère* * Ham* * Sourdough* * Eggs*/
If you stick to commenting this way and then need to comment out a large section of code you can do that with /* */ and not run in to any interference from method comments.
May I suggest updating the "Guidelines for Doc Comments" with 2 changes:I would submit a PR myself but I'm not sure what Dart class to point at as a good example of /// dartdocs. If you can suggest a class with good dartdocs, I'd be happy to submit a PR.
- Explicitly state that /// and /** are supported, but /// is the convention. Given that this convention is probably the first thing a novice needs to learn about dartdoc, I think it makes sense to state the convention at the top of the "Guidlines for Doc Comments" article. (This duplicates the style guide a bit, but the style guide is much broader and readers interested specifically in dartdoc may not read the entire style guide.)
- Instead of linking to Completer as an example of good dartdoc, link to a class that uses the /// dartdoc style.
What about adding an command line option to dartfmt in dart_style to automatically convert /** .. */ doc-comments
to /// .. doc-comments?
That would be easy to implement and quite useful.
What about adding an command line option to dartfmt in dart_style to automatically convert /** .. */ doc-comments
to /// .. doc-comments?
That would be easy to implement and quite useful.
-g.
On Friday, March 13, 2015 at 8:07:09 PM UTC+2, Bob wrote:On Fri, Mar 13, 2015 at 10:41 AM, Mark Haase <meh...@gmail.com> wrote:May I suggest updating the "Guidelines for Doc Comments" with 2 changes:I would submit a PR myself but I'm not sure what Dart class to point at as a good example of /// dartdocs. If you can suggest a class with good dartdocs, I'd be happy to submit a PR.
- Explicitly state that /// and /** are supported, but /// is the convention. Given that this convention is probably the first thing a novice needs to learn about dartdoc, I think it makes sense to state the convention at the top of the "Guidlines for Doc Comments" article. (This duplicates the style guide a bit, but the style guide is much broader and readers interested specifically in dartdoc may not read the entire style guide.)
- Instead of linking to Completer as an example of good dartdoc, link to a class that uses the /// dartdoc style.
Great idea. Filed a bug: https://github.com/dart-lang/www.dartlang.org/issues/1280Thanks!- bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.