From ec44aa6795c259ff97220a727433ecd7cb50f69a Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Wed, 13 Nov 2019 13:42:32 -0800 Subject: [PATCH 1/6] Quality of life tooling changes for dartdoc --- lib/src/dartdoc_options.dart | 14 ++++-- lib/src/element_type.dart | 3 +- lib/src/html/html_generator.dart | 3 +- lib/src/html/template_data.dart | 6 ++- lib/src/model/categorization.dart | 3 +- lib/src/model/category.dart | 1 - test/model_test.dart | 29 +++++++----- tool/grind.dart | 77 ++++++++++++++++++++++++++----- tool/travis.sh | 8 +--- 9 files changed, 102 insertions(+), 42 deletions(-) diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart index 6fd89ed012..223ed301da 100644 --- a/lib/src/dartdoc_options.dart +++ b/lib/src/dartdoc_options.dart @@ -1376,7 +1376,8 @@ class DartdocOptionContext extends DartdocOptionContextBase bool get injectHtml => optionSet['injectHtml'].valueAt(context); - bool get excludeFooterVersion => optionSet['excludeFooterVersion'].valueAt(context); + bool get excludeFooterVersion => + optionSet['excludeFooterVersion'].valueAt(context); ToolConfiguration get tools => optionSet['tools'].valueAt(context); @@ -1420,8 +1421,7 @@ class DartdocOptionContext extends DartdocOptionContextBase bool isPackageExcluded(String name) => excludePackages.any((pattern) => name == pattern); - String get templatesDir => - optionSet['templatesDir'].valueAt(context); + String get templatesDir => optionSet['templatesDir'].valueAt(context); } /// Instantiate dartdoc's configuration file and options parser with the @@ -1624,8 +1624,12 @@ Future> createDartdocOptions() async { 'exist. Executables for different platforms are specified by ' 'giving the platform name as a key, and a list of strings as the ' 'command.'), - DartdocOptionArgOnly("templatesDir", null, isDir: true, mustExist: true, hide: true, - help: 'Path to a directory containing templates to use instead of the default ones. ' + DartdocOptionArgOnly("templatesDir", null, + isDir: true, + mustExist: true, + hide: true, + help: + 'Path to a directory containing templates to use instead of the default ones. ' 'Directory must contain an html file for each of the following: 404error, category, ' 'class, constant, constructor, enum, function, index, library, method, mixin, ' 'property, top_level_constant, top_level_property, typedef. Partial templates are ' diff --git a/lib/src/element_type.dart b/lib/src/element_type.dart index f753c6d65b..5f026fa287 100644 --- a/lib/src/element_type.dart +++ b/lib/src/element_type.dart @@ -329,7 +329,8 @@ abstract class DefinedElementType extends ElementType { DartType get instantiatedType { if (_instantiatedType == null) { if (!interfaceType.typeArguments.every((t) => t is InterfaceType)) { - _instantiatedType = packageGraph.typeSystem.instantiateToBounds(interfaceType); + _instantiatedType = + packageGraph.typeSystem.instantiateToBounds(interfaceType); } else { _instantiatedType = interfaceType; } diff --git a/lib/src/html/html_generator.dart b/lib/src/html/html_generator.dart index 93fe22151b..f346499cf7 100644 --- a/lib/src/html/html_generator.dart +++ b/lib/src/html/html_generator.dart @@ -59,8 +59,7 @@ class HtmlGenerator extends Generator { String dirname = options?.templatesDir; if (dirname != null) { Directory templateDir = Directory(dirname); - templates = await Templates.fromDirectory( - templateDir, + templates = await Templates.fromDirectory(templateDir, headerPaths: headers, footerPaths: footers, footerTextPaths: footerTexts); diff --git a/lib/src/html/template_data.dart b/lib/src/html/template_data.dart index 8e1095b3f6..d03974b36f 100644 --- a/lib/src/html/template_data.dart +++ b/lib/src/html/template_data.dart @@ -295,7 +295,8 @@ class MethodTemplateData extends TemplateData { @override Method get self => method; @override - String get title => '${method.name} method - ${container.name} ${containerDesc} - ' + String get title => + '${method.name} method - ${container.name} ${containerDesc} - ' '${library.name} library - Dart API'; @override String get layoutTitle => _layoutTitle( @@ -328,7 +329,8 @@ class PropertyTemplateData extends TemplateData { Field get self => property; @override - String get title => '${property.name} $type - ${container.name} ${containerDesc} - ' + String get title => + '${property.name} $type - ${container.name} ${containerDesc} - ' '${library.name} library - Dart API'; @override String get layoutTitle => diff --git a/lib/src/model/categorization.dart b/lib/src/model/categorization.dart index 0f8d9d8343..1229ad2eec 100644 --- a/lib/src/model/categorization.dart +++ b/lib/src/model/categorization.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - import 'package:dartdoc/src/model/model.dart'; final categoryRegexp = RegExp( @@ -115,7 +114,7 @@ abstract class Categorization implements ModelElement { .map((n) => package.nameToCategory[n]) .where((c) => c != null) .toList() - ..sort(); + ..sort(); } return _categories; } diff --git a/lib/src/model/category.dart b/lib/src/model/category.dart index d080ac3fc5..9cd8ec5f17 100644 --- a/lib/src/model/category.dart +++ b/lib/src/model/category.dart @@ -10,7 +10,6 @@ import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/package_meta.dart'; import 'package:dartdoc/src/warnings.dart'; - /// A category is a subcategory of a package, containing libraries tagged /// with a @category identifier. class Category extends Nameable diff --git a/test/model_test.dart b/test/model_test.dart index a7cbc1ac36..fb39385fdb 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -710,11 +710,12 @@ void main() { EnumField enumValue2; setUpAll(() { - enumWithAnimation = exLibrary.enums.firstWhere((c) => c.name == 'EnumWithAnimation'); - enumValue1 = enumWithAnimation.constants - .firstWhere((m) => m.name == 'value1'); - enumValue2 = enumWithAnimation.constants - .firstWhere((m) => m.name == 'value2'); + enumWithAnimation = + exLibrary.enums.firstWhere((c) => c.name == 'EnumWithAnimation'); + enumValue1 = + enumWithAnimation.constants.firstWhere((m) => m.name == 'value1'); + enumValue2 = + enumWithAnimation.constants.firstWhere((m) => m.name == 'value2'); dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); withAnimation = dog.allInstanceMethods.firstWhere((m) => m.name == 'withAnimation'); @@ -775,12 +776,18 @@ void main() { contains('