Commit graph

45 commits

Author SHA1 Message Date
Greg Spencer d0491dcf15
Add the channel parameter to the Dartpad samples (#115018)
* Add the channel paramter to the Dartpad samples

* Add sanity check test

* Make sample_id more generic
2022-11-09 23:47:05 +00:00
Greg Spencer 1f0760a1cc
Fix API docs CSS files so dark mode works (#112023) 2022-09-21 18:33:08 +00:00
Ian Hickson de938e508c
Fix HTML in skeletons (ampersands must be escaped) (#109360) 2022-08-11 15:39:17 +00:00
Ian Hickson 9b2668a451
Minor fix compendium (#107874) 2022-08-11 02:33:07 +00:00
Michael Goderbauer 9ee566beb4
Remove sample templates (#103575) 2022-05-12 10:27:11 -07:00
Greg Spencer c7643cf54e
Fix samples so that they present properly in the docs (#97224) 2022-02-24 18:51:22 -08:00
Greg Spencer bbc21fe3ed
Fix some issues with samples (#95044) 2021-12-13 09:29:09 -08:00
Greg Spencer ab2b0851a2
Add smoke tests for all the examples, fix 17 broken examples. (#89021)
This adds a smoke test for every single API example. It also fixes 17 tests that had bugs in them, or were otherwise broken, and even fixes one actual bug in the framework, and one limitation in the framework.

The bug in the framework is that NetworkImage's _loadAsync method had await response.drain<List<int>>();, but if the response is null, it will throw a cryptic exception saying that Null can't be assigned to List<int>. The fix was just to use await response.drain<void>(); instead.

The limitation is that RelativePositionedTransition takes an Animation<Rect> rect parameter, and if you want to use a RectTween with it, the value emitted there is Rect?, and one of the examples was just casting from Animation<Rect> to Animation<Rect?>, which is invalid, so I modified RelativePositionedTransition to take a Rect? and just use Rect.zero if the rect is null.
2021-09-28 09:32:06 -07:00
Greg Spencer 10e4b04010
Switch document generation to use the snippets package (#87231)
Switch document generation to use the snippets package instead of the snippets code in the Flutter repo. In the process, some bugs in sample code analysis have been fixed, and I've fixed some more errors in the samples.

This will allow the snippets package to be developed separately from the Flutter repo, and reduce the code in the Flutter repo.

The snippets code is deleted in this PR.

I also converted some comments in the snippet templates to be regular comments instead of doc comments, because having a doc comment block before the imports causes the Dart import sorter to lose the comment. They should have been regular comments in the first place.

The snippets package resides in the assets-for-api-docs repo.

The sample analysis has also been converted to be run in parallel, and I've bumped the Dartdoc version to 1.0.2.
2021-08-11 19:48:29 -07:00
Michael Goderbauer b8a2456737
Enable library_private_types_in_public_api lint (#81578) 2021-05-10 16:26:16 -07:00
Shi-Hao Hong 49adef6792
[State Restoration] Code sample templates, migrate existing code samples (#78757)
* Create state restoration templates, 

* Update existing state restoration samples to use the new templates

* Add to README, decided to require stateful widgets to include RestorationMixin
2021-03-23 09:24:34 +08:00
Greg Spencer a8d820a46e
Update samples to use repo analysis options, Fix sample templates and a ton of analyzer issues (#77868) 2021-03-11 16:45:03 -08:00
Shi-Hao Hong 01d2325be1
Complete migration to null safety in api documentation (#72939)
* Remove all usage of no_null_safety in API docs workflows
2021-01-06 08:27:34 +08:00
Michael Goderbauer ff05ca2503
Prepare to migrate API doc samples and snippets to null safety (#72040) 2020-12-11 13:39:36 -08:00
Jonah Williams b44696626c
[null-safety] add language version to freeform template (#69043) 2020-10-26 13:22:36 -07:00
Jonah Williams 16029c3868
[null-safety] try updating snippets for null safety (#68723)
Add a language version so the snippets do not opt-in automatically.

Fixes #68719
2020-10-22 13:18:06 -07:00
Ian Hickson 39be8a40b5
More restoration documentation (#63438) 2020-08-21 10:51:05 -07:00
Yazeed Al-Khalaf d41b1fbb50
✒ Spell Check All .md Files Related to Flutter 💙 (#61564)
* 🐛 Fix Spelling Issues in Main README.md

* 🐛 Fix spelling issues in dev README.md

* 🐛 Fix spelling issues in complex_layout README.md

* 🐛 Fix spelling issues in macrobenchmarks README.md

* 🐛 Fix spelling issues in platform_views_layout README.md

* 🐛 Fix spelling issues in test_Apps/stocks README.md

* 🐛 Fix spelling issues in bots README.md

* ✒ Spell Check dev/ci README.md

* ✒ Spell Check dev/ci/docker_linux README.md

* ✒ Spell Check dev/devicelab README.md

* ✒ Spell Check dev/docs README.md

* ✒ Spell Check dev/snippets README.md

* ✒ Spell Check dev/snippets/config/templates README.md

* ✒ Spell Check dev/tools/gen_keycodes README.md

* ✒ Spell Check dev/tools/vitool README.md

* ✒ Spell Check examples/catalog README.md

* ✒ Spell Check examples/flutter_view README.md

* ✒ Spell Check examples/image_list README.md

* ✒ Spell Check examples/layers README.md

* ✒ Spell Check examples/platform_channel README.md

* ✒ Spell Check examples/platform_channel_swift README.md

* ✒ Spell Check examples/platform_view README.md

* ✒ Spell Check packages/_flutter_web_build_script README.md

* ✒ Spell Check packages/flutter_localizations README.md

* ✒ Spell Check packages/flutter_tools README.md

* ✒ Spell Check CODE_OF_CONDUCT.md

* ✒ Spell Check dev/integration_test/android_splash_screens/splash_Screen_load_rotate README.md

* ✒ Spell Check dev/integration_test/android_views README.md

* ✒ Spell Check dev/integration_tests/flutter_driver_screenshot_test README.md

* ✒ Spell Check dev/integration_tests/flutter_gallery README.md

* ✒ Spell Check dev/integration_tests/gradle_deprecated_settings README.md

* ✒ Spell Check dev/integration_tests/ios_add2app_life_cycle README.md

* ✒ Spell Check dev/integration_tests/ios_host_app README.md

* ✒ Spell Check dev/integration_tests/ios_platform_view_tests README.md

* ✒ Spell Check dev/automated_tests/flutter_test README.md

* ✒ Spell Check .github/PULL_REQUEST_TEMPLATE.md

* ✒ Spell Check .hithub/ISSUE_TEMPLATE/ACTIVATION.md

* ✒ Spell Check .github/ISSUE_TEMPLATE/BUG.md

* ✒ Spell Check .github/ISSUE_TEMPLATE/feature_request.md

* ✒ Spell Check .github/ISSUE_TEMPLATE/performance_others.md

* ✒ Spell Check .github/ISSUE_TEMPLATE/performance_speed.md

* ✒ Spell Check packages/flutter_tools/doc/daemon.md

* ✒ Spell Check packages/flutter_tools/fuchsia_enrtypoint_shim/README.md

* ✒ Minimize line to 80 columns

* ✒ Minimize line to 80 columns

* ✒ Fix Typo

* ✒ Chnaged numbers to 1 for testing purposes

* ✒ Changed numbers to 1 for testing purposes

*  Remove 'a' which is a typo

* ✒ Change a sentence to be better

* ✒ Remove 'a' which is a typo

* ✒ Fix small issue

* ✒ Fix small typo

* ✒ Fix some typos

*  Remove trailing space

*  Remove trailing space

* 🐛 Fix small typo

* ✒ Fix Typo

* 🐛 Fix small bug
2020-07-22 18:23:47 -07:00
Kate Lovett f89814b02c
Adding CupertinoApp Sample templates (#60929) 2020-07-08 18:26:04 -07:00
Greg Spencer d19c44344b
Add sample for InheritedNotifier, convert two others to DartPa… (#52349)
This adds a sample for InheritedNotifier, and converts a couple of other samples to be DartPad samples. I also added a new sample template stateful_widget_material_ticker, which adds a TickerProviderStateMixin to the state object so that animation controllers can be created there easily.
2020-03-10 15:23:45 -07:00
Greg Spencer 9fb781a54a
Update samples to work with Dartpad, and convert all that make… (#50377)
This PR modifies the existing API docs samples to use DartPad so that all of the samples are now interactive apps on the API docs site.

It also removes the restriction for the max width of the description area so that the dartpad region can expand horizontally.

I updated the first paragraph on the API docs to indicate that Flutter is more than just mobile now (same text as the README.md at the top level).

I modified a few of the examples so that they looked nicer, and fit better on the page.

I added the sample description text above each DartPad instance, since that often defines the context of the example.

I removed animations and images when they were redundant with the sample content. There were a few that made sense to keep, so I did.
2020-02-10 10:00:20 -08:00
Greg Spencer f118b638ed
Add channel-specific dartpad URL to snippet generation (#49845)
Adds the channel to docs generation for dartpad samples, since the new query parameter was added in dart-lang/dart-pad#1462
2020-02-07 08:45:57 -08:00
Greg Spencer fabf4e3d0d Reverse the sense of the terms snippet and sample. (#48254) 2020-01-08 15:28:02 -08:00
Ian Hickson 449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00
Greg Spencer dcc4b82540
Fix snippets to include element ID in the output sample. (#44787)
This fixes the snippet code output so that it includes the name of the element that it is a snippet for in the first line.
2019-11-15 10:23:04 -08:00
Michael Goderbauer 81e693a7fe
Add Sample code to SlideTransition (#41009) 2019-09-24 12:38:45 -07:00
MH Johnson 86d200a943
add missing comma (#40555) 2019-09-16 11:47:40 -04:00
MH Johnson 0d3bb515f3
[Docs] Create 'center' snippets template (#40367)
* Create 'center' template
2019-09-15 20:38:44 -04:00
Andrew Brogdon 691977755c
Adds DartPad option to the DartDoc snippet generator. (#39924) 2019-09-10 08:36:14 -07:00
Greg Spencer 67ee3e191e
Add anchors to samples (#35906)
This adds an "anchor button" to each of the samples so that the user can link to individual samples instead of having to link to just the page. Clicking on the anchor button jumps to the anchor, as well as copying the anchor URL to the clipboard.

There is some oddness in the implementation: because dartdoc uses a <base> tag, the href for the link can't just be "#id", it has to calculate the URL from the current window href. I do that in the onmouseenter and onclick because onload doesn't get triggered for <a> tags (and onmouseenter doesn't get triggered for mobile platforms), but I still want the href to be updated before someone right-clicks it to copy the URL.
2019-07-10 16:48:20 -07:00
Michael Goderbauer 4e973adc79
Various doc fixes (#35548) 2019-07-08 17:02:25 -07:00
Shi-Hao Hong 3ab249cd41
Dartdoc Generation README Improvements (#34073)
* Add dartdoc generation README helper images

* Add test doc generation workflow section

* Add info about interpolating into templates
2019-06-10 13:22:47 -07:00
Todd Volkert 6884146925
Add loading support to Image (#33369)
This adds two new builders to the `Image` class:

* `frameBuilder`, which allows callers to control the widget
  created by an [Image].
* `loadingBuilder`, which allows callers fine-grained control
  over how to display loading progress of an image to the user.

`FadeInImage` can be simplified by migrating to the new API.
This is done in a follow-on commit.

https://github.com/flutter/flutter/issues/32374
2019-05-29 12:52:05 -07:00
Chris Bracken 4d9923201b
Correct typos (#33322)
Corects a bnuch of typeos throuhgout teh Fluter codebsae.

Made use of the `misspell` tool:
https://github.com/client9/misspell
2019-05-24 19:12:45 -07:00
Todd Volkert daa7060882
Add stateful_widget_animation snippet template (#33295) 2019-05-24 09:24:16 -07:00
Greg Spencer 7775c23784
[Re-Land] Implement focus traversal for desktop platforms. (#31614)
This re-lands the Focus changes in #30040. Correctness changes in routes.dart, and removes the automatic requesting of focus on reparent when there is no current focus, which caused undesirable selections.

Addresses #11344, #1608, #13264, and #1678
Fixes #30084
Fixes #26704
2019-04-25 16:26:58 -07:00
Greg Spencer 590cc27b31
Revert "Implement focus traversal for desktop platforms, shoehorn edition. (#30040)" (#31461)
This reverts commit 4218c0bc38.
2019-04-22 18:02:35 -07:00
Greg Spencer 4218c0bc38
Implement focus traversal for desktop platforms, shoehorn edition. (#30040)
Implements focus traversal for desktop platforms, including re-implementing the existing focus manager and focus tree.

This implements a Focus widget that can be put into a widget tree to allow input focus to be given to a particular part of a widget tree.

It incorporates with the existing FocusScope and FocusNode infrastructure, and has minimal breakage to the API, although FocusScope.reparentIfNeeded is removed, replaced by a call to FocusAttachment.reparent(), so this is a breaking change:

FocusScopeNodes must now be attached to the focus tree using FocusScopeNode.attach, which takes a context and an optional onKey callback, and returns a FocusAttachment that should be kept by the widget that hosts the FocusScopeNode. This is necessary because of the need to make sure that the focus tree reflects the widget hierarchy.

Callers that used to call FocusScope(context).reparentIfNeeded in their build method will call reparent  on a FocusAttachment instead, which they will obtain by calling FocusScopeNode.attach in their initState method. Widgets that own FocusNodes will need to call dispose on the focus node in their dispose method.

Addresses #11344, #1608, #13264, and #1678
Fixes #30084
Fixes #26704
2019-04-22 09:51:40 -07:00
Greg Spencer 262f12b4a9
Remove remaining "## Sample code" segments, and fix the snippet generator. (#27793)
This converts all remaining "## Sample code" segments into snippets, and fixes
the snippet generator to handle multiple snippets in the same dartdoc block
properly.

I also generated, compiled, and ran each of the existing application samples,
and fixed them up to be more useful and/or just run without errors.

This PR fixes these problems with examples:

1. Switching tabs in a snippet now works if there is more than one snippet in
   a single dartdoc block.
2. Generation of snippet code now works if there is more than one snippet.
3. Contrast of text and links in the code sample block has been improved to
   recommended levels.
4. Added five new snippet templates, including a "freeform" template to make
   it possible to show examples that need to change the app instantiation.
5. Fixed several examples to run properly, a couple by adding the "Scaffold"
   widget to the template, a couple by just fixing their code.
6. Fixed visual look of some of the samples when they run by placing many
   samples inside of a Scaffold.
7. In order to make it easier to run locally, changed the sample analyzer to
   remove the contents of the supplied temp directory before running, since
   having files that hang around is problematic (only a problem when running
   locally with the `--temp` argument).
8. Added a `SampleCheckerException` class, and handle sample checking
   exceptions more gracefully.
9. Deprecated the old "## Sample code" designation, and added enforcement for
   the deprecation.
10. Removed unnecessary `new` from templates (although they never appeared in
   the samples thanks to dartfmt, but still).

Fixes #26398
Fixes #27411
2019-02-15 07:48:49 -08:00
Greg Spencer 95b0124785
Add imports section to sample code templates, and more docs. (#25184)
Adds documentation for the stateless widget template, and adds an "imports" section to both templates.
2018-12-13 14:11:11 -08:00
Greg Spencer a6e901130e
Convert existing '## Sample code' samples to '{@tool sample}...{@end-tool}' form. (#24077)
This converts existing ## Sample code samples to {@tool sample}...{@end-tool} form.

Also:
1. Fixed a minor bug in analyze-sample-code.dart
2. Made the snippet tool only insert descriptions if the description is non-empty.
3. Moved the Card diagram to before the code sample.
2018-11-07 20:35:10 -08:00
Greg Spencer 094f93dfcf
Fixes several bugs in samples, quotes HTML properly, and pre-compiles snippet tool. (#24020)
When converting all of the samples to use the snippet tool, I encountered some bugs/shortcomings:

1. The document production took 90 minutes, since the snippet tool was being invoked from the command line each time. I fixed this by snapshotting the executable before running, so it's down to 7 minutes.

2. The sample code was not being properly escaped by the snippet tool, so generics were causing issues in the HTML output. It is now quoted.

3. Code examples that used languages other than Dart were not supported. Anything that highlight.js was compiled for dartdoc with is now supported.

4. The comment color for highlight.js was light grey on white, which was pretty unreadable. It's now dark green and bold.
2018-11-07 08:29:14 -08:00
Greg Spencer 202b045b50
Rewrite the analyze-sample-code script to also analyze snippets (#23893)
This rewrites the sample code analysis script to be a little less of a hack (but still not pretty), and to handle snippets as well.

It also changes the semantics of how sample code is handled: the namespace for the sample code is now limited to the file that it appears in, so some additional "Examples can assume:" blocks were added. The upside of this is that there will be far fewer name collisions.

I fixed the output too: no longer will you get 4000 lines of numbered output with the error at the top and have to grep for the actual problem. It gives the filename and line number of the original location of the code (in the comment in the tree), and prints out the source code on the line that caused the problem along with the error.

For snippets, it prints out the location of the start of the snippet and the source code line that causes the problem. It can't print out the original line, because snippets get formatted when they are written, so the line might not be in the same place.
2018-11-05 07:31:35 -08:00
Greg Spencer f9c6f30576
Allow users to create samples using flutter create. (#23584)
This adds flutter create --sample which allows users to execute a command which will create a working sample app from samples embedded in the API docs.

The command looks something like this:

flutter create --sample=chip.DeletableChipAttributes.onDeleted mysample
2018-10-30 16:01:14 -07:00
Greg Spencer 65d3ddd5d1
Dartdoc snippet extension to inject full featured code snippets in to API docs. (#23281)
This creates a custom dartdoc tool that will generate snippet blocks in our API docs that allow the user to copy easily to the clipboard, and will also embed the snippet code into a template to show it in a larger context with an app.

This PR adds the snippet tool, a template, and a couple of HTML skeleton files, one for snippets that are designed to be in an application setting, and one where it simply puts a nice container around existing snippets, making them easier to copy to the clipboard.
2018-10-23 13:50:24 -07:00