diff --git a/lib/markdown_processor.dart b/lib/markdown_processor.dart index 3143cc5f5c..7a595ad735 100644 --- a/lib/markdown_processor.dart +++ b/lib/markdown_processor.dart @@ -69,7 +69,7 @@ class Documentation { String tempHtml = renderMarkdownToHtml(raw, element); _asHtmlDocument = parse(tempHtml); _asHtmlDocument.querySelectorAll('script').forEach((s) => s.remove()); - _asHtmlDocument.querySelectorAll('code').forEach((e) { + _asHtmlDocument.querySelectorAll('pre').forEach((e) { e.classes.addAll(['prettyprint', 'lang-dart']); }); _asHtml = _asHtmlDocument.body.innerHtml; @@ -98,9 +98,6 @@ class _InlineCodeSyntax extends md.InlineSyntax { @override bool onMatch(md.InlineParser parser, Match match) { var element = new md.Element.text('code', htmlEscape(match[1])); - var c = element.attributes.putIfAbsent("class", () => ""); - c = (c.isEmpty ? "" : " ") + "prettyprint"; - element.attributes["class"] = c; parser.addNode(element); return true; } @@ -124,7 +121,9 @@ NodeList _getCommentRefs(ModelElement modelElement) { if (modelElement.element.node is AnnotatedNode) { if ((modelElement.element.node as AnnotatedNode).documentationComment != null) { - return (modelElement.element.node as AnnotatedNode).documentationComment.references; + return (modelElement.element.node as AnnotatedNode) + .documentationComment + .references; } } else if (modelElement.element is LibraryElement) { // handle anonymous libraries diff --git a/lib/resources/styles.css b/lib/resources/styles.css index a974aefb7a..d0be3de656 100644 --- a/lib/resources/styles.css +++ b/lib/resources/styles.css @@ -122,7 +122,7 @@ a, a:hover { color: #1976D2; } -pre { +pre.prettyprint { font-family: 'Source Code Pro', monospace; color: black; border-radius: 4px; @@ -146,11 +146,8 @@ pre code { code { font-family: 'Source Code Pro', monospace; /* overriding bootstrap */ - font-size: 15px; color: inherit; - border-radius: 0; - padding: 0; - background-color: inherit; + background-color: #f7f7f7; } @media(max-width: 768px) { diff --git a/test/model_test.dart b/test/model_test.dart index cb88835062..c44efa3888 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -225,13 +225,11 @@ void main() { }); test('codeifies a class from the SDK', () { - expect(docsAsHtml, - contains('String')); + expect(docsAsHtml, contains('String')); }); test('codeifies a reference to its parameter', () { - expect(docsAsHtml, - contains('value')); + expect(docsAsHtml, contains('value')); }); test('links to a reference to its class', () { @@ -292,9 +290,7 @@ void main() { // track when the behavior changes test('codeifies a prefixed top-level variable an imported lib', () { expect( - docsAsHtml, - contains( - 'css.theOnlyThingInTheLibrary')); + docsAsHtml, contains('css.theOnlyThingInTheLibrary')); }); test('links to a name with a single underscore', () { @@ -325,7 +321,7 @@ void main() { expect( add.oneLineDoc, equals( - 'Adds value to the end of this list,\nextending the length by one.')); + 'Adds value to the end of this list,\nextending the length by one.')); }); test( @@ -336,17 +332,17 @@ void main() { expect( add.documentationAsHtml, startsWith( - '

Adds value to the end of this list,\nextending the length by one.')); + '

Adds value to the end of this list,\nextending the length by one.')); }); test('incorrect doc references are still wrapped in code blocks', () { expect(incorrectReference.documentationAsHtml, - '

This should not work.

'); + '

This should not work.

'); }); test('no references', () { - expect(Apple.documentationAsHtml, - '

Sample class String

'); + expect( + Apple.documentationAsHtml, '

Sample class String

'); }); test('single ref to class', () { @@ -358,7 +354,7 @@ void main() { expect( thisIsAsync.documentationAsHtml, equals( - '

An async function. It should look like I return a Future.

')); + '

An async function. It should look like I return a Future.

')); }); test('references are correct in exported libraries', () { @@ -368,10 +364,7 @@ void main() { expect(resolved, isNotNull); expect(resolved, contains('BaseClass')); - expect( - resolved, - contains( - 'linking over to Apple.')); + expect(resolved, contains('linking over to Apple.')); }); test('references to class and constructors', () { @@ -403,16 +396,14 @@ void main() { expect( testingCodeSyntaxInOneLiners.oneLineDoc, equals( - 'These are code syntaxes: true and false')); + 'These are code syntaxes: true and false')); }); test('doc comments to parameters are marked as code', () { Method localMethod = subForDocComments.instanceMethods .firstWhere((m) => m.name == 'localMethod'); - expect(localMethod.documentationAsHtml, - contains('foo')); - expect(localMethod.documentationAsHtml, - contains('bar')); + expect(localMethod.documentationAsHtml, contains('foo')); + expect(localMethod.documentationAsHtml, contains('bar')); }); }); @@ -668,7 +659,7 @@ void main() { expect( thisIsAsync.documentationAsHtml, equals( - '

An async function. It should look like I return a Future.

')); + '

An async function. It should look like I return a Future.

')); }); test('docs do not lose brackets in code blocks', () {