Skip to content

Commit 2d88c17

Browse files
authored
Fix issue #1401. (#1407)
* Fix for #1401 * dartfmt * version update * version update * Update comment
1 parent 4790d06 commit 2d88c17

File tree

98 files changed

+4228
-219
lines changed

Some content is hidden

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

98 files changed

+4228
-219
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/markdown_processor.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ MatchingLinkResult _getMatchingLinkElement(
293293
}
294294

295295
/// Given a set of commentRefs, return the one whose name matches the codeRef.
296-
Element _getRefElementFromCommentRefs(List<CommentReference> commentRefs, String codeRef) {
296+
Element _getRefElementFromCommentRefs(
297+
List<CommentReference> commentRefs, String codeRef) {
297298
for (CommentReference ref in commentRefs) {
298299
if (ref.identifier.name == codeRef) {
299-
bool isConstrElement =
300-
ref.identifier.staticElement is ConstructorElement;
300+
bool isConstrElement = ref.identifier.staticElement is ConstructorElement;
301301
// Constructors are now handled by library search.
302302
if (!isConstrElement) {
303303
return ref.identifier.staticElement;
@@ -338,7 +338,8 @@ Map<String, Set<ModelElement>> _findRefElementCache;
338338
// TODO(jcollins-g): Subcomponents of this function shouldn't be adding nulls to results, strip the
339339
// removes out that are gratuitous and debug the individual pieces.
340340
// TODO(jcollins-g): A complex package winds up spending a lot of cycles in here. Optimize.
341-
Element _findRefElementInLibrary(String codeRef, ModelElement element, List<CommentReference> commentRefs) {
341+
Element _findRefElementInLibrary(
342+
String codeRef, ModelElement element, List<CommentReference> commentRefs) {
342343
assert(element.package.allLibrariesAdded);
343344

344345
String codeRefChomped = codeRef.replaceFirst(isConstructor, '');

lib/src/model.dart

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

1043+
@override
1044+
String get documentation {
1045+
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
1046+
// to prevent displaying more or less than one summary.
1047+
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
1048+
assert(assertCheck.containsAll([true, false]));
1049+
return super.documentation;
1050+
}
1051+
10431052
String get constantValue {
10441053
if (_constantValue != null) return _constantValue;
10451054

@@ -1189,6 +1198,12 @@ abstract class GetterSetterCombo implements ModelElement {
11891198
return null;
11901199
}
11911200

1201+
@override
1202+
bool get canHaveParameters => hasSetter;
1203+
1204+
@override
1205+
List<Parameter> get parameters => setter.parameters;
1206+
11921207
@override
11931208
String get genericParameters {
11941209
if (hasSetter) return setter.genericParameters;
@@ -1204,15 +1219,15 @@ abstract class GetterSetterCombo implements ModelElement {
12041219
bool get hasExplicitGetter => hasGetter && !_getter.isSynthetic;
12051220

12061221
bool get hasExplicitSetter => hasSetter && !_setter.isSynthetic;
1222+
bool get hasImplicitSetter => hasSetter && _setter.isSynthetic;
1223+
12071224
bool get hasGetter;
12081225

12091226
bool get hasNoGetterSetter => !hasExplicitGetter && !hasExplicitSetter;
12101227

12111228
bool get hasSetter;
12121229

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

12171232
String get arrow {
12181233
// →
@@ -2115,6 +2130,10 @@ abstract class ModelElement
21152130

21162131
String get linkedParamsNoMetadata => linkedParams(showMetadata: false);
21172132

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

21202139
@override
@@ -3635,6 +3654,15 @@ class TopLevelVariable extends ModelElement
36353654

36363655
String get constantValueTruncated => truncateString(constantValue, 200);
36373656

3657+
@override
3658+
String get documentation {
3659+
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
3660+
// to prevent displaying more or less than one summary.
3661+
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
3662+
assert(assertCheck.containsAll([true, false]));
3663+
return super.documentation;
3664+
}
3665+
36383666
@override
36393667
ModelElement get enclosingElement => library;
36403668

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}}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dartdoc
22
# Also update the `version` field in lib/dartdoc.dart.
3-
version: 0.11.0
3+
version: 0.11.1
44
author: Dart Team <[email protected]>
55
description: A documentation generator for Dart.
66
homepage: https://github.com/dart-lang/dartdoc

testing/test_package/lib/fake.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,50 @@ 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+
@override
189+
set implicitGetterExplicitSetter(String x) {}
190+
191+
@override
192+
List<int> get explicitGetterImplicitSetter => new List<int>();
193+
194+
myCoolTypedef _aFunction;
195+
196+
myCoolTypedef get explicitGetterSetter {
197+
return _aFunction;
198+
}
199+
200+
/// This property is not synthetic, so it might reference [f] -- display it.
201+
set explicitGetterSetter(myCoolTypedef f) => _aFunction = f;
202+
203+
/// This property only has a getter and no setter; no parameters to print.
204+
myCoolTypedef get explicitGetter {
205+
return _aFunction;
206+
}
207+
208+
/// Set to [f], and don't warn about [bar] or [baz].
209+
set explicitSetter(f(int bar, Cool baz, List<int> macTruck)) {}
210+
211+
final Set finalProperty = new Set();
212+
213+
Map implicitReadWrite;
214+
215+
/// Hey there, more things not to warn about: [f], [x], or [q].
216+
String aMethod(Function f(Cool x, bool q)) {
217+
return 'hi';
218+
}
219+
}
220+
177221
/// This is a very long line spread
178222
/// across... wait for it... two physical lines.
179223
///

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>

0 commit comments

Comments
 (0)