Open srawlins opened 1 year ago
I like the idea of generalizing it to @section
or similar. Could then be used to also highlight other things in docs. Would there be a good way to guard against typos in the CSS class name given? If we define CSS for @section snippet
, ideally it should give an indication that @section sippppet
is nothing valid.
Would there be a good way to guard against typos in the CSS class name given?
I can think of a few options:
@tool snipppet
has no protection today, right? So there's that.note
, info
, warning
, hint
; I dunno. So then snippet
could be a built-in style.dartdoc_options.yaml
. I think this is how we guard @category
against typos.The list of these can be required to be found in
dartdoc_options.yaml
. I think this is how we guard@category
against typos.
This would be my preferred option.
Hopefully this will come in my lifetime. Good luck!
On that note, I've managed to run the snippet tool as such:
export FLUTTER_LIBRARY="some_library"
dart run ./packages/snippets/bin.dart --output-directory=./docs/snippets_out/ --type=snippet --input=some_dart_file.dart
This indeed generates the snippet HTML
code and the related .json
file, however, I'm not sure where to go further in terms of embedding this into the finished HTML pages.
I'm having 2 issues:
dart doc .
, having added the snippets
tool to the dartdoc_options.yaml
file, no snippets are generated. It seems that this tool is not invoked at all.dart run dartdoc --apply-tools ...
, the Flutter SDK snippets start being generated in the snippets
folder which is not even specified in the dartdoc_options.yaml
file.All in all, I haven't had much luck with it :)
I believe the full feature set of Flutter's
@tool snippet
is as follows: Given text like this:The tool outputs:
All of this sounds perfectly reasonable to bring in-house. We could even stick to the current format of:
I'm thinking the following features:
@snippet
Though this seems to be even more general purpose than snippets. If we're just talking about a way to:
then we could just call this
{@section
or something. This might map nicely to an HTML5 tag. This directive would get you the self-link, the custom name for the anchor, maybe the CSS class for styling (so you could do{@section warning}
which is highlighted red, and{@section note}
which is highlighted blue or whatever.Then we can add the simple feature where all code blocks have a copy-to-clipboard button. We can maybe recognize
no-copy
in the info string (```dart no-copy
) to omit the copy-to-clipboard button.WDYT @goderbauer @gspencergoog