API documentation cleanup#108500
Conversation
There was a problem hiding this comment.
Two newlinews here? lol
There was a problem hiding this comment.
in ScrollPhysics you added ... without a newline.
There was a problem hiding this comment.
removed the leading/trailing blank lines here
There was a problem hiding this comment.
in ScrollPhysics you added ... without a newline.
dev/bots/analyze_snippet_code.dart
Outdated
dev/bots/analyze_snippet_code.dart
Outdated
dev/bots/analyze_snippet_code.dart
Outdated
dev/bots/analyze_snippet_code.dart
Outdated
There was a problem hiding this comment.
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.
Should we add const and extension ?
This regexp will not match top level functions or mutable variables.
There was a problem hiding this comment.
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.
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); |
dev/bots/analyze_snippet_code.dart
Outdated
There was a problem hiding this comment.
| 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.
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.
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),
];|
(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.
Thanks for cleaning this up!!!
There was a problem hiding this comment.
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.
I have the same concern for many other places in this PR...
There was a problem hiding this comment.
The four space indent triggers monospace font.
There was a problem hiding this comment.
Is ... special cased somehow? Otherwise, shouldn't this be
| /// ... | |
| /// // ... |
There was a problem hiding this comment.
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.
yeah, seems reasonable, i'll remove this feature.
There was a problem hiding this comment.
(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.
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.
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.
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.
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.
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.
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.