diff --git a/CHANGELOG.md b/CHANGELOG.md index 19d700216e..dc05b443ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 3.1.0 +* This version supports the Dart language feature constructor tearoffs, + pending completion by other tools. +* Allow embedded type parameters in comment references. (#2772) +* Add testing for constructor tearoff constant rendering. (#2780) +* Do not crash on package not found, instead provide a more useful + explanation for users. (#2781, #2778) +* `--allow-warnings-in-packages` no longer also applies to errors. + The `--allow-errors-in-packages` flag should now work as intended. + (#2785) +* Some additional deprecations preparing for NNBD. (#2784) + ## 3.0.0 * BREAKING CHANGE: Refactor of Class, Enum, and Mixin types result in some deleted interfaces in templates and a change in class hierarchy. (#2770) diff --git a/dartdoc_options.yaml b/dartdoc_options.yaml index 5e293ce510..e9b9acf8b7 100644 --- a/dartdoc_options.yaml +++ b/dartdoc_options.yaml @@ -1,4 +1,4 @@ dartdoc: linkToSource: root: '.' - uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v3.0.0/%f%#L%l%' + uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v3.1.0/%f%#L%l%' diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart index fc45d2a56c..5080811d30 100644 --- a/lib/dartdoc.dart +++ b/lib/dartdoc.dart @@ -25,8 +25,6 @@ import 'package:dartdoc/src/logging.dart'; import 'package:dartdoc/src/matching_link_result.dart'; import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/package_meta.dart'; -import 'package:dartdoc/src/tool_definition.dart'; -import 'package:dartdoc/src/tool_runner.dart'; import 'package:dartdoc/src/tuple.dart'; import 'package:dartdoc/src/utils.dart'; import 'package:dartdoc/src/version.dart'; @@ -196,12 +194,15 @@ class Dartdoc { Stream get onCheckProgress => _onCheckProgress.stream; + @Deprecated('Will be removed in 4.0.0. ' + 'Use the return value from generateDocsBase instead.') PackageGraph packageGraph; @visibleForTesting Future generateDocsBase() async { var stopwatch = Stopwatch()..start(); - packageGraph = await packageBuilder.buildPackageGraph(); + var packageGraph = await packageBuilder.buildPackageGraph(); + this.packageGraph = packageGraph; var seconds = stopwatch.elapsedMilliseconds / 1000.0; var libs = packageGraph.libraries.length; logInfo("Initialized dartdoc with $libs librar${libs == 1 ? 'y' : 'ies'} " @@ -245,10 +246,11 @@ class Dartdoc { /// thrown if dartdoc fails in an expected way, for example if there is an /// analysis error in the code. Future generateDocs() async { + DartdocResults dartdocResults; try { logInfo('Documenting ${config.topLevelPackageMeta}...'); - var dartdocResults = await generateDocsBase(); + dartdocResults = await generateDocsBase(); if (dartdocResults.packageGraph.localPublicLibraries.isEmpty) { logWarning('dartdoc could not find any libraries to document'); } @@ -263,10 +265,7 @@ class Dartdoc { logInfo('Success! Docs generated into $outDirPath'); return dartdocResults; } finally { - // Clear out any cached tool snapshots and temporary directories. - SnapshotCache.instanceFor(config.resourceProvider).dispose(); - // ignore: unawaited_futures - ToolTempFileTracker.instance?.dispose(); + dartdocResults?.packageGraph?.dispose(); } } diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index 33ec9b0538..41cff0ff9b 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -5,7 +5,6 @@ // @dart=2.9 import 'package:analyzer/dart/element/element.dart'; -import 'package:dartdoc/src/model/inheriting_container.dart'; import 'package:dartdoc/src/model/model.dart'; import 'comment_referable.dart'; diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 7109f03c28..453606972e 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -5,7 +5,6 @@ // @dart=2.9 import 'package:dartdoc/src/model/feature.dart'; -import 'package:dartdoc/src/model/inheriting_container.dart'; import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/special_elements.dart'; diff --git a/lib/src/model/inheriting_container.dart b/lib/src/model/inheriting_container.dart index 39a202ed1a..09418f21c9 100644 --- a/lib/src/model/inheriting_container.dart +++ b/lib/src/model/inheriting_container.dart @@ -7,7 +7,6 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:dartdoc/src/element_type.dart'; -import 'package:dartdoc/src/model/class.dart'; import 'package:dartdoc/src/model/comment_referable.dart'; import 'package:dartdoc/src/model/extension_target.dart'; import 'package:dartdoc/src/model/model.dart'; diff --git a/lib/src/model/mixin.dart b/lib/src/model/mixin.dart index 347252ec08..f8dbce11aa 100644 --- a/lib/src/model/mixin.dart +++ b/lib/src/model/mixin.dart @@ -7,7 +7,6 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:dartdoc/src/element_type.dart'; -import 'package:dartdoc/src/model/inheriting_container.dart'; import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/model_utils.dart' as model_utils; import 'package:dartdoc/src/special_elements.dart'; diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index cd0c3b822c..b8cc3731ea 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -22,6 +22,8 @@ import 'package:dartdoc/src/package_meta.dart' show PackageMeta, PackageMetaProvider; import 'package:dartdoc/src/render/renderer_factory.dart'; import 'package:dartdoc/src/special_elements.dart'; +import 'package:dartdoc/src/tool_definition.dart'; +import 'package:dartdoc/src/tool_runner.dart'; import 'package:dartdoc/src/tuple.dart'; import 'package:dartdoc/src/warnings.dart'; @@ -39,6 +41,14 @@ class PackageGraph with CommentReferable, Nameable { Package.fromPackageMeta(packageMeta, this); } + void dispose() { + // Clear out any cached tool snapshots and temporary directories. + // TODO(jcollins-g): Consider ownership change for these objects + // so they are tied to PackageGraph instead of being global. + SnapshotCache.instanceFor(config.resourceProvider).dispose(); + ToolTempFileTracker.instanceFor(config.resourceProvider).dispose(); + } + @override String get name => null; diff --git a/lib/src/model/prefix.dart b/lib/src/model/prefix.dart index 0e97aeaf4a..4b677e991a 100644 --- a/lib/src/model/prefix.dart +++ b/lib/src/model/prefix.dart @@ -8,7 +8,6 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/scope.dart'; import 'package:analyzer/src/dart/element/element.dart'; import 'package:dartdoc/src/model/comment_referable.dart'; -import 'package:dartdoc/src/model/library.dart'; import '../../dartdoc.dart'; diff --git a/lib/src/model_utils.dart b/lib/src/model_utils.dart index 518bc0cbdb..2a79fec543 100644 --- a/lib/src/model_utils.dart +++ b/lib/src/model_utils.dart @@ -14,7 +14,6 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/file_system/file_system.dart'; import 'package:analyzer/src/dart/ast/utilities.dart'; import 'package:dartdoc/dartdoc.dart' show DartdocFailure; -import 'package:dartdoc/src/model/inheriting_container.dart'; import 'package:dartdoc/src/model/model.dart'; import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; diff --git a/lib/src/tool_definition.dart b/lib/src/tool_definition.dart index 9885dcd876..fe37380c34 100644 --- a/lib/src/tool_definition.dart +++ b/lib/src/tool_definition.dart @@ -240,9 +240,8 @@ class SnapshotCache { void dispose() { _instances.remove(_resourceProvider); if (snapshotCache.exists) { - return snapshotCache.delete(); + snapshotCache.delete(); } - return null; } } diff --git a/lib/src/tool_runner.dart b/lib/src/tool_runner.dart index 527a0eb5bd..47010b2813 100644 --- a/lib/src/tool_runner.dart +++ b/lib/src/tool_runner.dart @@ -27,13 +27,11 @@ class ToolTempFileTracker { : temporaryDirectory = resourceProvider.createSystemTemp('dartdoc_tools_'); - static ToolTempFileTracker _instance; + static final Map _instances = {}; - static ToolTempFileTracker get instance => _instance; - - static ToolTempFileTracker createInstance( - ResourceProvider resourceProvider) => - _instance ??= ToolTempFileTracker._(resourceProvider); + static ToolTempFileTracker instanceFor(ResourceProvider resourceProvider) => + _instances.putIfAbsent( + resourceProvider, () => ToolTempFileTracker._(resourceProvider)); int _temporaryFileCount = 0; @@ -48,9 +46,9 @@ class ToolTempFileTracker { } /// Call once no more files are to be created. - Future dispose() async { + void dispose() { if (temporaryDirectory.exists) { - return temporaryDirectory.delete(); + temporaryDirectory.delete(); } } } @@ -221,8 +219,8 @@ class ToolRunner { // file before running the tool synchronously. // Write the content to a temp file. - var tmpFile = ToolTempFileTracker.createInstance(resourceProvider) - .createTemporaryFile(); + var tmpFile = + ToolTempFileTracker.instanceFor(resourceProvider).createTemporaryFile(); tmpFile.writeAsStringSync(content); return pathContext.absolute(tmpFile.path); } diff --git a/lib/src/version.dart b/lib/src/version.dart index 0ed1620d7d..d006dce1fc 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '3.0.0'; +const packageVersion = '3.1.0'; diff --git a/pubspec.yaml b/pubspec.yaml index 4705d58104..a7b561ad98 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,42 +1,42 @@ name: dartdoc # Run `grind build` after updating. -version: 3.0.0 +version: 3.1.0 description: A non-interactive HTML documentation generator for Dart source code. homepage: https://github.com/dart-lang/dartdoc environment: sdk: '>=2.12.0 <3.0.0' dependencies: - analyzer: ^2.2.0 - args: ^2.0.0 - charcode: ^1.2.0 + analyzer: ^2.3.0 + args: ^2.3.0 + charcode: ^1.3.1 collection: ^1.15.0 - cli_util: ^0.3.0 - crypto: ^3.0.0 - glob: ^2.0.0 + cli_util: ^0.3.3 + crypto: ^3.0.1 + glob: ^2.0.1 html: ^0.15.0 - logging: ^1.0.0 + logging: ^1.0.2 markdown: ^4.0.0 meta: ^1.7.0 - package_config: ^2.0.0 - path: ^1.3.0 - pub_semver: ^2.0.0 - source_span: ^1.5.2 - yaml: ^3.0.0 + package_config: ^2.0.2 + path: ^1.8.0 + pub_semver: ^2.1.0 + source_span: ^1.8.1 + yaml: ^3.1.0 dev_dependencies: - async: ^2.0.8 - build: ^2.0.0 - build_runner: ^2.0.1 - build_test: ^2.0.0 - build_version: ^2.0.1 - code_builder: ^4.0.0 - coverage: ^1.0.2 - dart_style: ^2.0.0 - grinder: ^0.9.0-nullsafety.0 - http: ^0.13.0 - pedantic: ^1.11.0 - test: ^1.3.0 + async: ^2.8.2 + build: ^2.1.0 + build_runner: ^2.1.2 + build_test: ^2.1.3 + build_version: ^2.1.0 + code_builder: ^4.1.0 + coverage: ^1.0.3 + dart_style: ^2.1.0 + grinder: ^0.9.0 + http: ^0.13.3 + pedantic: ^1.11.1 + test: ^1.17.12 executables: dartdoc: null diff --git a/test/mustachio/runtime_renderer_render_test.dart b/test/mustachio/runtime_renderer_render_test.dart index 456423b9a3..f28124b04a 100644 --- a/test/mustachio/runtime_renderer_render_test.dart +++ b/test/mustachio/runtime_renderer_render_test.dart @@ -573,24 +573,26 @@ line 1, column 9 of ${fooTemplateFile.path}: Failed to resolve 's2' as a propert var barTemplateFile = getFile('/project/src/bar.mustache'); expect( () async => await Template.parse(barTemplateFile), - throwsA(const TypeMatcher().having( - (e) => e.message, - 'message', - contains('"${barTemplateFile.path}" does not exist.')))); + throwsA(const TypeMatcher() + .having((e) => e.message, 'message', contains('does not exist.')))); }); test('Template parser throws when it cannot read a partial', () async { var barTemplateFile = getFile('/project/src/bar.mustache') ..writeAsStringSync('Text {{#foo}}{{>missing.mustache}}{{/foo}}'); - var missingTemplateFile = getFile('/project/src/missing.mustache'); expect( () async => await Template.parse(barTemplateFile), - throwsA(const TypeMatcher() - .having((e) => e.message, 'message', contains(''' -line 1, column 14 of ${barTemplateFile.path}: FileSystemException (File "${missingTemplateFile.path}" does not exist.) when reading partial: + throwsA(const TypeMatcher().having( + (e) => e.message, + 'message', + allOf( + contains(''' +line 1, column 14 of ${barTemplateFile.path}: FileSystemException'''), + contains('''does not exist.'''), + contains('''when reading partial: ╷ 1 │ Text {{#foo}}{{>missing.mustache}}{{/foo}} │ ^^^^^^^^^^^^^^^^^^^^^ -''')))); +'''))))); }); } diff --git a/tool/travis.sh b/tool/travis.sh index f9c33eb78e..0650bc3dfb 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -29,11 +29,7 @@ elif [ "$DARTDOC_BOT" = "flutter" ]; then pub run grinder validate-flutter-docs elif [ "$DARTDOC_BOT" = "packages" ]; then echo "Running packages dartdoc bot" - if [ ${DART_VERSION} != 2.2.0 ] ; then - PACKAGE_NAME=angular PACKAGE_VERSION=">=5.1.0" DARTDOC_PARAMS="--include=angular,angular.security" pub run grinder build-pub-package - else - PACKAGE_NAME=angular PACKAGE_VERSION=">=5.0.0-beta <5.1.0" DARTDOC_PARAMS="--include=angular,angular.security" pub run grinder build-pub-package - fi + PACKAGE_NAME=angular PACKAGE_VERSION=">=7.0.0" DARTDOC_PARAMS="--include=angular" pub run grinder build-pub-package PACKAGE_NAME=access PACKAGE_VERSION=">=1.0.1+2" pub run grinder build-pub-package # Negative test for flutter_plugin_tools, make sure right error message is displayed. PACKAGE_NAME=flutter_plugin_tools PACKAGE_VERSION=">=0.0.14+1" pub run grinder build-pub-package 2>&1 | grep "warning: package:flutter_plugin_tools has no documentable libraries"