From 50f66d56366f4cfb785a0851438f33ea81748592 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Wed, 14 Feb 2018 17:45:35 -0800 Subject: [PATCH 1/2] Make link validation optional --- bin/dartdoc.dart | 11 +++++++---- lib/dartdoc.dart | 5 ++--- lib/src/config.dart | 10 +++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bin/dartdoc.dart b/bin/dartdoc.dart index 9f4736d6d7..6bd054aa87 100644 --- a/bin/dartdoc.dart +++ b/bin/dartdoc.dart @@ -262,7 +262,8 @@ main(List arguments) async { double.parse(args['ambiguous-reexport-scorer-min-confidence']), verboseWarnings: args['verbose-warnings'], excludePackages: args['exclude-packages'], - dropTextFrom: dropTextFrom); + dropTextFrom: dropTextFrom, + validateLinks: args['validate-links']); DartDoc dartdoc = new DartDoc(inputDir, excludeLibraries, sdkDir, generators, outputDir, packageMeta, includeLibraries, includeExternals); @@ -382,13 +383,15 @@ ArgParser _createArgsParser() { "Drop all text for SDK components. Helpful for integration tests for dartdoc, probably not useful for anything else.", negatable: true, defaultsTo: false, - hide: true, - ); + hide: true); parser.addFlag('json', help: 'Prints out progress JSON maps. One entry per line.', defaultsTo: false, negatable: true); - + parser.addFlag('validate-links', + help: 'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)', + negatable: true, + defaultsTo: true); return parser; } diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart index 0eed9dfa34..95f04e0088 100644 --- a/lib/dartdoc.dart +++ b/lib/dartdoc.dart @@ -171,8 +171,7 @@ class DartDoc extends PackageBuilder { await generator.generate(package, outputDir.path); writtenFiles.addAll(generator.writtenFiles.map(path.normalize)); } - - verifyLinks(package, outputDir.path); + if (config.validateLinks) validateLinks(package, outputDir.path); int warnings = package.packageWarningCounter.warningCount; int errors = package.packageWarningCounter.errorCount; if (warnings == 0 && errors == 0) { @@ -398,7 +397,7 @@ class DartDoc extends PackageBuilder { /// Don't call this method more than once, and only after you've /// generated all docs for the Package. - void verifyLinks(Package package, String origin) { + void validateLinks(Package package, String origin) { assert(_hrefs == null); _hrefs = package.allHrefs; diff --git a/lib/src/config.dart b/lib/src/config.dart index 527839e874..95335371cb 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -19,6 +19,7 @@ class Config { final bool verboseWarnings; final List dropTextFrom; final List excludePackages; + final bool validateLinks; Config._( this.inputDir, this.showWarnings, @@ -31,7 +32,8 @@ class Config { this.reexportMinConfidence, this.verboseWarnings, this.dropTextFrom, - this.excludePackages); + this.excludePackages, + this.validateLinks); } Config _config; @@ -49,7 +51,8 @@ void setConfig( double reexportMinConfidence: 0.1, bool verboseWarnings: true, List dropTextFrom, - List excludePackages}) { + List excludePackages, + bool validateLinks: true}) { _config = new Config._( inputDir, showWarnings, @@ -62,5 +65,6 @@ void setConfig( reexportMinConfidence, verboseWarnings, dropTextFrom ?? const [], - excludePackages ?? const []); + excludePackages ?? const [], + validateLinks); } From a00ff284a3069cae1930f6762487e2f624c38fa0 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Wed, 14 Feb 2018 17:46:05 -0800 Subject: [PATCH 2/2] dartfmt --- bin/dartdoc.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/dartdoc.dart b/bin/dartdoc.dart index 6bd054aa87..7fd31a94bf 100644 --- a/bin/dartdoc.dart +++ b/bin/dartdoc.dart @@ -377,21 +377,21 @@ ArgParser _createArgsParser() { help: 'Display extra debugging information and help with warnings.', negatable: true, defaultsTo: true); - parser.addFlag( - 'hide-sdk-text', - help: - "Drop all text for SDK components. Helpful for integration tests for dartdoc, probably not useful for anything else.", - negatable: true, - defaultsTo: false, - hide: true); + parser.addFlag('hide-sdk-text', + help: + "Drop all text for SDK components. Helpful for integration tests for dartdoc, probably not useful for anything else.", + negatable: true, + defaultsTo: false, + hide: true); parser.addFlag('json', help: 'Prints out progress JSON maps. One entry per line.', defaultsTo: false, negatable: true); parser.addFlag('validate-links', - help: 'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)', - negatable: true, - defaultsTo: true); + help: + 'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)', + negatable: true, + defaultsTo: true); return parser; }