Skip to content

Fix issue #1401. #1407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.1
* Fix regression where a property or top level variable can be listed twice
under some conditions. #1401

## 0.11.0

* Fix resolution of ambiguous classes where the analyzer can help us. #1397
Expand Down
2 changes: 1 addition & 1 deletion lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export 'src/sdk.dart';

const String name = 'dartdoc';
// Update when pubspec version changes.
const String version = '0.11.0';
const String version = '0.11.1';

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

Expand Down
9 changes: 5 additions & 4 deletions lib/src/markdown_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ MatchingLinkResult _getMatchingLinkElement(
}

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

String codeRefChomped = codeRef.replaceFirst(isConstructor, '');
Expand Down
34 changes: 31 additions & 3 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,15 @@ class Field extends ModelElement
assert(enclosingElement != definingEnclosingElement);
}

@override
String get documentation {
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
// to prevent displaying more or less than one summary.
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
assert(assertCheck.containsAll([true, false]));
return super.documentation;
}

String get constantValue {
if (_constantValue != null) return _constantValue;

Expand Down Expand Up @@ -1189,6 +1198,12 @@ abstract class GetterSetterCombo implements ModelElement {
return null;
}

@override
bool get canHaveParameters => hasSetter;

@override
List<Parameter> get parameters => setter.parameters;

@override
String get genericParameters {
if (hasSetter) return setter.genericParameters;
Expand All @@ -1204,15 +1219,15 @@ abstract class GetterSetterCombo implements ModelElement {
bool get hasExplicitGetter => hasGetter && !_getter.isSynthetic;

bool get hasExplicitSetter => hasSetter && !_setter.isSynthetic;
bool get hasImplicitSetter => hasSetter && _setter.isSynthetic;

bool get hasGetter;

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

bool get hasSetter;

bool get hasGetterOrSetterWithoutParams {
return (hasGetter || (hasSetter && !hasExplicitSetter));
}
bool get hasGetterNoSetter => (hasGetter && !hasSetter);

String get arrow {
// →
Expand Down Expand Up @@ -2115,6 +2130,10 @@ abstract class ModelElement

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

String get linkedParamsNoMetadataOrNames {
return linkedParams(showMetadata: false, showNames: false);
}

ElementType get modelType => _modelType;

@override
Expand Down Expand Up @@ -3635,6 +3654,15 @@ class TopLevelVariable extends ModelElement

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

@override
String get documentation {
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
// to prevent displaying more or less than one summary.
Set<bool> assertCheck = new Set()..addAll([hasSetter, hasGetterNoSetter]);
assert(assertCheck.containsAll([true, false]));
return super.documentation;
}

@override
ModelElement get enclosingElement => library;

Expand Down
10 changes: 5 additions & 5 deletions lib/templates/_property.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{{ #hasExplicitSetter }}
{{ #hasSetter }}
<dt id="{{htmlId}}" class="property{{ #isInherited }} inherited{{ /isInherited}}">
<span class="name{{#isDeprecated}} deprecated{{/isDeprecated}}">{{{linkedName}}}</span><span class="signature">{{{genericParameters}}}
<span class="returntype parameter">{{{ arrow }}} {{{ linkedParamsNoMetadata }}}</span>
<span class="returntype parameter">{{{ arrow }}} {{ #hasExplicitSetter }} {{{ linkedParamsNoMetadata }}} {{/hasExplicitSetter}} {{#hasImplicitSetter}} {{{linkedParamsNoMetadataOrNames}}} {{/hasImplicitSetter}}</span>
</span>
</dt>
{{ /hasExplicitSetter }}
{{ #hasGetterOrSetterWithoutParams }}
{{ /hasSetter }}
{{ #hasGetterNoSetter }}
<dt id="{{htmlId}}" class="property{{ #isInherited }} inherited{{ /isInherited}}">
<span class="name">{{{linkedName}}}</span>
<span class="signature">{{{ arrow }}} {{{ linkedReturnType }}}</span>
</dt>
{{ /hasGetterOrSetterWithoutParams }}
{{ /hasGetterNoSetter }}
<dd{{ #isInherited }} class="inherited"{{ /isInherited}}>
{{{ oneLineDoc }}}
{{>features}}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dartdoc
# Also update the `version` field in lib/dartdoc.dart.
version: 0.11.0
version: 0.11.1
author: Dart Team <[email protected]>
description: A documentation generator for Dart.
homepage: https://github.com/dart-lang/dartdoc
Expand Down
44 changes: 44 additions & 0 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,50 @@ class SuperAwesomeClass {
}
}

typedef void myCoolTypedef(Cool x, bool y);

/// Names are actually wrong in this class, but when we extend it,
/// they are correct.
class ImplicitProperties {
String implicitGetterExplicitSetter;
List<int> explicitGetterImplicitSetter;
}

/// Classes with unusual properties? I don't think they exist.
class ClassWithUnusualProperties extends ImplicitProperties {
@override
set implicitGetterExplicitSetter(String x) {}

@override
List<int> get explicitGetterImplicitSetter => new List<int>();

myCoolTypedef _aFunction;

myCoolTypedef get explicitGetterSetter {
return _aFunction;
}

/// This property is not synthetic, so it might reference [f] -- display it.
set explicitGetterSetter(myCoolTypedef f) => _aFunction = f;

/// This property only has a getter and no setter; no parameters to print.
myCoolTypedef get explicitGetter {
return _aFunction;
}

/// Set to [f], and don't warn about [bar] or [baz].
set explicitSetter(f(int bar, Cool baz, List<int> macTruck)) {}

final Set finalProperty = new Set();

Map implicitReadWrite;

/// Hey there, more things not to warn about: [f], [x], or [q].
String aMethod(Function f(Cool x, bool q)) {
return 'hi';
}
}

/// This is a very long line spread
/// across... wait for it... two physical lines.
///
Expand Down
5 changes: 3 additions & 2 deletions testing/test_package_docs/css/css-library.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ <h2>Properties</h2>

<dl class="properties">
<dt id="theOnlyThingInTheLibrary" class="property">
<span class="name"><a href="css/theOnlyThingInTheLibrary.html">theOnlyThingInTheLibrary</a></span>
<span class="signature">&#8596; String</span>
<span class="name"><a href="css/theOnlyThingInTheLibrary.html">theOnlyThingInTheLibrary</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="theOnlyThingInTheLibrary=-param-_theOnlyThingInTheLibrary"><span class="type-annotation">String</span> </span> </span>
</span>
</dt>
<dd>
<p></p>
Expand Down
16 changes: 7 additions & 9 deletions testing/test_package_docs/ex/Apple-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,19 @@ <h2>Properties</h2>
<div class="features">final</div>
</dd>
<dt id="m" class="property">
<span class="name"><a href="ex/Apple/m.html">m</a></span>
<span class="signature">&#8596; int</span>
<span class="name"><a href="ex/Apple/m.html">m</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="m=-param-_m"><span class="type-annotation">int</span> </span> </span>
</span>
</dt>
<dd>
<p>The read-write field <code>m</code>.</p>
<div class="features">read / write</div>
</dd>
<dt id="s" class="property">
<span class="name"><a href="ex/Apple/s.html">s</a></span><span class="signature">
<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>
<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>
</span>
</dt>
<dt id="s" class="property">
<span class="name"><a href="ex/Apple/s.html">s</a></span>
<span class="signature">&#8596; String</span>
</dt>
<dd>
<p>The getter for <code>s</code></p>
<div class="features">read / write</div>
Expand Down Expand Up @@ -336,8 +333,9 @@ <h2>Static Properties</h2>

<dl class="properties">
<dt id="string" class="property">
<span class="name"><a href="ex/Apple/string.html">string</a></span>
<span class="signature">&#8596; String</span>
<span class="name"><a href="ex/Apple/string.html">string</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="string=-param-_string"><span class="type-annotation">String</span> </span> </span>
</span>
</dt>
<dd>
<p></p>
Expand Down
15 changes: 9 additions & 6 deletions testing/test_package_docs/ex/B-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ <h2>Properties</h2>

<dl class="properties">
<dt id="autoCompress" class="property">
<span class="name"><a href="ex/B/autoCompress.html">autoCompress</a></span>
<span class="signature">&#8596; bool</span>
<span class="name"><a href="ex/B/autoCompress.html">autoCompress</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="autoCompress=-param-_autoCompress"><span class="type-annotation">bool</span> </span> </span>
</span>
</dt>
<dd>
<p>The default value is <code>false</code> (compression disabled).
Expand All @@ -196,8 +197,9 @@ <h2>Properties</h2>
<div class="features">@override, read-only</div>
</dd>
<dt id="list" class="property">
<span class="name"><a href="ex/B/list.html">list</a></span>
<span class="signature">&#8596; List&lt;String&gt;</span>
<span class="name"><a href="ex/B/list.html">list</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="list=-param-_list"><span class="type-annotation">List&lt;String&gt;</span> </span> </span>
</span>
</dt>
<dd>
<p>A list of Strings</p>
Expand Down Expand Up @@ -228,8 +230,9 @@ <h2>Properties</h2>
<div class="features">read-only, inherited</div>
</dd>
<dt id="m" class="property inherited">
<span class="name"><a href="ex/Apple/m.html">m</a></span>
<span class="signature">&#8596; int</span>
<span class="name"><a href="ex/Apple/m.html">m</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="m=-param-_m"><span class="type-annotation">int</span> </span> </span>
</span>
</dt>
<dd class="inherited">
<p>The read-write field <code>m</code>.</p>
Expand Down
18 changes: 8 additions & 10 deletions testing/test_package_docs/ex/Dog-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ <h2>Properties</h2>
<div class="features">@protected, final</div>
</dd>
<dt id="deprecatedField" class="property">
<span class="name"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span>
<span class="signature">&#8596; int</span>
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="deprecatedField=-param-_deprecatedField"><span class="type-annotation">int</span> </span> </span>
</span>
</dt>
<dd>
<p></p>
Expand All @@ -236,7 +237,7 @@ <h2>Properties</h2>
</dd>
<dt id="deprecatedSetter" class="property">
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedSetter.html">deprecatedSetter</a></span><span class="signature">
<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>
<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>
</span>
</dt>
<dd>
Expand All @@ -252,8 +253,9 @@ <h2>Properties</h2>
<div class="features">@override, read-only</div>
</dd>
<dt id="name" class="property">
<span class="name"><a href="ex/Dog/name.html">name</a></span>
<span class="signature">&#8596; String</span>
<span class="name"><a href="ex/Dog/name.html">name</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="name=-param-_name"><span class="type-annotation">String</span> </span> </span>
</span>
</dt>
<dd>
<p></p>
Expand Down Expand Up @@ -412,13 +414,9 @@ <h2>Static Properties</h2>
</dd>
<dt id="staticGetterSetter" class="property">
<span class="name"><a href="ex/Dog/staticGetterSetter.html">staticGetterSetter</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="staticGetterSetter=-param-x"><span class="parameter-name">x</span></span></span>
<span class="returntype parameter">&#8596; <span class="parameter" id="staticGetterSetter=-param-x"><span class="parameter-name">x</span></span> </span>
</span>
</dt>
<dt id="staticGetterSetter" class="property">
<span class="name"><a href="ex/Dog/staticGetterSetter.html">staticGetterSetter</a></span>
<span class="signature">&#8596; int</span>
</dt>
<dd>
<p></p>
<div class="features">read / write</div>
Expand Down
12 changes: 7 additions & 5 deletions testing/test_package_docs/ex/F-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ <h2>Properties</h2>
<div class="features">@protected, final, inherited</div>
</dd>
<dt id="deprecatedField" class="property inherited">
<span class="name"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span>
<span class="signature">&#8596; int</span>
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedField.html">deprecatedField</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="deprecatedField=-param-_deprecatedField"><span class="type-annotation">int</span> </span> </span>
</span>
</dt>
<dd class="inherited">
<p></p>
Expand All @@ -211,7 +212,7 @@ <h2>Properties</h2>
</dd>
<dt id="deprecatedSetter" class="property inherited">
<span class="name deprecated"><a class="deprecated" href="ex/Dog/deprecatedSetter.html">deprecatedSetter</a></span><span class="signature">
<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>
<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>
</span>
</dt>
<dd class="inherited">
Expand All @@ -235,8 +236,9 @@ <h2>Properties</h2>
<div class="features">@override, read-only, inherited</div>
</dd>
<dt id="name" class="property inherited">
<span class="name"><a href="ex/Dog/name.html">name</a></span>
<span class="signature">&#8596; String</span>
<span class="name"><a href="ex/Dog/name.html">name</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="name=-param-_name"><span class="type-annotation">String</span> </span> </span>
</span>
</dt>
<dd class="inherited">
<p></p>
Expand Down
5 changes: 3 additions & 2 deletions testing/test_package_docs/ex/WithGeneric-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ <h2>Properties</h2>

<dl class="properties">
<dt id="prop" class="property">
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span>
<span class="signature">&#8596; T</span>
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="prop=-param-_prop"><span class="type-annotation">T</span> </span> </span>
</span>
</dt>
<dd>
<p></p>
Expand Down
5 changes: 3 additions & 2 deletions testing/test_package_docs/ex/WithGenericSub-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ <h2>Properties</h2>
<div class="features">read-only, inherited</div>
</dd>
<dt id="prop" class="property inherited">
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span>
<span class="signature">&#8596; T</span>
<span class="name"><a href="ex/WithGeneric/prop.html">prop</a></span><span class="signature">
<span class="returntype parameter">&#8596; <span class="parameter" id="prop=-param-_prop"><span class="type-annotation">T</span> </span> </span>
</span>
</dt>
<dd class="inherited">
<p></p>
Expand Down
Loading