Commit graph

16 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
Greg Spencer c7643cf54e
Fix samples so that they present properly in the docs (#97224) 2022-02-24 18:51:22 -08: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 ff05ca2503
Prepare to migrate API doc samples and snippets to null safety (#72040) 2020-12-11 13:39:36 -08: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
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
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 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 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