Skip to content

Commit 0504dcc

Browse files
committed
Fix for #1401
1 parent fca21f9 commit 0504dcc

File tree

95 files changed

+4220
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+4220
-213
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.11.1
2+
* Fix regression where a property or top level variable can be listed twice
3+
under some conditions. #1401
4+
15
## 0.11.0
26

37
* Fix resolution of ambiguous classes where the analyzer can help us. #1397

lib/dartdoc.dart

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

4545
const String name = 'dartdoc';
4646
// Update when pubspec version changes.
47-
const String version = '0.11.0';
47+
const String version = '0.11.1';
4848

4949
final String defaultOutDir = path.join('doc', 'api');
5050

lib/src/model.dart

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,14 @@ class Field extends ModelElement
10401040
assert(enclosingElement != definingEnclosingElement);
10411041
}
10421042

1043+
@override
1044+
String get documentation {
1045+
// Verify that we will show exactly one of the summaries.
1046+
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
1047+
assert(assertCheck.containsAll([true, false]));
1048+
return super.documentation;
1049+
}
1050+
10431051
String get constantValue {
10441052
if (_constantValue != null) return _constantValue;
10451053

@@ -1189,6 +1197,12 @@ abstract class GetterSetterCombo implements ModelElement {
11891197
return null;
11901198
}
11911199

1200+
@override
1201+
bool get canHaveParameters => hasSetter;
1202+
1203+
@override
1204+
List<Parameter> get parameters => setter.parameters;
1205+
11921206
@override
11931207
String get genericParameters {
11941208
if (hasSetter) return setter.genericParameters;
@@ -1204,15 +1218,15 @@ abstract class GetterSetterCombo implements ModelElement {
12041218
bool get hasExplicitGetter => hasGetter && !_getter.isSynthetic;
12051219

12061220
bool get hasExplicitSetter => hasSetter && !_setter.isSynthetic;
1221+
bool get hasImplicitSetter => hasSetter && _setter.isSynthetic;
1222+
12071223
bool get hasGetter;
12081224

12091225
bool get hasNoGetterSetter => !hasExplicitGetter && !hasExplicitSetter;
12101226

12111227
bool get hasSetter;
12121228

1213-
bool get hasGetterOrSetterWithoutParams {
1214-
return (hasGetter || (hasSetter && !hasExplicitSetter));
1215-
}
1229+
bool get hasGetterNoSetter => (hasGetter && !hasSetter);
12161230

12171231
String get arrow {
12181232
// →
@@ -2115,6 +2129,10 @@ abstract class ModelElement
21152129

21162130
String get linkedParamsNoMetadata => linkedParams(showMetadata: false);
21172131

2132+
String get linkedParamsNoMetadataOrNames {
2133+
return linkedParams(showMetadata: false, showNames: false);
2134+
}
2135+
21182136
ElementType get modelType => _modelType;
21192137

21202138
@override
@@ -3635,6 +3653,14 @@ class TopLevelVariable extends ModelElement
36353653

36363654
String get constantValueTruncated => truncateString(constantValue, 200);
36373655

3656+
@override
3657+
String get documentation {
3658+
// Verify that we will show exactly one of the summaries.
3659+
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
3660+
assert(assertCheck.containsAll([true, false]));
3661+
return super.documentation;
3662+
}
3663+
36383664
@override
36393665
ModelElement get enclosingElement => library;
36403666

lib/templates/_property.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{{ #hasExplicitSetter }}
1+
{{ #hasSetter }}
22
<dt id="{{htmlId}}" class="property{{ #isInherited }} inherited{{ /isInherited}}">
33
<span class="name{{#isDeprecated}} deprecated{{/isDeprecated}}">{{{linkedName}}}</span><span class="signature">{{{genericParameters}}}
4-
<span class="returntype parameter">{{{ arrow }}} {{{ linkedParamsNoMetadata }}}</span>
4+
<span class="returntype parameter">{{{ arrow }}} {{ #hasExplicitSetter }} {{{ linkedParamsNoMetadata }}} {{/hasExplicitSetter}} {{#hasImplicitSetter}} {{{linkedParamsNoMetadataOrNames}}} {{/hasImplicitSetter}}</span>
55
</span>
66
</dt>
7-
{{ /hasExplicitSetter }}
8-
{{ #hasGetterOrSetterWithoutParams }}
7+
{{ /hasSetter }}
8+
{{ #hasGetterNoSetter }}
99
<dt id="{{htmlId}}" class="property{{ #isInherited }} inherited{{ /isInherited}}">
1010
<span class="name">{{{linkedName}}}</span>
1111
<span class="signature">{{{ arrow }}} {{{ linkedReturnType }}}</span>
1212
</dt>
13-
{{ /hasGetterOrSetterWithoutParams }}
13+
{{ /hasGetterNoSetter }}
1414
<dd{{ #isInherited }} class="inherited"{{ /isInherited}}>
1515
{{{ oneLineDoc }}}
1616
{{>features}}

testing/test_package/lib/fake.dart

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,51 @@ class SuperAwesomeClass {
174174
}
175175
}
176176

177+
typedef void myCoolTypedef(Cool x, bool y);
178+
179+
/// Names are actually wrong in this class, but when we extend it,
180+
/// they are correct.
181+
class ImplicitProperties {
182+
String implicitGetterExplicitSetter;
183+
List<int> explicitGetterImplicitSetter;
184+
}
185+
186+
/// Classes with unusual properties? I don't think they exist.
187+
class ClassWithUnusualProperties extends ImplicitProperties {
188+
189+
@override
190+
set implicitGetterExplicitSetter(String x) {}
191+
192+
@override
193+
List<int> get explicitGetterImplicitSetter => new List<int>();
194+
195+
myCoolTypedef _aFunction;
196+
197+
myCoolTypedef get explicitGetterSetter {
198+
return _aFunction;
199+
}
200+
201+
/// This property is not synthetic, so it might reference [f] -- display it.
202+
set explicitGetterSetter(myCoolTypedef f) => _aFunction = f;
203+
204+
/// This property only has a getter and no setter; no parameters to print.
205+
myCoolTypedef get explicitGetter {
206+
return _aFunction;
207+
}
208+
209+
/// Set to [f], and don't warn about [bar] or [baz].
210+
set explicitSetter(f(int bar, Cool baz, List<int> macTruck)) {}
211+
212+
final Set finalProperty = new Set();
213+
214+
Map implicitReadWrite;
215+
216+
/// Hey there, more things not to warn about: [f], [x], or [q].
217+
String aMethod(Function f(Cool x, bool q)) {
218+
return 'hi';
219+
}
220+
}
221+
177222
/// This is a very long line spread
178223
/// across... wait for it... two physical lines.
179224
///

testing/test_package_docs/css/css-library.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ <h2>Properties</h2>
9696

9797
<dl class="properties">
9898
<dt id="theOnlyThingInTheLibrary" class="property">
99-
<span class="name"><a href="css/theOnlyThingInTheLibrary.html">theOnlyThingInTheLibrary</a></span>
100-
<span class="signature">&#8596; String</span>
99+
<span class="name"><a href="css/theOnlyThingInTheLibrary.html">theOnlyThingInTheLibrary</a></span><span class="signature">
100+
<span class="returntype parameter">&#8596; <span class="parameter" id="theOnlyThingInTheLibrary=-param-_theOnlyThingInTheLibrary"><span class="type-annotation">String</span> </span> </span>
101+
</span>
101102
</dt>
102103
<dd>
103104
<p></p>

testing/test_package_docs/ex/Apple-class.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,19 @@ <h2>Properties</h2>
190190
<div class="features">final</div>
191191
</dd>
192192
<dt id="m" class="property">
193-
<span class="name"><a href="ex/Apple/m.html">m</a></span>
194-
<span class="signature">&#8596; int</span>
193+
<span class="name"><a href="ex/Apple/m.html">m</a></span><span class="signature">
194+
<span class="returntype parameter">&#8596; <span class="parameter" id="m=-param-_m"><span class="type-annotation">int</span> </span> </span>
195+
</span>
195196
</dt>
196197
<dd>
197198
<p>The read-write field <code>m</code>.</p>
198199
<div class="features">read / write</div>
199200
</dd>
200201
<dt id="s" class="property">
201202
<span class="name"><a href="ex/Apple/s.html">s</a></span><span class="signature">
202-
<span class="returntype parameter">&#8596; <span class="parameter" id="s=-param-something"><span class="type-annotation">String</span> <span class="parameter-name">something</span></span></span>
203+
<span class="returntype parameter">&#8596; <span class="parameter" id="s=-param-something"><span class="type-annotation">String</span> <span class="parameter-name">something</span></span> </span>
203204
</span>
204205
</dt>
205-
<dt id="s" class="property">
206-
<span class="name"><a href="ex/Apple/s.html">s</a></span>
207-
<span class="signature">&#8596; String</span>
208-
</dt>
209206
<dd>
210207
<p>The getter for <code>s</code></p>
211208
<div class="features">read / write</div>
@@ -336,8 +333,9 @@ <h2>Static Properties</h2>
336333

337334
<dl class="properties">
338335
<dt id="string" class="property">
339-
<span class="name"><a href="ex/Apple/string.html">string</a></span>
340-
<span class="signature">&#8596; String</span>
336+
<span class="name"><a href="ex/Apple/string.html">string</a></span><span class="signature">
337+
<span class="returntype parameter">&#8596; <span class="parameter" id="string=-param-_string"><span class="type-annotation">String</span> </span> </span>
338+
</span>
341339
</dt>
342340
<dd>
343341
<p></p>

testing/test_package_docs/ex/B-class.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ <h2>Properties</h2>
179179

180180
<dl class="properties">
181181
<dt id="autoCompress" class="property">
182-
<span class="name"><a href="ex/B/autoCompress.html">autoCompress</a></span>
183-
<span class="signature">&#8596; bool</span>
182+
<span class="name"><a href="ex/B/autoCompress.html">autoCompress</a></span><span class="signature">
183+
<span class="returntype parameter">&#8596; <span class="parameter" id="autoCompress=-param-_autoCompress"><span class="type-annotation">bool</span> </span> </span>
184+
</span>
184185
</dt>
185186
<dd>
186187
<p>The default value is <code>false</code> (compression disabled).
@@ -196,8 +197,9 @@ <h2>Properties</h2>
196197
<div class="features">@override, read-only</div>
197198
</dd>
198199
<dt id="list" class="property">
199-
<span class="name"><a href="ex/B/list.html">list</a></span>
200-
<span class="signature">&#8596; List&lt;String&gt;</span>
200+
<span class="name"><a href="ex/B/list.html">list</a></span><span class="signature">
201+
<span class="returntype parameter">&#8596; <span class="parameter" id="list=-param-_list"><span class="type-annotation">List&lt;String&gt;</span> </span> </span>
202+
</span>
201203
</dt>
202204
<dd>
203205
<p>A list of Strings</p>
@@ -228,8 +230,9 @@ <h2>Properties</h2>
228230
<div class="features">read-only, inherited</div>
229231
</dd>
230232
<dt id="m" class="property inherited">
231-
<span class="name"><a href="ex/Apple/m.html">m</a></span>
232-
<span class="signature">&#8596; int</span>
233+
<span class="name"><a href="ex/Apple/m.html">m</a></span><span class="signature">
234+
<span class="returntype parameter">&#8596; <span class="parameter" id="m=-param-_m"><span class="type-annotation">int</span> </span> </span>
235+
</span>
233236
</dt>
234237
<dd class="inherited">
235238
<p>The read-write field <code>m</code>.</p>

testing/test_package_docs/ex/Dog-class.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ <h2>Properties</h2>
219219
<div class="features">@protected, final</div>
220220
</dd>
221221
<dt id="deprecatedField" class="property">
222-
<span class="name"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span>
223-
<span class="signature">&#8596; int</span>
222+
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span><span class="signature">
223+
<span class="returntype parameter">&#8596; <span class="parameter" id="deprecatedField=-param-_deprecatedField"><span class="type-annotation">int</span> </span> </span>
224+
</span>
224225
</dt>
225226
<dd>
226227
<p></p>
@@ -236,7 +237,7 @@ <h2>Properties</h2>
236237
</dd>
237238
<dt id="deprecatedSetter" class="property">
238239
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedSetter.html">deprecatedSetter</a></span><span class="signature">
239-
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span></span>
240+
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span> </span>
240241
</span>
241242
</dt>
242243
<dd>
@@ -252,8 +253,9 @@ <h2>Properties</h2>
252253
<div class="features">@override, read-only</div>
253254
</dd>
254255
<dt id="name" class="property">
255-
<span class="name"><a href="ex/Dog/name.html">name</a></span>
256-
<span class="signature">&#8596; String</span>
256+
<span class="name"><a href="ex/Dog/name.html">name</a></span><span class="signature">
257+
<span class="returntype parameter">&#8596; <span class="parameter" id="name=-param-_name"><span class="type-annotation">String</span> </span> </span>
258+
</span>
257259
</dt>
258260
<dd>
259261
<p></p>
@@ -412,13 +414,9 @@ <h2>Static Properties</h2>
412414
</dd>
413415
<dt id="staticGetterSetter" class="property">
414416
<span class="name"><a href="ex/Dog/staticGetterSetter.html">staticGetterSetter</a></span><span class="signature">
415-
<span class="returntype parameter">&#8596; <span class="parameter" id="staticGetterSetter=-param-x"><span class="parameter-name">x</span></span></span>
417+
<span class="returntype parameter">&#8596; <span class="parameter" id="staticGetterSetter=-param-x"><span class="parameter-name">x</span></span> </span>
416418
</span>
417419
</dt>
418-
<dt id="staticGetterSetter" class="property">
419-
<span class="name"><a href="ex/Dog/staticGetterSetter.html">staticGetterSetter</a></span>
420-
<span class="signature">&#8596; int</span>
421-
</dt>
422420
<dd>
423421
<p></p>
424422
<div class="features">read / write</div>

testing/test_package_docs/ex/F-class.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ <h2>Properties</h2>
194194
<div class="features">@protected, final, inherited</div>
195195
</dd>
196196
<dt id="deprecatedField" class="property inherited">
197-
<span class="name"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span>
198-
<span class="signature">&#8596; int</span>
197+
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span><span class="signature">
198+
<span class="returntype parameter">&#8596; <span class="parameter" id="deprecatedField=-param-_deprecatedField"><span class="type-annotation">int</span> </span> </span>
199+
</span>
199200
</dt>
200201
<dd class="inherited">
201202
<p></p>
@@ -211,7 +212,7 @@ <h2>Properties</h2>
211212
</dd>
212213
<dt id="deprecatedSetter" class="property inherited">
213214
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedSetter.html">deprecatedSetter</a></span><span class="signature">
214-
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span></span>
215+
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span> </span>
215216
</span>
216217
</dt>
217218
<dd class="inherited">
@@ -235,8 +236,9 @@ <h2>Properties</h2>
235236
<div class="features">@override, read-only, inherited</div>
236237
</dd>
237238
<dt id="name" class="property inherited">
238-
<span class="name"><a href="ex/Dog/name.html">name</a></span>
239-
<span class="signature">&#8596; String</span>
239+
<span class="name"><a href="ex/Dog/name.html">name</a></span><span class="signature">
240+
<span class="returntype parameter">&#8596; <span class="parameter" id="name=-param-_name"><span class="type-annotation">String</span> </span> </span>
241+
</span>
240242
</dt>
241243
<dd class="inherited">
242244
<p></p>

testing/test_package_docs/ex/WithGeneric-class.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ <h2>Properties</h2>
168168

169169
<dl class="properties">
170170
<dt id="prop" class="property">
171-
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span>
172-
<span class="signature">&#8596; T</span>
171+
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span><span class="signature">
172+
<span class="returntype parameter">&#8596; <span class="parameter" id="prop=-param-_prop"><span class="type-annotation">T</span> </span> </span>
173+
</span>
173174
</dt>
174175
<dd>
175176
<p></p>

testing/test_package_docs/ex/WithGenericSub-class.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ <h2>Properties</h2>
178178
<div class="features">read-only, inherited</div>
179179
</dd>
180180
<dt id="prop" class="property inherited">
181-
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span>
182-
<span class="signature">&#8596; T</span>
181+
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span><span class="signature">
182+
<span class="returntype parameter">&#8596; <span class="parameter" id="prop=-param-_prop"><span class="type-annotation">T</span> </span> </span>
183+
</span>
183184
</dt>
184185
<dd class="inherited">
185186
<p></p>

testing/test_package_docs/ex/ex-library.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ <h2>Properties</h2>
341341

342342
<dl class="properties">
343343
<dt id="deprecatedField" class="property">
344-
<span class="name"><a class="deprecated" href="ex/deprecatedField.html">deprecatedField</a></span>
345-
<span class="signature">&#8596; int</span>
344+
<span class="name deprecated"><a class="deprecated" href="ex/deprecatedField.html">deprecatedField</a></span><span class="signature">
345+
<span class="returntype parameter">&#8596; <span class="parameter" id="deprecatedField=-param-_deprecatedField"><span class="type-annotation">int</span> </span> </span>
346+
</span>
346347
</dt>
347348
<dd>
348349
<p></p>
@@ -358,16 +359,17 @@ <h2>Properties</h2>
358359
</dd>
359360
<dt id="deprecatedSetter" class="property">
360361
<span class="name deprecated"><a class="deprecated" href="ex/deprecatedSetter.html">deprecatedSetter</a></span><span class="signature">
361-
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span></span>
362+
<span class="returntype parameter">&#8592; <span class="parameter" id="deprecatedSetter=-param-value"><span class="type-annotation">int</span> <span class="parameter-name">value</span></span> </span>
362363
</span>
363364
</dt>
364365
<dd>
365366
<p></p>
366367
<div class="features">write-only</div>
367368
</dd>
368369
<dt id="number" class="property">
369-
<span class="name"><a href="ex/number.html">number</a></span>
370-
<span class="signature">&#8596; double</span>
370+
<span class="name"><a href="ex/number.html">number</a></span><span class="signature">
371+
<span class="returntype parameter">&#8596; <span class="parameter" id="number=-param-_number"><span class="type-annotation">double</span> </span> </span>
372+
</span>
371373
</dt>
372374
<dd>
373375
<p></p>

0 commit comments

Comments
 (0)