mirror of
https://github.com/flutter/flutter
synced 2024-09-12 21:01:59 +00:00
Analyze doc code snippets for all packages for which we publish docs (#132607)
Fixes TODO in the analyzer script :)
This commit is contained in:
parent
e52e8da303
commit
14f9ed28d0
|
@ -61,6 +61,11 @@
|
|||
// contains no explicit imports, the snippets will implicitly import all the
|
||||
// main Flutter packages (including material and flutter_test), as well as most
|
||||
// core Dart packages with the usual prefixes.
|
||||
//
|
||||
// When invoked without an additional path argument, the script will analyze
|
||||
// the code snippets for all packages in the "packages" subdirectory that do
|
||||
// not specify "nodoc: true" in their pubspec.yaml (i.e. all packages for which
|
||||
// we publish docs will have their doc code snippets analyzed).
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
@ -73,9 +78,6 @@ import 'package:watcher/watcher.dart';
|
|||
|
||||
final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
|
||||
final String _packageFlutter = path.join(_flutterRoot, 'packages', 'flutter', 'lib');
|
||||
final String _packageFlutterTest = path.join(_flutterRoot, 'packages', 'flutter_test', 'lib');
|
||||
final String _packageFlutterDriver = path.join(_flutterRoot, 'packages', 'flutter_driver', 'lib');
|
||||
final String _packageIntegrationTest = path.join(_flutterRoot, 'packages', 'integration_test', 'lib');
|
||||
final String _defaultDartUiLocation = path.join(_flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui');
|
||||
final String _flutter = path.join(_flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
|
||||
|
||||
|
@ -147,18 +149,28 @@ Future<void> main(List<String> arguments) async {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
List<Directory> flutterPackages;
|
||||
final List<Directory> flutterPackages;
|
||||
if (parsedArguments.rest.length == 1) {
|
||||
// Used for testing.
|
||||
flutterPackages = <Directory>[Directory(parsedArguments.rest.single)];
|
||||
} else {
|
||||
flutterPackages = <Directory>[
|
||||
Directory(_packageFlutter),
|
||||
Directory(_packageFlutterTest),
|
||||
Directory(_packageIntegrationTest),
|
||||
Directory(_packageFlutterDriver),
|
||||
// TODO(goderbauer): Add all other packages for which we publish docs.
|
||||
];
|
||||
// By default analyze snippets in all packages in the packages subdirectory
|
||||
// that do not specify "nodoc: true" in their pubspec.yaml.
|
||||
flutterPackages = <Directory>[];
|
||||
final String packagesRoot = path.join(_flutterRoot, 'packages');
|
||||
for (final FileSystemEntity entity in Directory(packagesRoot).listSync()) {
|
||||
if (entity is! Directory) {
|
||||
continue;
|
||||
}
|
||||
final File pubspec = File(path.join(entity.path, 'pubspec.yaml'));
|
||||
if (!pubspec.existsSync()) {
|
||||
throw StateError("Unexpected package '${entity.path}' found in packages directory");
|
||||
}
|
||||
if (!pubspec.readAsStringSync().contains('nodoc: true')) {
|
||||
flutterPackages.add(Directory(path.join(entity.path, 'lib')));
|
||||
}
|
||||
}
|
||||
assert(flutterPackages.length >= 4);
|
||||
}
|
||||
|
||||
final bool includeDartUi = parsedArguments.wasParsed('dart-ui-location') || parsedArguments['include-dart-ui'] as bool;
|
||||
|
|
|
@ -29,8 +29,12 @@ dev_dependencies:
|
|||
sdk: flutter
|
||||
flutter_goldens:
|
||||
sdk: flutter
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_web_plugins:
|
||||
sdk: flutter
|
||||
test: 1.24.6
|
||||
|
||||
_fe_analyzer_shared: 64.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
|
|
@ -10,6 +10,10 @@ import 'l10n/generated_cupertino_localizations.dart';
|
|||
import 'utils/date_localizations.dart' as util;
|
||||
import 'widgets_localizations.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
|
||||
/// Implementation of localized strings for Cupertino widgets using the `intl`
|
||||
/// package for date and time formatting.
|
||||
///
|
||||
|
@ -32,11 +36,11 @@ import 'widgets_localizations.dart';
|
|||
/// app supports with [CupertinoApp.supportedLocales]:
|
||||
///
|
||||
/// ```dart
|
||||
/// CupertinoApp(
|
||||
/// const CupertinoApp(
|
||||
/// localizationsDelegates: GlobalCupertinoLocalizations.delegates,
|
||||
/// supportedLocales: [
|
||||
/// const Locale('en', 'US'), // American English
|
||||
/// const Locale('he', 'IL'), // Israeli Hebrew
|
||||
/// supportedLocales: <Locale>[
|
||||
/// Locale('en', 'US'), // American English
|
||||
/// Locale('he', 'IL'), // Israeli Hebrew
|
||||
/// // ...
|
||||
/// ],
|
||||
/// // ...
|
||||
|
@ -432,11 +436,11 @@ abstract class GlobalCupertinoLocalizations implements CupertinoLocalizations {
|
|||
/// app supports with [CupertinoApp.supportedLocales]:
|
||||
///
|
||||
/// ```dart
|
||||
/// CupertinoApp(
|
||||
/// const CupertinoApp(
|
||||
/// localizationsDelegates: GlobalCupertinoLocalizations.delegates,
|
||||
/// supportedLocales: [
|
||||
/// const Locale('en', 'US'), // English
|
||||
/// const Locale('he', 'IL'), // Hebrew
|
||||
/// supportedLocales: <Locale>[
|
||||
/// Locale('en', 'US'), // English
|
||||
/// Locale('he', 'IL'), // Hebrew
|
||||
/// ],
|
||||
/// // ...
|
||||
/// )
|
||||
|
|
|
@ -11,6 +11,10 @@ import 'l10n/generated_material_localizations.dart';
|
|||
import 'utils/date_localizations.dart' as util;
|
||||
import 'widgets_localizations.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
|
||||
/// Implementation of localized strings for the material widgets using the
|
||||
/// `intl` package for date and time formatting.
|
||||
///
|
||||
|
@ -30,11 +34,11 @@ import 'widgets_localizations.dart';
|
|||
/// app supports with [MaterialApp.supportedLocales]:
|
||||
///
|
||||
/// ```dart
|
||||
/// MaterialApp(
|
||||
/// const MaterialApp(
|
||||
/// localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
/// supportedLocales: [
|
||||
/// const Locale('en', 'US'), // American English
|
||||
/// const Locale('he', 'IL'), // Israeli Hebrew
|
||||
/// supportedLocales: <Locale>[
|
||||
/// Locale('en', 'US'), // American English
|
||||
/// Locale('he', 'IL'), // Israeli Hebrew
|
||||
/// // ...
|
||||
/// ],
|
||||
/// // ...
|
||||
|
@ -681,11 +685,11 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations {
|
|||
/// app supports with [MaterialApp.supportedLocales]:
|
||||
///
|
||||
/// ```dart
|
||||
/// MaterialApp(
|
||||
/// const MaterialApp(
|
||||
/// localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
/// supportedLocales: [
|
||||
/// const Locale('en', 'US'), // English
|
||||
/// const Locale('he', 'IL'), // Hebrew
|
||||
/// supportedLocales: <Locale>[
|
||||
/// Locale('en', 'US'), // English
|
||||
/// Locale('he', 'IL'), // Hebrew
|
||||
/// ],
|
||||
/// // ...
|
||||
/// )
|
||||
|
|
|
@ -34,8 +34,10 @@ void usePathUrlStrategy() {
|
|||
/// ```dart
|
||||
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
///
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(PathUrlStrategy());
|
||||
/// void main() {
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(PathUrlStrategy());
|
||||
/// }
|
||||
/// ```
|
||||
class PathUrlStrategy extends ui_web.HashUrlStrategy {
|
||||
/// Creates an instance of [PathUrlStrategy].
|
||||
|
|
|
@ -99,8 +99,10 @@ void usePathUrlStrategy() {
|
|||
/// ```dart
|
||||
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
///
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(const HashUrlStrategy());
|
||||
/// void main() {
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(const HashUrlStrategy());
|
||||
/// }
|
||||
/// ```
|
||||
class HashUrlStrategy extends UrlStrategy {
|
||||
/// Creates an instance of [HashUrlStrategy].
|
||||
|
@ -117,8 +119,10 @@ class HashUrlStrategy extends UrlStrategy {
|
|||
/// ```dart
|
||||
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
///
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(PathUrlStrategy());
|
||||
/// void main() {
|
||||
/// // Somewhere before calling `runApp()` do:
|
||||
/// setUrlStrategy(PathUrlStrategy());
|
||||
/// }
|
||||
/// ```
|
||||
class PathUrlStrategy extends HashUrlStrategy {
|
||||
/// Creates an instance of [PathUrlStrategy].
|
||||
|
|
|
@ -9,6 +9,12 @@ import 'dart:ui_web' as ui_web;
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'dart:ui_web' as ui_web;
|
||||
// void handleFrameworkMessage(String name, ByteData? data, PlatformMessageResponseCallback? callback) { }
|
||||
|
||||
/// A registrar for Flutter plugins implemented in Dart.
|
||||
///
|
||||
/// Plugins for the web platform are implemented in Dart and are
|
||||
|
@ -32,6 +38,11 @@ import 'package:flutter/services.dart';
|
|||
/// final MyPlugin instance = MyPlugin();
|
||||
/// channel.setMethodCallHandler(instance.handleMethodCall);
|
||||
/// }
|
||||
///
|
||||
/// Future<dynamic> handleMethodCall(MethodCall call) async {
|
||||
/// // ...
|
||||
/// }
|
||||
///
|
||||
/// // ...
|
||||
/// }
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue