-
Notifications
You must be signed in to change notification settings - Fork 29.7k
API documentation cleanup #108500
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
API documentation cleanup #108500
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.
Two newlinews here? lol
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.
good catch. fixed.
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.
in ScrollPhysics you added ... without a newline.
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.
removed the leading/trailing blank lines here
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.
in ScrollPhysics you added ... without a newline.
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.
same
dev/bots/analyze_snippet_code.dart
Outdated
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.
typo: ellipsis
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.
fixed
dev/bots/analyze_snippet_code.dart
Outdated
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.
typo: not not
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.
fixed
dev/bots/analyze_snippet_code.dart
Outdated
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.
Should we add num?
dev/bots/analyze_snippet_code.dart
Outdated
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.
Should we add num?
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.
added, but i wouldn't encourage anyone to write code using num.
dev/bots/analyze_snippet_code.dart
Outdated
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.
Should we add const and extension ?
This regexp will not match top level functions or mutable variables.
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.
Added extension, though hopefully no examples even use that.
const is intentionally not here because it's used when showing examples of Widgets, which are expressions.
Top-level functions are handled by _maybeFunctionDeclarationRegExp.
Mutable variables are hard to recognize. We never use var because of the analysis options. Generally they end up being treated as statements, which seems to work for our current examples.
dev/bots/analyze_snippet_code.dart
Outdated
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.
It looks like we can refactor this to:
| if (line.startsWith('// // ignore_for_file: ')) { | |
| final _Line newLine = _Line( | |
| line: lineNumber, | |
| indent: 3, | |
| code: line.substring(3), | |
| ); | |
| ignorePreambleLinesOnly.add(newLine); | |
| preambleLines.add(newLine); | |
| } else { | |
| preambleLines.add(_Line(line: lineNumber, indent: 3, code: line.substring(3))); | |
| } | |
| final _Line newLine = _Line(line: lineNumber, indent: 3, code: line.substring(3)); | |
| if (line.startsWith('// ignore_for_file: ')) { | |
| ignorePreambleLinesOnly.add(newLine); | |
| } | |
| preambleLines.add(newLine); |
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.
good call!
dev/bots/analyze_snippet_code.dart
Outdated
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.
| if (preamble.isNotEmpty) | |
| ...preamble, | |
| if (preamble.isNotEmpty) | |
| const _Line.generated(), // blank line | |
| if (preamble.isNotEmpty) ...[ | |
| ...preamble, | |
| const _Line.generated(), // blank line | |
| ], |
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 considered doing that but isn't that less efficient? now you're building a list just to inject it back into another list, rather than just evaluating a boolean variable twice.
dev/bots/analyze_snippet_code.dart
Outdated
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.
We can use collection-if and collection-for:
final List<_Line> codeLines = <_Line>[
if (prefix != null) _Line.generated(code: prefix),
for (int i = 0; i < code.length; ++i)
_Line(
code: code[i],
line: firstLine.line + i,
indent: firstLine.indent,
),
if (postfix != null) _Line.generated(code: postfix),
];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.
done
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.
unnecessary wrap
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.
fixed
|
(tests are failing because I haven't landed the engine part yet) |
|
PR updated per comments, thanks for the reviews! |
goderbauer
left a comment
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.
Thanks for cleaning this up!!!
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 would expect that the alignment here will be off when these are rendered with a variable-width font on https://api.flutter.dev/?
(or does dartdoc have a special feature that I am not aware off and these will continue to render with a fixed-width font even without the ```?)
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 have the same concern for many other places in this PR...
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.
The four space indent triggers monospace font.
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.
Is ... special cased somehow? Otherwise, shouldn't this be
| /// ... | |
| /// // ... |
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.
Now that I read the doc in analyze_snippet_code.dart, I see that it is special cased. I would argue that that isn't necessary and instead the ... should just be added as a comment. Has the added benefit that if I copy this snippet into my own code, I don't get a bunch of analyzer warnings on this line. Everywhere else (e.g. // continuing from previous example...) these are also used in comments.
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.
yeah, seems reasonable, i'll remove this feature.
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.
(Or more to the point, make it require // .... The feature itself is still useful, it adds an ignore.)
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.
We should somewhere document what strings with special meaning you can use so we can point people to it in code reviews. I wonder, what would be a good place for that.
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 see that they are documented in analyze_snippet_code.dart.
dev/bots/analyze_snippet_code.dart
Outdated
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.
Otherwise, they are... ?
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.
technically this bullet point continues the sentence started by "Such snippets:", though admittedly by this point in the text the reader has probably forgotten this. :-)
dev/bots/analyze_snippet_code.dart
Outdated
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 wonder if we should give these control comments a common prefix. It would indicate to the reader that these comments are actually load-bearing. Also, if I want to author a new example and look at an existing one it would give me something to search for to understand what other control comments are available.
On the other hand, it my hinder the reading flow of these examples...
Just a thought, not feeling super-strongly about this either way.
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.
yeah i feel super constrained here because the most important result is that the examples flow well for the developers.
on the other hand, these load-bearing comments are so magical, ugh.
I've added a message to the snippet analyzer's output that just points right at the docs, FWIW. Dunno how much it'll help.
4b573c0 to
1e667aa
Compare
|
Landed fixes for the dev/bots/test tests. |
|
This depends on flutter/engine#35146 rolling into the framework. |
goderbauer
left a comment
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.
RSLGTM when checks are happy.
|
Now blocked on flutter/engine#35235 |
d4f1fc3 to
4fc72cc
Compare
|
0c2b01d to
9cf960d
Compare
* Enable asserst when running analyze_snippet_code.dart * Revamp analyze_snippet_code.dart to actually analyze _all_ code snippets. * Add a full example for SliverOpacity. * Export src/cupertino/debug.dart which we somehow had missed. * Fix a zillion minor errors in API docs and especially API sample code.

Enable asserst when running analyze_snippet_code.dart
Revamp analyze_snippet_code.dart to actually analyze all code snippets.
Add a full example for SliverOpacity.
Export src/cupertino/debug.dart which we somehow had missed.
Fix a zillion minor errors in API docs and especially API sample code.