Unverified Commit 14f9ed28 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Analyze doc code snippets for all packages for which we publish docs (#132607)

Fixes TODO in the analyzer script :)
parent e52e8da3
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
// contains no explicit imports, the snippets will implicitly import all the // contains no explicit imports, the snippets will implicitly import all the
// main Flutter packages (including material and flutter_test), as well as most // main Flutter packages (including material and flutter_test), as well as most
// core Dart packages with the usual prefixes. // 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:async';
import 'dart:convert'; import 'dart:convert';
...@@ -73,9 +78,6 @@ import 'package:watcher/watcher.dart'; ...@@ -73,9 +78,6 @@ import 'package:watcher/watcher.dart';
final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script)))); final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
final String _packageFlutter = path.join(_flutterRoot, 'packages', 'flutter', 'lib'); 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 _defaultDartUiLocation = path.join(_flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui');
final String _flutter = path.join(_flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter'); final String _flutter = path.join(_flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
...@@ -147,18 +149,28 @@ Future<void> main(List<String> arguments) async { ...@@ -147,18 +149,28 @@ Future<void> main(List<String> arguments) async {
exit(0); exit(0);
} }
List<Directory> flutterPackages; final List<Directory> flutterPackages;
if (parsedArguments.rest.length == 1) { if (parsedArguments.rest.length == 1) {
// Used for testing. // Used for testing.
flutterPackages = <Directory>[Directory(parsedArguments.rest.single)]; flutterPackages = <Directory>[Directory(parsedArguments.rest.single)];
} else { } else {
flutterPackages = <Directory>[ // By default analyze snippets in all packages in the packages subdirectory
Directory(_packageFlutter), // that do not specify "nodoc: true" in their pubspec.yaml.
Directory(_packageFlutterTest), flutterPackages = <Directory>[];
Directory(_packageIntegrationTest), final String packagesRoot = path.join(_flutterRoot, 'packages');
Directory(_packageFlutterDriver), for (final FileSystemEntity entity in Directory(packagesRoot).listSync()) {
// TODO(goderbauer): Add all other packages for which we publish docs. 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; final bool includeDartUi = parsedArguments.wasParsed('dart-ui-location') || parsedArguments['include-dart-ui'] as bool;
......
...@@ -29,8 +29,12 @@ dev_dependencies: ...@@ -29,8 +29,12 @@ dev_dependencies:
sdk: flutter sdk: flutter
flutter_goldens: flutter_goldens:
sdk: flutter sdk: flutter
flutter_localizations:
sdk: flutter
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_web_plugins:
sdk: flutter
test: 1.24.6 test: 1.24.6
_fe_analyzer_shared: 64.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" _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'; ...@@ -10,6 +10,10 @@ import 'l10n/generated_cupertino_localizations.dart';
import 'utils/date_localizations.dart' as util; import 'utils/date_localizations.dart' as util;
import 'widgets_localizations.dart'; 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` /// Implementation of localized strings for Cupertino widgets using the `intl`
/// package for date and time formatting. /// package for date and time formatting.
/// ///
...@@ -32,11 +36,11 @@ import 'widgets_localizations.dart'; ...@@ -32,11 +36,11 @@ import 'widgets_localizations.dart';
/// app supports with [CupertinoApp.supportedLocales]: /// app supports with [CupertinoApp.supportedLocales]:
/// ///
/// ```dart /// ```dart
/// CupertinoApp( /// const CupertinoApp(
/// localizationsDelegates: GlobalCupertinoLocalizations.delegates, /// localizationsDelegates: GlobalCupertinoLocalizations.delegates,
/// supportedLocales: [ /// supportedLocales: <Locale>[
/// const Locale('en', 'US'), // American English /// Locale('en', 'US'), // American English
/// const Locale('he', 'IL'), // Israeli Hebrew /// Locale('he', 'IL'), // Israeli Hebrew
/// // ... /// // ...
/// ], /// ],
/// // ... /// // ...
...@@ -432,11 +436,11 @@ abstract class GlobalCupertinoLocalizations implements CupertinoLocalizations { ...@@ -432,11 +436,11 @@ abstract class GlobalCupertinoLocalizations implements CupertinoLocalizations {
/// app supports with [CupertinoApp.supportedLocales]: /// app supports with [CupertinoApp.supportedLocales]:
/// ///
/// ```dart /// ```dart
/// CupertinoApp( /// const CupertinoApp(
/// localizationsDelegates: GlobalCupertinoLocalizations.delegates, /// localizationsDelegates: GlobalCupertinoLocalizations.delegates,
/// supportedLocales: [ /// supportedLocales: <Locale>[
/// const Locale('en', 'US'), // English /// Locale('en', 'US'), // English
/// const Locale('he', 'IL'), // Hebrew /// Locale('he', 'IL'), // Hebrew
/// ], /// ],
/// // ... /// // ...
/// ) /// )
......
...@@ -11,6 +11,10 @@ import 'l10n/generated_material_localizations.dart'; ...@@ -11,6 +11,10 @@ import 'l10n/generated_material_localizations.dart';
import 'utils/date_localizations.dart' as util; import 'utils/date_localizations.dart' as util;
import 'widgets_localizations.dart'; 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 /// Implementation of localized strings for the material widgets using the
/// `intl` package for date and time formatting. /// `intl` package for date and time formatting.
/// ///
...@@ -30,11 +34,11 @@ import 'widgets_localizations.dart'; ...@@ -30,11 +34,11 @@ import 'widgets_localizations.dart';
/// app supports with [MaterialApp.supportedLocales]: /// app supports with [MaterialApp.supportedLocales]:
/// ///
/// ```dart /// ```dart
/// MaterialApp( /// const MaterialApp(
/// localizationsDelegates: GlobalMaterialLocalizations.delegates, /// localizationsDelegates: GlobalMaterialLocalizations.delegates,
/// supportedLocales: [ /// supportedLocales: <Locale>[
/// const Locale('en', 'US'), // American English /// Locale('en', 'US'), // American English
/// const Locale('he', 'IL'), // Israeli Hebrew /// Locale('he', 'IL'), // Israeli Hebrew
/// // ... /// // ...
/// ], /// ],
/// // ... /// // ...
...@@ -681,11 +685,11 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations { ...@@ -681,11 +685,11 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations {
/// app supports with [MaterialApp.supportedLocales]: /// app supports with [MaterialApp.supportedLocales]:
/// ///
/// ```dart /// ```dart
/// MaterialApp( /// const MaterialApp(
/// localizationsDelegates: GlobalMaterialLocalizations.delegates, /// localizationsDelegates: GlobalMaterialLocalizations.delegates,
/// supportedLocales: [ /// supportedLocales: <Locale>[
/// const Locale('en', 'US'), // English /// Locale('en', 'US'), // English
/// const Locale('he', 'IL'), // Hebrew /// Locale('he', 'IL'), // Hebrew
/// ], /// ],
/// // ... /// // ...
/// ) /// )
......
...@@ -34,8 +34,10 @@ void usePathUrlStrategy() { ...@@ -34,8 +34,10 @@ void usePathUrlStrategy() {
/// ```dart /// ```dart
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
/// ///
/// void main() {
/// // Somewhere before calling `runApp()` do: /// // Somewhere before calling `runApp()` do:
/// setUrlStrategy(PathUrlStrategy()); /// setUrlStrategy(PathUrlStrategy());
/// }
/// ``` /// ```
class PathUrlStrategy extends ui_web.HashUrlStrategy { class PathUrlStrategy extends ui_web.HashUrlStrategy {
/// Creates an instance of [PathUrlStrategy]. /// Creates an instance of [PathUrlStrategy].
......
...@@ -99,8 +99,10 @@ void usePathUrlStrategy() { ...@@ -99,8 +99,10 @@ void usePathUrlStrategy() {
/// ```dart /// ```dart
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
/// ///
/// void main() {
/// // Somewhere before calling `runApp()` do: /// // Somewhere before calling `runApp()` do:
/// setUrlStrategy(const HashUrlStrategy()); /// setUrlStrategy(const HashUrlStrategy());
/// }
/// ``` /// ```
class HashUrlStrategy extends UrlStrategy { class HashUrlStrategy extends UrlStrategy {
/// Creates an instance of [HashUrlStrategy]. /// Creates an instance of [HashUrlStrategy].
...@@ -117,8 +119,10 @@ class HashUrlStrategy extends UrlStrategy { ...@@ -117,8 +119,10 @@ class HashUrlStrategy extends UrlStrategy {
/// ```dart /// ```dart
/// import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
/// ///
/// void main() {
/// // Somewhere before calling `runApp()` do: /// // Somewhere before calling `runApp()` do:
/// setUrlStrategy(PathUrlStrategy()); /// setUrlStrategy(PathUrlStrategy());
/// }
/// ``` /// ```
class PathUrlStrategy extends HashUrlStrategy { class PathUrlStrategy extends HashUrlStrategy {
/// Creates an instance of [PathUrlStrategy]. /// Creates an instance of [PathUrlStrategy].
......
...@@ -9,6 +9,12 @@ import 'dart:ui_web' as ui_web; ...@@ -9,6 +9,12 @@ import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.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. /// A registrar for Flutter plugins implemented in Dart.
/// ///
/// Plugins for the web platform are implemented in Dart and are /// Plugins for the web platform are implemented in Dart and are
...@@ -32,6 +38,11 @@ import 'package:flutter/services.dart'; ...@@ -32,6 +38,11 @@ import 'package:flutter/services.dart';
/// final MyPlugin instance = MyPlugin(); /// final MyPlugin instance = MyPlugin();
/// channel.setMethodCallHandler(instance.handleMethodCall); /// channel.setMethodCallHandler(instance.handleMethodCall);
/// } /// }
///
/// Future<dynamic> handleMethodCall(MethodCall call) async {
/// // ...
/// }
///
/// // ... /// // ...
/// } /// }
/// ``` /// ```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment