Add an option to exclude version info from footer (#2010)

* Add an option to exclude version info from footer

* Update changelog

* Fix code
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc10a77..df603c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart
index cf05f89..2439fe6 100644
--- a/lib/src/dartdoc_options.dart
+++ b/lib/src/dartdoc_options.dart
@@ -1376,6 +1376,8 @@
 
   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.
@@ -1611,6 +1613,8 @@
     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 '
diff --git a/lib/src/model.dart b/lib/src/model.dart
index 3ffb04d..ebba432 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -4993,6 +4993,8 @@
 
   final bool hasEmbedderSdk;
 
+  bool get hasFooterVersion => !config.excludeFooterVersion;
+
   PackageGraph get packageGraph => this;
 
   /// Map of package name to Package.
diff --git a/lib/templates/_footer.html b/lib/templates/_footer.html
index 3aa83c9..c20bd74 100644
--- a/lib/templates/_footer.html
+++ b/lib/templates/_footer.html
@@ -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 -->
diff --git a/test/dartdoc_integration_test.dart b/test/dartdoc_integration_test.dart
index 2e65818..383477d 100644
--- a/test/dartdoc_integration_test.dart
+++ b/test/dartdoc_integration_test.dart
@@ -230,5 +230,28 @@
       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));
 }
+
diff --git a/testing/test_package_options/dartdoc_options.yaml b/testing/test_package_options/dartdoc_options.yaml
index 84a0f1d..b925cba 100644
--- a/testing/test_package_options/dartdoc_options.yaml
+++ b/testing/test_package_options/dartdoc_options.yaml
@@ -8,3 +8,4 @@
   linkTo:
     url: 'https://nonexistingsuperpackage.topdomain/%n%/%v%'
   showUndocumentedCategories: true
+  excludeFooterVersion: true