Skip to content

Commit 043bd79

Browse files
authored
Add an option to exclude version info from footer (dart-lang#2010)
* Add an option to exclude version info from footer * Update changelog * Fix code
1 parent 3540711 commit 043bd79

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.28.5-dev
22
* Support the latest version of `package:analyzer`.
33
* Fix hyperlinks to overriden methods (#1994).
4+
* Add an option to exclude version in footer info (#1982).
45

56
## 0.28.4
67
* **Breaking change** Change the default for `allow-tools` command line flag to false.

lib/src/dartdoc_options.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,8 @@ class DartdocOptionContext extends DartdocOptionContextBase
13761376

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

1379+
bool get excludeFooterVersion => optionSet['excludeFooterVersion'].valueAt(context);
1380+
13791381
ToolConfiguration get tools => optionSet['tools'].valueAt(context);
13801382

13811383
/// _input is only used to construct synthetic options.
@@ -1611,6 +1613,8 @@ Future<List<DartdocOption>> createDartdocOptions() async {
16111613
DartdocOptionArgOnly<bool>('verboseWarnings', true,
16121614
help: 'Display extra debugging information and help with warnings.',
16131615
negatable: true),
1616+
DartdocOptionFileOnly<bool>('excludeFooterVersion', false,
1617+
help: 'Excludes the package version number in the footer text'),
16141618
DartdocOptionFileOnly<ToolConfiguration>('tools', ToolConfiguration.empty,
16151619
convertYamlToType: ToolConfiguration.fromYamlMap,
16161620
help: 'A map of tool names to executable paths. Each executable must '

lib/src/model.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4993,6 +4993,8 @@ class PackageGraph {
49934993

49944994
final bool hasEmbedderSdk;
49954995

4996+
bool get hasFooterVersion => !config.excludeFooterVersion;
4997+
49964998
PackageGraph get packageGraph => this;
49974999

49985000
/// Map of package name to Package.

lib/templates/_footer.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
<footer>
44
<span class="no-break">
5-
{{packageGraph.defaultPackage.name}} {{packageGraph.defaultPackage.version}}
5+
{{packageGraph.defaultPackage.name}}
6+
{{#packageGraph.hasFooterVersion}}
7+
{{packageGraph.defaultPackage.version}}
8+
{{/packageGraph.hasFooterVersion}}
69
</span>
710

811
<!-- footer-text placeholder -->

test/dartdoc_integration_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,28 @@ void main() {
230230
File outFile = File(path.join(tempDir.path, 'index.html'));
231231
expect(outFile.readAsStringSync(), contains('footer text include'));
232232
});
233+
234+
test('--footer-text excludes version', () async {
235+
String _testPackagePath =
236+
path.fromUri(_currentFileUri.resolve('../testing/test_package_options'));
237+
238+
var args = <String>[
239+
dartdocPath,
240+
'--output',
241+
tempDir.path
242+
];
243+
244+
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
245+
workingDirectory: _testPackagePath);
246+
247+
File outFile = File(path.join(tempDir.path, 'index.html'));
248+
RegExp footerRegex = RegExp('<footer>(.*\s*?\n?)+?</footer>', multiLine: true);
249+
// get footer, check for version number
250+
RegExpMatch m = footerRegex.firstMatch(outFile.readAsStringSync());
251+
RegExp version = RegExp(r'(\d+\.)?(\d+\.)?(\*|\d+)');
252+
expect(version.hasMatch(m.group(0)), false);
253+
});
254+
233255
}, timeout: Timeout.factor(4));
234256
}
257+

testing/test_package_options/dartdoc_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dartdoc:
88
linkTo:
99
url: 'https://nonexistingsuperpackage.topdomain/%n%/%v%'
1010
showUndocumentedCategories: true
11+
excludeFooterVersion: true

0 commit comments

Comments
 (0)