Skip to content

Commit eb90a44

Browse files
authored
Remove annotations from the features section of each element (#3268)
1 parent 1612637 commit eb90a44

31 files changed

+639
-325
lines changed

lib/src/generator/templates.aot_renderers_for_html.dart

Lines changed: 201 additions & 134 deletions
Large diffs are not rendered by default.

lib/src/generator/templates.aot_renderers_for_md.dart

Lines changed: 116 additions & 51 deletions
Large diffs are not rendered by default.

lib/src/model/field.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Field extends ModelElement
114114

115115
@override
116116
Set<Feature> get features {
117-
var allFeatures = super.features..addAll(comboFeatures);
117+
var allFeatures = {...super.features, ...comboFeatures};
118118
// Combo features can indicate 'inherited' and 'override' if
119119
// either the getter or setter has one of those properties, but that's not
120120
// really specific enough for [Field]s that have public getter/setters.

lib/src/model/model_element.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,12 @@ abstract class ModelElement extends Canonicalization
414414
@override
415415
late final ModelNode? modelNode = packageGraph.getModelNodeFor(element);
416416

417-
// Skips over annotations with null elements or that are otherwise
418-
// supposed to be invisible (@pragma). While technically, null elements
419-
// indicate invalid code from analyzer's perspective they are present in
420-
// sky_engine (@Native) so we don't want to crash here.
417+
/// This element's [Annotation]s.
418+
///
419+
/// Does not include annotations with `null` elements or that are otherwise
420+
/// supposed to be invisible (like `@pragma`). While `null` elements indicate
421+
/// invalid code from analyzer's perspective, some are present in `sky_engine`
422+
/// (`@Native`) so we don't want to crash here.
421423
late final List<Annotation> annotations = element.metadata
422424
.whereNot((m) =>
423425
m.element == null ||
@@ -458,24 +460,14 @@ abstract class ModelElement extends Canonicalization
458460
.where((s) => s.isNotEmpty)
459461
.toSet();
460462

461-
static const Set<String> _specialFeatures = {
462-
// Replace the @override annotation with a feature that explicitly
463-
// indicates whether an override has occurred.
464-
'override',
465-
// Drop the plain "deprecated" annotation; that's indicated via
466-
// strikethroughs. Custom @Deprecated() will still appear.
467-
'deprecated'
468-
};
469-
470463
bool get hasFeatures => features.isNotEmpty;
471464

472-
/// Usually a superset of [annotations] except where [_specialFeatures]
473-
/// replace them, a list of annotations as well as tags applied by
474-
/// Dartdoc itself when it notices characteristics of an element
475-
/// that need to be documented. See [Feature] for a list.
465+
/// The set of attributes or "features" of this element.
466+
///
467+
/// This includes tags applied by Dartdoc for various attributes that should
468+
/// be called out. See [Feature] for a list.
476469
Set<Feature> get features {
477470
return {
478-
...annotations.whereNot((a) => _specialFeatures.contains(a.name)),
479471
// 'const' and 'static' are not needed here because 'const' and 'static'
480472
// elements get their own sections in the doc.
481473
if (isFinal) Feature.finalFeature,

lib/templates/html/_accessor_getter.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<section id="getter">
33

44
<section class="multi-line-signature">
5+
{{ >annotations }}
56
<span class="returntype">{{{ modelType.returnType.linkedName }}}</span>
6-
{{>name_summary}}
7-
{{>features}}
7+
{{ >name_summary }}
8+
{{ >features }}
89
</section>
910

1011
{{>documentation}}

lib/templates/html/_accessor_setter.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<section id="setter">
33

44
<section class="multi-line-signature">
5+
{{ >annotations }}
56
<span class="returntype">void</span>
6-
{{>name_summary}}<span class="signature">(<wbr>{{{ linkedParamsNoMetadata }}})</span>
7-
{{>features}}
7+
{{ >name_summary }}<span class="signature">(<wbr>{{{ linkedParamsNoMetadata }}})</span>
8+
{{ >features }}
89
</section>
910

1011
{{>documentation}}

lib/templates/html/_annotations.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{{ #hasAnnotations }}
2-
<dt>Annotations</dt>
3-
<dd>
4-
<ul class="annotation-list {{ relationshipsClass }}">
2+
<div>
3+
<ol class="annotation-list">
54
{{ #annotations }}
65
<li>{{{ linkedNameWithParameters }}}</li>
76
{{ /annotations }}
8-
</ul>
9-
</dd>
7+
</ol>
8+
</div>
109
{{ /hasAnnotations }}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
{{#hasAnnotations}}
2-
<div>
3-
<ol class="annotation-list">
4-
{{#annotations}}
5-
<li>{{{linkedNameWithParameters}}}</li>
6-
{{/annotations}}
7-
</ol>
8-
</div>
9-
{{/hasAnnotations}}
1+
{{ >annotations }}
102

113
<span class="returntype">{{{ modelType.returnType.linkedName }}}</span>
124
{{>name_summary}}{{{genericParameters}}}(<wbr>{{#hasParameters}}{{{linkedParamsLines}}}{{/hasParameters}})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{ #hasAnnotations }}
2+
<dt>Annotations</dt>
3+
<dd>
4+
<ul class="annotation-list {{ relationshipsClass }}">
5+
{{ #annotations }}
6+
<li>{{{ linkedNameWithParameters }}}</li>
7+
{{ /annotations }}
8+
</ul>
9+
</dd>
10+
{{ /hasAnnotations }}
11+

lib/templates/html/class.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</ul></dd>
3434
{{/hasPotentiallyApplicableExtensions}}
3535

36-
{{ >annotations }}
36+
{{ >container_annotations }}
3737
</dl>
3838
</section>
3939
{{/hasModifiers}}

0 commit comments

Comments
 (0)