diff --git a/app/lib/dartdoc/customization.dart b/app/lib/dartdoc/customization.dart
index 471dc3bae7..15201720f3 100644
--- a/app/lib/dartdoc/customization.dart
+++ b/app/lib/dartdoc/customization.dart
@@ -164,9 +164,11 @@ class DartdocCustomizer {
final pubPackageText = '$packageName package';
if (breadcrumbs.children.length == 1) {
// we are on the index page
- final firstLink = breadcrumbs.querySelector('a');
- firstLink.attributes['href'] = pubPackageLink;
- firstLink.text = pubPackageText;
+ final newItem = Element.tag('li');
+ newItem.append(Element.tag('a')
+ ..attributes['href'] = pubPackageLink
+ ..text = pubPackageText);
+ breadcrumbs.children.first.replaceWith(newItem);
final docitem = Element.tag('li')
..className = 'self-crumb'
diff --git a/app/lib/dartdoc/dartdoc_runner.dart b/app/lib/dartdoc/dartdoc_runner.dart
index a90666ddc0..5cdd9890c7 100644
--- a/app/lib/dartdoc/dartdoc_runner.dart
+++ b/app/lib/dartdoc/dartdoc_runner.dart
@@ -204,10 +204,16 @@ class DartdocJobProcessor extends JobProcessor {
}
if (hasContent) {
- await DartdocCustomizer(
- job.packageName, job.packageVersion, job.isLatestStable)
- .customizeDir(outputDir);
- logFileOutput.write('Content customization completed.\n\n');
+ try {
+ await DartdocCustomizer(
+ job.packageName, job.packageVersion, job.isLatestStable)
+ .customizeDir(outputDir);
+ logFileOutput.write('Content customization completed.\n\n');
+ } catch (e, st) {
+ // Do not block on customization failure.
+ _logger.severe('Dartdoc customization failed ($job).', e, st);
+ logFileOutput.write('Content customization failed.\n\n');
+ }
await _tar(tempDirPath, tarDir, outputDir, logFileOutput);
} else {
diff --git a/app/test/dartdoc/customization_test.dart b/app/test/dartdoc/customization_test.dart
index d5a43475fe..f4250df2eb 100644
--- a/app/test/dartdoc/customization_test.dart
+++ b/app/test/dartdoc/customization_test.dart
@@ -47,32 +47,37 @@ void main() {
golden.split('\n').where((s) => s.isNotEmpty));
}
- group('pana 0.10.2', () {
- final prevCustomizer = DartdocCustomizer('pana', '0.12.2', false);
- final latestCustomizer = DartdocCustomizer('pana', '0.12.2', true);
-
- void expectMatch(String name) {
- test(name, () {
- final inputName = 'pana_0.12.2_$name.html';
- final outputName = 'pana_0.12.2_$name.out.html';
- final diffName = 'pana_0.12.2_$name.latest.diff';
- final html = File('$goldenDir/$inputName').readAsStringSync();
- final prevResult = prevCustomizer.customizeHtml(html) ?? html;
- final latestResult = latestCustomizer.customizeHtml(html) ?? html;
- expectGoldenFile(prevResult, outputName);
- expectGoldenFile(_miniDiff(prevResult, latestResult), diffName);
-
- if (_regenerateGoldens) {
- fail('Set `_regenerateGoldens` to `false` to run tests.');
- }
- });
- }
+ void expectMatch(String package, String version, String name) {
+ test('Match $package $version $name', () {
+ final prevCustomizer = DartdocCustomizer(package, version, false);
+ final latestCustomizer = DartdocCustomizer(package, version, true);
+
+ final path = '${package}_${version}_$name';
+ final inputName = '$path.html';
+ final outputName = '$path.out.html';
+ final diffName = '$path.latest.diff';
+ final html = File('$goldenDir/$inputName').readAsStringSync();
+ final prevResult = prevCustomizer.customizeHtml(html) ?? html;
+ final latestResult = latestCustomizer.customizeHtml(html) ?? html;
+ expectGoldenFile(prevResult, outputName);
+ expectGoldenFile(_miniDiff(prevResult, latestResult), diffName);
+
+ if (_regenerateGoldens) {
+ fail('Set `_regenerateGoldens` to `false` to run tests.');
+ }
+ });
+ }
+
+ group('pana 0.12.2', () {
+ expectMatch('pana', '0.12.2', 'index');
+ expectMatch('pana', '0.12.2', 'license_file_class');
+ expectMatch('pana', '0.12.2', 'license_file_constructor');
+ expectMatch('pana', '0.12.2', 'license_file_name_field');
+ expectMatch('pana', '0.12.2', 'pretty_json');
+ });
- expectMatch('index');
- expectMatch('license_file_class');
- expectMatch('license_file_constructor');
- expectMatch('license_file_name_field');
- expectMatch('pretty_json');
+ group('Misc packages', () {
+ expectMatch('dygraph', '0.1.1', 'index');
});
}
diff --git a/app/test/dartdoc/golden/dygraph_0.1.1_index.html b/app/test/dartdoc/golden/dygraph_0.1.1_index.html
new file mode 100644
index 0000000000..695f52686a
--- /dev/null
+++ b/app/test/dartdoc/golden/dygraph_0.1.1_index.html
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+ dygraph - Dart API docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - dygraph package
+
+ dygraph
+
+
+
+
+
+
+
+
+
+ Dygraph (Dart)
+Dart JS interop for Dygraph v2+ - fast, flexible open source JavaScript charting library.
+Usage
+
+-
+
Register the Dart package in your pubspec.yaml
:
+ dependencies:
+ dygraph: ^0.1.0
+
+
+-
+
Load the latest Dygraph source (js and css) in your html layout:
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.css">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.js"></script>
+
+
+-
+
Create a Dygraph
instance:
+ import 'dart:html';
+
+ import 'package:dygraph/dygraph.dart';
+
+ void main() {
+ final el = document.getElementById('chart_container');
+
+ final options = DygraphOptions(
+ labels: ['Index', 'X', 'Y'],
+ colors: ['blue', 'red'],
+ );
+
+ final data = [
+ [1, 10, 100],
+ [2, 20, 80],
+ [3, 50, 60],
+ [4, 70, 80],
+ ];
+
+ Dygraph(el, data, options);
+ }
+
+
+
+
+Note 1: Dart DateTime objects need to be converted to native js dates by using dart:html_common
and convertDartToNative_DateTime()
.
+
+
+Note 2: When passing a Dart function as a callback, make sure to wrap it with allowInterop()
or allowInteropCaptureThis()
.
+
+Check the API reference for detailed documentation.
+To view the example, run pub global run webdev serve example
from the root directory of this project.
+
+
+
+ Libraries
+
+ -
+ dygraph
+
+ -
+ The JS interop library itself.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/test/dartdoc/golden/dygraph_0.1.1_index.latest.diff b/app/test/dartdoc/golden/dygraph_0.1.1_index.latest.diff
new file mode 100644
index 0000000000..6644402fb1
--- /dev/null
+++ b/app/test/dartdoc/golden/dygraph_0.1.1_index.latest.diff
@@ -0,0 +1,6 @@
+-
+-
+- dygraph package
++ dygraph package
+- dygraph package
++ dygraph package
diff --git a/app/test/dartdoc/golden/dygraph_0.1.1_index.out.html b/app/test/dartdoc/golden/dygraph_0.1.1_index.out.html
new file mode 100644
index 0000000000..babfa7e444
--- /dev/null
+++ b/app/test/dartdoc/golden/dygraph_0.1.1_index.out.html
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+
+
+
+
+ dygraph - Dart API docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dygraph (Dart)
+ Dart JS interop for
+ Dygraph v2+ - fast, flexible open source JavaScript charting library.
+
+ Usage
+
+ -
+
Register the Dart package in your
+ pubspec.yaml
:
+
+
+ dependencies:
+ dygraph: ^0.1.0
+
+
+
+ -
+
Load the latest Dygraph source (js and css) in your html layout:
+
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.css">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.js"></script>
+
+
+
+ -
+
Create a
+ Dygraph
instance:
+
+
+ import 'dart:html';
+
+ import 'package:dygraph/dygraph.dart';
+
+ void main() {
+ final el = document.getElementById('chart_container');
+
+ final options = DygraphOptions(
+ labels: ['Index', 'X', 'Y'],
+ colors: ['blue', 'red'],
+ );
+
+ final data = [
+ [1, 10, 100],
+ [2, 20, 80],
+ [3, 50, 60],
+ [4, 70, 80],
+ ];
+
+ Dygraph(el, data, options);
+ }
+
+
+
+
+
+
+ Note 1: Dart DateTime objects need to be converted to native js dates by using
+ dart:html_common
and
+ convertDartToNative_DateTime()
.
+
+
+
+
+ Note 2: When passing a Dart function as a callback, make sure to wrap it with
+ allowInterop()
or
+ allowInteropCaptureThis()
.
+
+
+ Check the
+ API reference for detailed documentation.
+
+ To view the example, run
+ pub global run webdev serve example
from the root directory of this project.
+
+
+
+ Libraries
+
+ -
+
+ dygraph
+
+
+ -
+ The JS interop library itself.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+