Skip to content

Add an option to exclude version info from footer #2010

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 3 commits into from
Aug 22, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.28.5-dev
* Support the latest version of `package:analyzer`.
* Fix hyperlinks to overriden methods (#1994).
* Add an option to exclude version in footer info (#1982).

## 0.28.4
* **Breaking change** Change the default for `allow-tools` command line flag to false.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,8 @@ class DartdocOptionContext extends DartdocOptionContextBase

bool get injectHtml => optionSet['injectHtml'].valueAt(context);

bool get excludeFooterVersion => optionSet['excludeFooterVersion'].valueAt(context);

ToolConfiguration get tools => optionSet['tools'].valueAt(context);

/// _input is only used to construct synthetic options.
Expand Down Expand Up @@ -1611,6 +1613,8 @@ Future<List<DartdocOption>> createDartdocOptions() async {
DartdocOptionArgOnly<bool>('verboseWarnings', true,
help: 'Display extra debugging information and help with warnings.',
negatable: true),
DartdocOptionFileOnly<bool>('excludeFooterVersion', false,
help: 'Excludes the package version number in the footer text'),
DartdocOptionFileOnly<ToolConfiguration>('tools', ToolConfiguration.empty,
convertYamlToType: ToolConfiguration.fromYamlMap,
help: 'A map of tool names to executable paths. Each executable must '
Expand Down
2 changes: 2 additions & 0 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4993,6 +4993,8 @@ class PackageGraph {

final bool hasEmbedderSdk;

bool get hasFooterVersion => !config.excludeFooterVersion;

PackageGraph get packageGraph => this;

/// Map of package name to Package.
Expand Down
5 changes: 4 additions & 1 deletion lib/templates/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

<footer>
<span class="no-break">
{{packageGraph.defaultPackage.name}} {{packageGraph.defaultPackage.version}}
{{packageGraph.defaultPackage.name}}
{{#packageGraph.hasFooterVersion}}
{{packageGraph.defaultPackage.version}}
{{/packageGraph.hasFooterVersion}}
</span>

<!-- footer-text placeholder -->
Expand Down
23 changes: 23 additions & 0 deletions test/dartdoc_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,28 @@ void main() {
File outFile = File(path.join(tempDir.path, 'index.html'));
expect(outFile.readAsStringSync(), contains('footer text include'));
});

test('--footer-text excludes version', () async {
String _testPackagePath =
path.fromUri(_currentFileUri.resolve('../testing/test_package_options'));

var args = <String>[
dartdocPath,
'--output',
tempDir.path
];

await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
workingDirectory: _testPackagePath);

File outFile = File(path.join(tempDir.path, 'index.html'));
RegExp footerRegex = RegExp('<footer>(.*\s*?\n?)+?</footer>', multiLine: true);
// get footer, check for version number
RegExpMatch m = footerRegex.firstMatch(outFile.readAsStringSync());
RegExp version = RegExp(r'(\d+\.)?(\d+\.)?(\*|\d+)');
expect(version.hasMatch(m.group(0)), false);
});

}, timeout: Timeout.factor(4));
}

1 change: 1 addition & 0 deletions testing/test_package_options/dartdoc_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dartdoc:
linkTo:
url: 'https://nonexistingsuperpackage.topdomain/%n%/%v%'
showUndocumentedCategories: true
excludeFooterVersion: true