diff --git a/bin/dartdoc.dart b/bin/dartdoc.dart index 7fd31a94bf..ce6ef1317f 100644 --- a/bin/dartdoc.dart +++ b/bin/dartdoc.dart @@ -144,7 +144,7 @@ main(List arguments) async { output['message'] = record.message; } - print(JSON.encode(output)); + print(json.encode(output)); }); } else { final stopwatch = new Stopwatch()..start(); @@ -311,29 +311,21 @@ ArgParser _createArgsParser() { help: 'Path to source directory.', defaultsTo: Directory.current.path); parser.addOption('output', help: 'Path to output directory.', defaultsTo: defaultOutDir); - parser.addOption('header', - allowMultiple: true, - splitCommas: true, - help: 'paths to header files containing HTML text.'); - parser.addOption('footer', - allowMultiple: true, - splitCommas: true, - help: 'paths to footer files containing HTML text.'); - parser.addOption('footer-text', - allowMultiple: true, + parser.addMultiOption('header', + splitCommas: true, help: 'paths to header files containing HTML text.'); + parser.addMultiOption('footer', + splitCommas: true, help: 'paths to footer files containing HTML text.'); + parser.addMultiOption('footer-text', splitCommas: true, help: 'paths to footer-text files ' '(optional text next to the package name and version).'); - parser.addOption('exclude', - allowMultiple: true, splitCommas: true, help: 'Library names to ignore.'); - parser.addOption('exclude-packages', - allowMultiple: true, splitCommas: true, help: 'Package names to ignore.'); - parser.addOption('include', - allowMultiple: true, - splitCommas: true, - help: 'Library names to generate docs for.'); - parser.addOption('include-external', - allowMultiple: true, + parser.addMultiOption('exclude', + splitCommas: true, help: 'Library names to ignore.'); + parser.addMultiOption('exclude-packages', + splitCommas: true, help: 'Package names to ignore.'); + parser.addMultiOption('include', + splitCommas: true, help: 'Library names to generate docs for.'); + parser.addMultiOption('include-external', help: 'Additional (external) dart files to include; use "dir/fileName", ' 'as in lib/material.dart.'); parser.addOption('hosted-url', @@ -353,10 +345,9 @@ ArgParser _createArgsParser() { help: 'Group libraries from the same package into categories.', negatable: false, defaultsTo: false); - parser.addOption('category-order', + parser.addMultiOption('category-order', help: 'A list of category names to place first when --use-categories is ' 'set. Unmentioned categories are sorted after these.', - allowMultiple: true, splitCommas: true); parser.addFlag('auto-include-dependencies', help: diff --git a/lib/src/html/resource_loader.dart b/lib/src/html/resource_loader.dart index 368665ce5d..2126e01cb2 100644 --- a/lib/src/html/resource_loader.dart +++ b/lib/src/html/resource_loader.dart @@ -11,7 +11,7 @@ library dartdoc.resource_loader; import 'dart:async' show Future; -import 'dart:convert' show UTF8; +import 'dart:convert' show utf8; import 'package:resource/resource.dart'; @@ -19,7 +19,7 @@ import 'package:resource/resource.dart'; Future loadAsString(String path) async { var bytes = await loadAsBytes(path); - return UTF8.decode(bytes); + return utf8.decode(bytes); } /// Loads a `package:` resource as an [List]. diff --git a/lib/src/io_utils.dart b/lib/src/io_utils.dart index 6554c1b22b..f99a69df22 100644 --- a/lib/src/io_utils.dart +++ b/lib/src/io_utils.dart @@ -77,7 +77,7 @@ class SubprocessLauncher { assert(prefix != null); if (filter == null) filter = (line) => [line]; stream - .transform(UTF8.decoder) + .transform(utf8.decoder) .transform(const LineSplitter()) .expand(filter) .listen((String line) { diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart index c486e98ec3..6f0f67ef2c 100644 --- a/lib/src/markdown_processor.dart +++ b/lib/src/markdown_processor.dart @@ -140,15 +140,15 @@ final RegExp notARealDocReference = new RegExp(r'''(^[^\w]|^[\d]|[,"'/]|^$)'''); final RegExp operatorPrefix = new RegExp(r'^operator[ ]*'); -final HtmlEscape htmlEscape = const HtmlEscape(HtmlEscapeMode.ELEMENT); +final HtmlEscape htmlEscape = const HtmlEscape(HtmlEscapeMode.element); final List _markdown_syntaxes = [ new _InlineCodeSyntax(), new _AutolinkWithoutScheme() -]..addAll(md.ExtensionSet.gitHub.inlineSyntaxes); +]..addAll(md.ExtensionSet.gitHubFlavored.inlineSyntaxes); final List _markdown_block_syntaxes = [] - ..addAll(md.ExtensionSet.gitHub.blockSyntaxes); + ..addAll(md.ExtensionSet.gitHubFlavored.blockSyntaxes); // Remove these schemas from the display text for hyperlinks. final RegExp _hide_schemes = new RegExp('^(http|https)://'); @@ -735,7 +735,7 @@ String _linkDocReference( // This would be linkedElement.linkedName, but link bodies are slightly // different for doc references. if (linkedElement.href == null) { - return '${HTML_ESCAPE.convert(label)}'; + return '${htmlEscape.convert(label)}'; } else { return '$label'; } @@ -744,7 +744,7 @@ String _linkDocReference( warnable.warn(PackageWarning.unresolvedDocReference, message: codeRef, referredFrom: warnable.documentationFrom); } - return '${HTML_ESCAPE.convert(label)}'; + return '${htmlEscape.convert(label)}'; } } @@ -992,7 +992,7 @@ class _InlineCodeSyntax extends md.InlineSyntax { @override bool onMatch(md.InlineParser parser, Match match) { - var element = new md.Element.text('code', HTML_ESCAPE.convert(match[1])); + var element = new md.Element.text('code', htmlEscape.convert(match[1])); parser.addNode(element); return true; } diff --git a/lib/src/model.dart b/lib/src/model.dart index f68fb59994..f0f0d112b5 100644 --- a/lib/src/model.dart +++ b/lib/src/model.dart @@ -61,7 +61,7 @@ Map>>> get _crossdartJson { var crossdartFile = new File(p.join(config.inputDir.path, "crossdart.json")); if (crossdartFile.existsSync()) { - __crossdartJson = JSON.decode(crossdartFile.readAsStringSync()) + __crossdartJson = json.decode(crossdartFile.readAsStringSync()) as Map>>>; } else { __crossdartJson = {}; @@ -1543,7 +1543,7 @@ abstract class GetterSetterCombo implements ModelElement { String _buildConstantValueBase() { String result = constantInitializer?.toString() ?? ''; - return const HtmlEscape(HtmlEscapeMode.UNKNOWN).convert(result); + return const HtmlEscape(HtmlEscapeMode.unknown).convert(result); } String get constantValue => linkifyConstantValue(constantValueBase); @@ -3413,7 +3413,7 @@ abstract class ModelElement extends Canonicalization if (isPublicAndPackageDocumented) { warn(PackageWarning.noCanonicalFound); } - return HTML_ESCAPE.convert(name); + return htmlEscape.convert(name); } var classContent = isDeprecated ? ' class="deprecated"' : ''; diff --git a/pubspec.lock b/pubspec.lock index 24097f014d..2b01741fee 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -408,4 +408,4 @@ packages: source: hosted version: "2.1.13" sdks: - dart: ">=2.0.0-dev.23.0 <=2.0.0-dev.36.0" + dart: ">=2.0.0-dev.23.0 <=2.0.0-dev.38.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1c3118b354..0b74dcfed5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/dartdoc # For development, recommend 1.25.0-dev.0.0 or higher to allow # dartanalyzer to work on dartdoc itself. environment: - sdk: '>=1.23.0-dev.11.5 <2.0.0' + sdk: '>=2.0.0-dev.9.0 <3.0.0' dependencies: analyzer: '0.31.2-alpha.0' args: '>=0.13.0 <2.0.0' diff --git a/test/compare_output_test.dart b/test/compare_output_test.dart index f682539b93..3a594d44e3 100644 --- a/test/compare_output_test.dart +++ b/test/compare_output_test.dart @@ -174,7 +174,7 @@ void main() { var jsonValues = LineSplitter .split(result.stdout) - .map((j) => JSON.decode(j) as Map) + .map((j) => json.decode(j) as Map) .toList(); expect(jsonValues, isNotEmpty, diff --git a/test/model_test.dart b/test/model_test.dart index 60329f4ecc..3434e02ec7 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -1172,11 +1172,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('typedef params have proper signature', () { - // typedef void VoidCallback(); - // void addCallback(VoidCallback callback) { } ModelFunction function = fakeLibrary.functions.firstWhere((f) => f.name == 'addCallback'); - ElementType t = function.parameters.first.modelType; String params = function.linkedParams(); expect( params, @@ -1184,8 +1181,6 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, 'VoidCallback ' 'callback'); - // typedef int Callback2(String); - // void addCallback2(Callback2 callback) { } function = fakeLibrary.functions.firstWhere((f) => f.name == 'addCallback2'); params = function.linkedParams(); @@ -1216,7 +1211,6 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, .singleWhere((f) => f.name == 'explicitSetter'); // TODO(jcollins-g): really, these shouldn't be called "parameters" in // the span class. - ElementType t = explicitSetter.modelType; expect(explicitSetter.linkedReturnType, 'dynamic Function(int, Cool, List<int>)'); }); @@ -1293,7 +1287,6 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, Method aTypedefReturningMethodInterface = TemplatedInterface .allInstanceMethods .singleWhere((m) => m.name == 'aTypedefReturningMethodInterface'); - ElementType mt = aTypedefReturningMethodInterface.modelType; expect(aTypedefReturningMethodInterface.linkedReturnType, 'ParameterizedTypedef<List<String>>'); }); @@ -2234,13 +2227,17 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, fakeLibrary.classes.firstWhere((t) => t.name == 'TypedefUsingClass'); }); - test('Typedefs with bound type parameters indirectly referred in parameters are displayed', () { + test( + 'Typedefs with bound type parameters indirectly referred in parameters are displayed', + () { Constructor theConstructor = TypedefUsingClass.constructors.first; - expect(theConstructor.linkedParams(), equals('ParameterizedTypedef<double> x')); + expect( + theConstructor.linkedParams(), + equals( + 'ParameterizedTypedef<double> x')); }); test('anonymous nested functions inside typedefs are handled', () { - ElementType t = aComplexTypedef.modelType; expect(aComplexTypedef, isNotNull); expect(aComplexTypedef.linkedReturnType, startsWith('Function')); expect(aComplexTypedef.nameWithGenerics, @@ -2371,13 +2368,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('typedef param is linked and does not include types', () { - ElementType t = methodWithTypedefParam.parameters.first.modelType; var params = methodWithTypedefParam.linkedParams(); expect( params, equals( 'processMessage p')); - //expect(params, contains('')); }); }); diff --git a/testing/test_package/lib/fake.dart b/testing/test_package/lib/fake.dart index 087e14d398..ad099b5907 100644 --- a/testing/test_package/lib/fake.dart +++ b/testing/test_package/lib/fake.dart @@ -47,13 +47,10 @@ library fake; import 'dart:async'; - import 'dart:collection'; -import 'example.dart'; - import 'css.dart' as css; - +import 'example.dart'; import 'two_exports.dart' show BaseClass; abstract class ImplementingThingy implements BaseThingy {} @@ -224,6 +221,7 @@ typedef int LotsAndLotsOfParameters(so, many, parameters, it, should, wrap, /// This class is cool! class Cool { + // ignore: missing_return Cool returnCool() {} } @@ -258,7 +256,9 @@ class SuperAwesomeClass { /// /// Another comment line. void fly(int height, Cool superCool, {String msg}) { + // ignore: unused_local_variable, avoid_init_to_null var x = null; + // ignore: unused_local_variable int i, y; for (int z = 0; z < 100; z++) { print('hi'); @@ -400,6 +400,7 @@ class ClassWithUnusualProperties extends ImplicitProperties { /// /// The rest of this is not in the first paragraph. @Annotation('value') +// ignore: deprecated_member_use class LongFirstLine extends SuperAwesomeClass with MixMeIn implements Interface, AnotherInterface { @@ -649,14 +650,18 @@ class HasGenericWithExtends {} /// Extends [ListBase] class SpecialList extends ListBase { + // ignore: annotate_overrides E operator [](int index) { return null; } + // ignore: annotate_overrides int get length => 0; + // ignore: annotate_overrides void set length(int length) {} + // ignore: annotate_overrides void operator []=(int index, E value) {} } @@ -676,6 +681,7 @@ class BaseForDocComments { /// /// Reference to another method in this class [anotherMethod] xx /// + // ignore: deprecated_member_use /// Reference to a top-level function in this library [topLevelFunction] xx /// /// Reference to a top-level function in another library that is imported into this library (example lib) [function1] xx @@ -771,6 +777,7 @@ class ReferringClass { abstract class MIEEMixinWithOverride = MIEEBase with _MIEEPrivateOverride; abstract class _MIEEPrivateOverride implements MIEEThing { + // ignore: annotate_overrides void operator[]=(K key, V value) { throw new UnsupportedError("Never use this"); } @@ -779,6 +786,7 @@ abstract class _MIEEPrivateOverride implements MIEEThing { abstract class MIEEBase extends MIEEMixin {} abstract class MIEEMixin implements MIEEThing { + // ignore: annotate_overrides operator []=(K key, V value); } diff --git a/tool/doc_packages.dart b/tool/doc_packages.dart index 63d4066ffb..0c31e56c52 100644 --- a/tool/doc_packages.dart +++ b/tool/doc_packages.dart @@ -6,7 +6,7 @@ library dartdoc.doc_packages; import 'dart:async'; -import 'dart:convert' show JSON, UTF8; +import 'dart:convert' show json, utf8; import 'dart:io'; import 'package:args/args.dart'; @@ -125,17 +125,17 @@ Future> _packageUrls(int page) { return http .get('https://pub.dartlang.org/packages.json?page=${page}') .then((response) { - return new List.from(JSON.decode(response.body)['packages']); + return new List.from(json.decode(response.body)['packages']); }); } Future> _getPackageInfos(List packageUrls) { var futures = packageUrls.map((String p) { return http.get(p).then((response) { - var json = JSON.decode(response.body); - String name = json['name']; + var decodedJson = json.decode(response.body); + String name = decodedJson['name']; List versions = new List.from( - json['versions'].map((v) => new Version.parse(v))); + decodedJson['versions'].map((v) => new Version.parse(v))); return new PackageInfo(name, Version.primary(versions)); }); }).toList(); @@ -200,8 +200,8 @@ Future _exec(String command, List args, .start(command, args, workingDirectory: cwd) .then((Process process) { if (!quiet) { - process.stdout.listen((bytes) => _log(UTF8.decode(bytes))); - process.stderr.listen((bytes) => _log(UTF8.decode(bytes))); + process.stdout.listen((bytes) => _log(utf8.decode(bytes))); + process.stderr.listen((bytes) => _log(utf8.decode(bytes))); } Future f = process.exitCode.then((code) {