Skip to content

Commit a09867b

Browse files
committed
tweak code fonts
Closes #798 Squashed commit of the following: commit ab6ef84 Author: Seth Ladd <[email protected]> Date: Sat Aug 8 08:27:55 2015 -0700 fix tests commit 38895dd Author: Seth Ladd <[email protected]> Date: Sat Aug 8 08:17:54 2015 -0700 remove commented code commit 5aebd24 Author: Seth Ladd <[email protected]> Date: Sat Aug 8 08:17:32 2015 -0700 tweak code fonts
1 parent ee64586 commit a09867b

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

lib/markdown_processor.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Documentation {
6969
String tempHtml = renderMarkdownToHtml(raw, element);
7070
_asHtmlDocument = parse(tempHtml);
7171
_asHtmlDocument.querySelectorAll('script').forEach((s) => s.remove());
72-
_asHtmlDocument.querySelectorAll('code').forEach((e) {
72+
_asHtmlDocument.querySelectorAll('pre').forEach((e) {
7373
e.classes.addAll(['prettyprint', 'lang-dart']);
7474
});
7575
_asHtml = _asHtmlDocument.body.innerHtml;
@@ -98,9 +98,6 @@ class _InlineCodeSyntax extends md.InlineSyntax {
9898
@override
9999
bool onMatch(md.InlineParser parser, Match match) {
100100
var element = new md.Element.text('code', htmlEscape(match[1]));
101-
var c = element.attributes.putIfAbsent("class", () => "");
102-
c = (c.isEmpty ? "" : " ") + "prettyprint";
103-
element.attributes["class"] = c;
104101
parser.addNode(element);
105102
return true;
106103
}
@@ -124,7 +121,9 @@ NodeList<CommentReference> _getCommentRefs(ModelElement modelElement) {
124121
if (modelElement.element.node is AnnotatedNode) {
125122
if ((modelElement.element.node as AnnotatedNode).documentationComment !=
126123
null) {
127-
return (modelElement.element.node as AnnotatedNode).documentationComment.references;
124+
return (modelElement.element.node as AnnotatedNode)
125+
.documentationComment
126+
.references;
128127
}
129128
} else if (modelElement.element is LibraryElement) {
130129
// handle anonymous libraries

lib/resources/styles.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ a, a:hover {
122122
color: #1976D2;
123123
}
124124

125-
pre {
125+
pre.prettyprint {
126126
font-family: 'Source Code Pro', monospace;
127127
color: black;
128128
border-radius: 4px;
@@ -146,11 +146,8 @@ pre code {
146146
code {
147147
font-family: 'Source Code Pro', monospace;
148148
/* overriding bootstrap */
149-
font-size: 15px;
150149
color: inherit;
151-
border-radius: 0;
152-
padding: 0;
153-
background-color: inherit;
150+
background-color: #f7f7f7;
154151
}
155152

156153
@media(max-width: 768px) {

test/model_test.dart

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,11 @@ void main() {
225225
});
226226

227227
test('codeifies a class from the SDK', () {
228-
expect(docsAsHtml,
229-
contains('<code class="prettyprint lang-dart">String</code>'));
228+
expect(docsAsHtml, contains('<code>String</code>'));
230229
});
231230

232231
test('codeifies a reference to its parameter', () {
233-
expect(docsAsHtml,
234-
contains('<code class="prettyprint lang-dart">value</code>'));
232+
expect(docsAsHtml, contains('<code>value</code>'));
235233
});
236234

237235
test('links to a reference to its class', () {
@@ -292,9 +290,7 @@ void main() {
292290
// track when the behavior changes
293291
test('codeifies a prefixed top-level variable an imported lib', () {
294292
expect(
295-
docsAsHtml,
296-
contains(
297-
'<code class="prettyprint lang-dart">css.theOnlyThingInTheLibrary</code>'));
293+
docsAsHtml, contains('<code>css.theOnlyThingInTheLibrary</code>'));
298294
});
299295

300296
test('links to a name with a single underscore', () {
@@ -325,7 +321,7 @@ void main() {
325321
expect(
326322
add.oneLineDoc,
327323
equals(
328-
'Adds <code class="prettyprint lang-dart">value</code> to the end of this list,\nextending the length by one.'));
324+
'Adds <code>value</code> to the end of this list,\nextending the length by one.'));
329325
});
330326

331327
test(
@@ -336,17 +332,17 @@ void main() {
336332
expect(
337333
add.documentationAsHtml,
338334
startsWith(
339-
'<p>Adds <code class="prettyprint lang-dart">value</code> to the end of this list,\nextending the length by one.'));
335+
'<p>Adds <code>value</code> to the end of this list,\nextending the length by one.'));
340336
});
341337

342338
test('incorrect doc references are still wrapped in code blocks', () {
343339
expect(incorrectReference.documentationAsHtml,
344-
'<p>This should <code class="prettyprint lang-dart">not work</code>.</p>');
340+
'<p>This should <code>not work</code>.</p>');
345341
});
346342

347343
test('no references', () {
348-
expect(Apple.documentationAsHtml,
349-
'<p>Sample class <code class="prettyprint lang-dart">String</code></p>');
344+
expect(
345+
Apple.documentationAsHtml, '<p>Sample class <code>String</code></p>');
350346
});
351347

352348
test('single ref to class', () {
@@ -358,7 +354,7 @@ void main() {
358354
expect(
359355
thisIsAsync.documentationAsHtml,
360356
equals(
361-
'<p>An async function. It should look like I return a <code class="prettyprint lang-dart">Future</code>.</p>'));
357+
'<p>An async function. It should look like I return a <code>Future</code>.</p>'));
362358
});
363359

364360
test('references are correct in exported libraries', () {
@@ -368,10 +364,7 @@ void main() {
368364
expect(resolved, isNotNull);
369365
expect(resolved,
370366
contains('<a href="two_exports/BaseClass-class.html">BaseClass</a>'));
371-
expect(
372-
resolved,
373-
contains(
374-
'linking over to <code class="prettyprint lang-dart">Apple</code>.'));
367+
expect(resolved, contains('linking over to <code>Apple</code>.'));
375368
});
376369

377370
test('references to class and constructors', () {
@@ -403,16 +396,14 @@ void main() {
403396
expect(
404397
testingCodeSyntaxInOneLiners.oneLineDoc,
405398
equals(
406-
'These are code syntaxes: <code class="prettyprint lang-dart">true</code> and <code class="prettyprint lang-dart">false</code>'));
399+
'These are code syntaxes: <code>true</code> and <code>false</code>'));
407400
});
408401

409402
test('doc comments to parameters are marked as code', () {
410403
Method localMethod = subForDocComments.instanceMethods
411404
.firstWhere((m) => m.name == 'localMethod');
412-
expect(localMethod.documentationAsHtml,
413-
contains('<code class="prettyprint lang-dart">foo</code>'));
414-
expect(localMethod.documentationAsHtml,
415-
contains('<code class="prettyprint lang-dart">bar</code>'));
405+
expect(localMethod.documentationAsHtml, contains('<code>foo</code>'));
406+
expect(localMethod.documentationAsHtml, contains('<code>bar</code>'));
416407
});
417408
});
418409

@@ -668,7 +659,7 @@ void main() {
668659
expect(
669660
thisIsAsync.documentationAsHtml,
670661
equals(
671-
'<p>An async function. It should look like I return a <code class="prettyprint lang-dart">Future</code>.</p>'));
662+
'<p>An async function. It should look like I return a <code>Future</code>.</p>'));
672663
});
673664

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

0 commit comments

Comments
 (0)