Skip to content

Merge into nnbd branch from master #2800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -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%'
15 changes: 7 additions & 8 deletions lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -196,12 +194,15 @@ class Dartdoc {

Stream<String> get onCheckProgress => _onCheckProgress.stream;

@Deprecated('Will be removed in 4.0.0. '
'Use the return value from generateDocsBase instead.')
PackageGraph packageGraph;

@visibleForTesting
Future<DartdocResults> 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'} "
Expand Down Expand Up @@ -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<DartdocResults> 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');
}
Expand All @@ -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();
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/model/class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion lib/src/model/inheritable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
1 change: 0 additions & 1 deletion lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion lib/src/model/mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
10 changes: 10 additions & 0 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;

Expand Down
1 change: 0 additions & 1 deletion lib/src/model/prefix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
1 change: 0 additions & 1 deletion lib/src/model_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/src/tool_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ class SnapshotCache {
void dispose() {
_instances.remove(_resourceProvider);
if (snapshotCache.exists) {
return snapshotCache.delete();
snapshotCache.delete();
}
return null;
}
}

Expand Down
18 changes: 8 additions & 10 deletions lib/src/tool_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ class ToolTempFileTracker {
: temporaryDirectory =
resourceProvider.createSystemTemp('dartdoc_tools_');

static ToolTempFileTracker _instance;
static final Map<ResourceProvider, ToolTempFileTracker> _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;

Expand All @@ -48,9 +46,9 @@ class ToolTempFileTracker {
}

/// Call once no more files are to be created.
Future<void> dispose() async {
void dispose() {
if (temporaryDirectory.exists) {
return temporaryDirectory.delete();
temporaryDirectory.delete();
}
}
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Generated code. Do not modify.
const packageVersion = '3.0.0';
const packageVersion = '3.1.0';
50 changes: 25 additions & 25 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 11 additions & 9 deletions test/mustachio/runtime_renderer_render_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<FileSystemException>().having(
(e) => e.message,
'message',
contains('"${barTemplateFile.path}" does not exist.'))));
throwsA(const TypeMatcher<FileSystemException>()
.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<MustachioResolutionError>()
.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<MustachioResolutionError>().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}}
│ ^^^^^^^^^^^^^^^^^^^^^
'''))));
''')))));
});
}
6 changes: 1 addition & 5 deletions tool/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down