Skip to content

Commit ccf8b91

Browse files
authored
Make link validation optional (#1607)
* Make link validation optional * dartfmt
1 parent 00c3306 commit ccf8b91

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

bin/dartdoc.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ main(List<String> arguments) async {
262262
double.parse(args['ambiguous-reexport-scorer-min-confidence']),
263263
verboseWarnings: args['verbose-warnings'],
264264
excludePackages: args['exclude-packages'],
265-
dropTextFrom: dropTextFrom);
265+
dropTextFrom: dropTextFrom,
266+
validateLinks: args['validate-links']);
266267

267268
DartDoc dartdoc = new DartDoc(inputDir, excludeLibraries, sdkDir, generators,
268269
outputDir, packageMeta, includeLibraries, includeExternals);
@@ -376,19 +377,21 @@ ArgParser _createArgsParser() {
376377
help: 'Display extra debugging information and help with warnings.',
377378
negatable: true,
378379
defaultsTo: true);
379-
parser.addFlag(
380-
'hide-sdk-text',
381-
help:
382-
"Drop all text for SDK components. Helpful for integration tests for dartdoc, probably not useful for anything else.",
383-
negatable: true,
384-
defaultsTo: false,
385-
hide: true,
386-
);
380+
parser.addFlag('hide-sdk-text',
381+
help:
382+
"Drop all text for SDK components. Helpful for integration tests for dartdoc, probably not useful for anything else.",
383+
negatable: true,
384+
defaultsTo: false,
385+
hide: true);
387386
parser.addFlag('json',
388387
help: 'Prints out progress JSON maps. One entry per line.',
389388
defaultsTo: false,
390389
negatable: true);
391-
390+
parser.addFlag('validate-links',
391+
help:
392+
'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)',
393+
negatable: true,
394+
defaultsTo: true);
392395
return parser;
393396
}
394397

lib/dartdoc.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ class DartDoc extends PackageBuilder {
171171
await generator.generate(package, outputDir.path);
172172
writtenFiles.addAll(generator.writtenFiles.map(path.normalize));
173173
}
174-
175-
verifyLinks(package, outputDir.path);
174+
if (config.validateLinks) validateLinks(package, outputDir.path);
176175
int warnings = package.packageWarningCounter.warningCount;
177176
int errors = package.packageWarningCounter.errorCount;
178177
if (warnings == 0 && errors == 0) {
@@ -398,7 +397,7 @@ class DartDoc extends PackageBuilder {
398397

399398
/// Don't call this method more than once, and only after you've
400399
/// generated all docs for the Package.
401-
void verifyLinks(Package package, String origin) {
400+
void validateLinks(Package package, String origin) {
402401
assert(_hrefs == null);
403402
_hrefs = package.allHrefs;
404403

lib/src/config.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Config {
1919
final bool verboseWarnings;
2020
final List<String> dropTextFrom;
2121
final List<String> excludePackages;
22+
final bool validateLinks;
2223
Config._(
2324
this.inputDir,
2425
this.showWarnings,
@@ -31,7 +32,8 @@ class Config {
3132
this.reexportMinConfidence,
3233
this.verboseWarnings,
3334
this.dropTextFrom,
34-
this.excludePackages);
35+
this.excludePackages,
36+
this.validateLinks);
3537
}
3638

3739
Config _config;
@@ -49,7 +51,8 @@ void setConfig(
4951
double reexportMinConfidence: 0.1,
5052
bool verboseWarnings: true,
5153
List<String> dropTextFrom,
52-
List<String> excludePackages}) {
54+
List<String> excludePackages,
55+
bool validateLinks: true}) {
5356
_config = new Config._(
5457
inputDir,
5558
showWarnings,
@@ -62,5 +65,6 @@ void setConfig(
6265
reexportMinConfidence,
6366
verboseWarnings,
6467
dropTextFrom ?? const <String>[],
65-
excludePackages ?? const <String>[]);
68+
excludePackages ?? const <String>[],
69+
validateLinks);
6670
}

0 commit comments

Comments
 (0)