Skip to content

Commit 3417bb1

Browse files
committed
fix issues with dispaying constants
1 parent ff194f4 commit 3417bb1

26 files changed

+85
-60
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
## 0.9.7+1
3+
* change how we truncate long constant values on the summary page
4+
* show the full docs for enums on the summary page; just show the first line of
5+
docs for other contants
6+
27
## 0.9.7
38
* fix the display of long constants
49
* fixed an issue with duplicate libraries in SDK

lib/dartdoc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export 'src/package_meta.dart';
4040

4141
const String name = 'dartdoc';
4242
// Update when pubspec version changes.
43-
const String version = '0.9.7';
43+
const String version = '0.9.7+1';
4444

4545
final String defaultOutDir = p.join('doc', 'api');
4646

lib/resources/styles.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,6 @@ dl dt.callable .name {
305305
color: #4674a2;
306306
}
307307

308-
/* make sure constant values don't overflow */
309-
.signature code {
310-
white-space: nowrap;
311-
overflow-x: hidden;
312-
text-overflow: ellipsis;
313-
display: block;
314-
}
315-
316308
.optional {
317309
font-style: italic;
318310
}

lib/src/markdown_processor.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ class Documentation {
189189

190190
if (pre.children.isNotEmpty && pre.children.first.localName == 'code') {
191191
var code = pre.children.first;
192-
pre.classes.addAll(code.classes.where((name) => name.startsWith('language-')));
192+
pre.classes
193+
.addAll(code.classes.where((name) => name.startsWith('language-')));
193194
}
194195

195196
bool specifiesLanguage = pre.classes.isNotEmpty;
@@ -203,6 +204,9 @@ class Documentation {
203204
var asOneLiner = asHtmlDocument.body.children.isEmpty
204205
? ''
205206
: asHtmlDocument.body.children.first.innerHtml;
207+
if (!asOneLiner.startsWith('<p>')) {
208+
asOneLiner = '<p>$asOneLiner</p>';
209+
}
206210
return new Documentation._(markdown, asHtml, asOneLiner);
207211
}
208212
}

lib/src/model.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import 'line_number_cache.dart';
2626
import 'markdown_processor.dart' show Documentation;
2727
import 'model_utils.dart';
2828
import 'package_meta.dart' show PackageMeta, FileContents;
29-
import 'utils.dart' show stripComments;
29+
import 'utils.dart';
3030

3131
Map<String, Map<String, List<Map<String, dynamic>>>> __crossdartJson;
3232

@@ -772,6 +772,9 @@ class EnumField extends Field {
772772
}
773773
}
774774

775+
@override
776+
String get oneLineDoc => documentationAsHtml;
777+
775778
@override
776779
String get href =>
777780
'${library.dirName}/${(enclosingElement as Class).fileName}';
@@ -809,6 +812,8 @@ class Field extends ModelElement
809812
return _constantValue;
810813
}
811814

815+
String get constantValueTruncated => truncateString(constantValue, 200);
816+
812817
@override
813818
ModelElement get enclosingElement {
814819
if (_enclosingClass == null) {
@@ -1531,7 +1536,6 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
15311536

15321537
String linkedParams(
15331538
{bool showMetadata: true, bool showNames: true, String separator: ', '}) {
1534-
15351539
String renderParam(Parameter param, String suffix) {
15361540
StringBuffer buf = new StringBuffer();
15371541
buf.write('<span class="parameter" id="${param.htmlId}">');
@@ -2165,6 +2169,8 @@ class TopLevelVariable extends ModelElement
21652169
return string.replaceAll(modelType.name, modelType.linkedName);
21662170
}
21672171

2172+
String get constantValueTruncated => truncateString(constantValue, 200);
2173+
21682174
@override
21692175
ModelElement get enclosingElement => library;
21702176

lib/src/utils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ String stripComments(String str) {
4141
}
4242
return buf.toString().trim();
4343
}
44+
45+
String truncateString(String str, int length) {
46+
if (str != null && str.length > length) {
47+
return str.substring(0, length) + '…';
48+
} else {
49+
return str;
50+
}
51+
}

lib/templates/_callable.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</span>
55
</dt>
66
<dd{{ #isInherited }} class="inherited"{{ /isInherited}}>
7-
<p>{{{ oneLineDoc }}}</p>
7+
{{{ oneLineDoc }}}
88
{{#isInherited}}
99
<div class="features">inherited</div>
1010
{{/isInherited}}

lib/templates/_constant.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<span class="signature">&#8594; {{{ linkedReturnType }}}</span>
44
</dt>
55
<dd>
6-
{{{ documentationAsHtml }}}
6+
{{{ oneLineDoc }}}
77
<div>
8-
<span class="signature"><code>{{{ constantValue }}}</code></span>
8+
<span class="signature"><code>{{{ constantValueTruncated }}}</code></span>
99
</div>
1010
</dd>

lib/templates/_property.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<span class="signature">&#8594; {{{ linkedReturnType }}}</span>
44
</dt>
55
<dd{{ #isInherited }} class="inherited"{{ /isInherited}}>
6-
<p>{{{ oneLineDoc }}}</p>
6+
{{{ oneLineDoc }}}
77
{{>readable_writable}}
88
</dd>

lib/templates/class.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ <h2>Constructors</h2>
114114
<span class="name">{{{linkedName}}}</span><span class="signature">({{{ linkedParams }}})</span>
115115
</dt>
116116
<dd>
117-
<p>{{{ oneLineDoc }}}</p>
117+
{{{ oneLineDoc }}}
118118
{{#isConst}}
119119
<div class="constructor-modifier features">const</div>
120120
{{/isConst}}

0 commit comments

Comments
 (0)