Unverified Commit 1e05bb5b authored by Dan Field's avatar Dan Field Committed by GitHub

Make docs do less work/be less flaky (#34818)

parent 2e0d6f77
...@@ -50,7 +50,12 @@ Future<void> main(List<String> arguments) async { ...@@ -50,7 +50,12 @@ Future<void> main(List<String> arguments) async {
final StringBuffer buf = StringBuffer(); final StringBuffer buf = StringBuffer();
buf.writeln('name: Flutter'); buf.writeln('name: Flutter');
buf.writeln('homepage: https://flutter.dev'); buf.writeln('homepage: https://flutter.dev');
buf.writeln('version: $version'); // TODO(dnfield): We should make DartDoc able to avoid emitting this. If we
// use the real value here, every file will get marked as new instead of only
// files that have otherwise changed. Instead, we replace it dynamically using
// JavaScript so that fewer files get marked as changed.
// https://github.com/dart-lang/dartdoc/issues/1982
buf.writeln('version: 0.0.0');
buf.writeln('dependencies:'); buf.writeln('dependencies:');
for (String package in findPackageNames()) { for (String package in findPackageNames()) {
buf.writeln(' $package:'); buf.writeln(' $package:');
...@@ -98,7 +103,7 @@ Future<void> main(List<String> arguments) async { ...@@ -98,7 +103,7 @@ Future<void> main(List<String> arguments) async {
if (code != 0) if (code != 0)
exit(code); exit(code);
createFooter('$kDocsRoot/lib/footer.html'); createFooter('$kDocsRoot/lib/', version);
copyAssets(); copyAssets();
createSearchMetadata('$kDocsRoot/lib/opensearch.xml', '$kDocsRoot/doc/opensearch.xml'); createSearchMetadata('$kDocsRoot/lib/opensearch.xml', '$kDocsRoot/doc/opensearch.xml');
cleanOutSnippets(); cleanOutSnippets();
...@@ -264,15 +269,18 @@ String gitRevision() { ...@@ -264,15 +269,18 @@ String gitRevision() {
return gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision; return gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
} }
void createFooter(String footerPath) { void createFooter(String footerPath, String version) {
final String timestamp = DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now()); final String timestamp = DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now());
final String gitBranch = getBranchName(); final String gitBranch = getBranchName();
final String gitBranchOut = gitBranch.isEmpty ? '' : '• </span class="no-break">$gitBranch</span>'; final String gitBranchOut = gitBranch.isEmpty ? '' : '• $gitBranch';
File('${footerPath}footer.html').writeAsStringSync('<script src="footer.js"></script>');
File(footerPath).writeAsStringSync(<String>[ File('$kPublishRoot/api/footer.js')
'• </span class="no-break">$timestamp<span>', ..createSync(recursive: true)
'• </span class="no-break">${gitRevision()}</span>', ..writeAsStringSync('''var span = document.querySelector('footer>span');
gitBranchOut].join(' ')); if (span) {
span.innerText = 'Flutter $version $timestamp ${gitRevision()} $gitBranchOut';
}
''');
} }
/// Generates an OpenSearch XML description that can be used to add a custom /// Generates an OpenSearch XML description that can be used to add a custom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment