Skip to content

Make link validation optional #1607

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 2 commits into from
Feb 15, 2018
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
23 changes: 13 additions & 10 deletions bin/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ main(List<String> 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);
Expand Down Expand Up @@ -376,19 +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);
return parser;
}

Expand Down
5 changes: 2 additions & 3 deletions lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
10 changes: 7 additions & 3 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Config {
final bool verboseWarnings;
final List<String> dropTextFrom;
final List<String> excludePackages;
final bool validateLinks;
Config._(
this.inputDir,
this.showWarnings,
Expand All @@ -31,7 +32,8 @@ class Config {
this.reexportMinConfidence,
this.verboseWarnings,
this.dropTextFrom,
this.excludePackages);
this.excludePackages,
this.validateLinks);
}

Config _config;
Expand All @@ -49,7 +51,8 @@ void setConfig(
double reexportMinConfidence: 0.1,
bool verboseWarnings: true,
List<String> dropTextFrom,
List<String> excludePackages}) {
List<String> excludePackages,
bool validateLinks: true}) {
_config = new Config._(
inputDir,
showWarnings,
Expand All @@ -62,5 +65,6 @@ void setConfig(
reexportMinConfidence,
verboseWarnings,
dropTextFrom ?? const <String>[],
excludePackages ?? const <String>[]);
excludePackages ?? const <String>[],
validateLinks);
}