Make docs do less work/be less flaky (#34818)
This commit is contained in:
@@ -50,7 +50,12 @@ Future<void> main(List<String> arguments) async {
|
||||
final StringBuffer buf = StringBuffer();
|
||||
buf.writeln('name: Flutter');
|
||||
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:');
|
||||
for (String package in findPackageNames()) {
|
||||
buf.writeln(' $package:');
|
||||
@@ -98,7 +103,7 @@ Future<void> main(List<String> arguments) async {
|
||||
if (code != 0)
|
||||
exit(code);
|
||||
|
||||
createFooter('$kDocsRoot/lib/footer.html');
|
||||
createFooter('$kDocsRoot/lib/', version);
|
||||
copyAssets();
|
||||
createSearchMetadata('$kDocsRoot/lib/opensearch.xml', '$kDocsRoot/doc/opensearch.xml');
|
||||
cleanOutSnippets();
|
||||
@@ -264,15 +269,18 @@ String 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 gitBranch = getBranchName();
|
||||
final String gitBranchOut = gitBranch.isEmpty ? '' : '• </span class="no-break">$gitBranch</span>';
|
||||
|
||||
File(footerPath).writeAsStringSync(<String>[
|
||||
'• </span class="no-break">$timestamp<span>',
|
||||
'• </span class="no-break">${gitRevision()}</span>',
|
||||
gitBranchOut].join(' '));
|
||||
final String gitBranchOut = gitBranch.isEmpty ? '' : '• $gitBranch';
|
||||
File('${footerPath}footer.html').writeAsStringSync('<script src="footer.js"></script>');
|
||||
File('$kPublishRoot/api/footer.js')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''var span = document.querySelector('footer>span');
|
||||
if (span) {
|
||||
span.innerText = 'Flutter $version • $timestamp • ${gitRevision()} $gitBranchOut';
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
/// Generates an OpenSearch XML description that can be used to add a custom
|
||||
|
||||
Reference in New Issue
Block a user