Move snippets package back into flutter repo (#147690)

## Description

This moves the snippets package back into the Flutter repo so that API documentation generation can happen without the use of `dart pub global run` because `pub run` doesn't handle concurrency well.

The change modifies the dartdoc building process to include building an executable from the snippets tool and installing that in the cache directory for use during docs generation.

The snippets tool will reside in dev/snippets, where it originally resided before being moved to https://github.com/flutter/assets-for-api-docs.

The snippets code itself is unchanged from the code that is in https://github.com/flutter/assets-for-api-docs/packages/snippets.

## Related Issues
 - https://github.com/flutter/flutter/issues/144408
 - https://github.com/flutter/flutter/issues/147609
 - https://github.com/flutter/flutter/pull/147645

## Tests
 - Added snippets tests to the overall testing build.
This commit is contained in:
Greg Spencer
2024-05-02 23:09:03 -07:00
committed by GitHub
parent 4006d1bd7b
commit 183bc15816
22 changed files with 4757 additions and 11 deletions

View File

@@ -107,16 +107,25 @@ function parse_args() {
fi
}
function build_snippets_tool() (
local snippets_dir="$FLUTTER_ROOT/dev/snippets"
local output_dir="$FLUTTER_BIN/cache/artifacts/snippets"
echo "Building snippets tool executable."
command cd "$snippets_dir"
mkdir -p "$output_dir"
dart pub get
dart compile exe -o "$output_dir/snippets" bin/snippets.dart
)
function generate_docs() {
# Install and activate dartdoc.
# When updating to a new dartdoc version, please also update
# `dartdoc_options.yaml` to include newly introduced error and warning types.
"$DART" pub global activate dartdoc 8.0.6
# Install and activate the snippets tool, which resides in the
# assets-for-api-docs repo:
# https://github.com/flutter/assets-for-api-docs/tree/main/packages/snippets
"$DART" pub global activate snippets 0.4.3
# Build and install the snippets tool, which resides in
# the dev/docs/snippets directory.
build_snippets_tool
# This script generates a unified doc set, and creates
# a custom index.html, placing everything into DOC_DIR.