Skip to content

Commit 81d5f3e

Browse files
committed
Include extension members on the extended type's page
Fixes dart-lang#2021 In this feature, we list extension members of an extended type on that extended type's page. The members are listed inline with other instance members and are cross-linked over to the extension's member pages. * Introduce `availableInstanceMethods` as a list combining both instance methods declared in a container, and instance methods declared in an applicable extension. The same for `availableInstanceOperators` and `availableInstanceFields`. * Introduce some constructors like `Field.providedByExtension` for members that are provided by an extension. * Add lots of documentation clarifying _where_ various members come from. * We introduce a new getter on ElementType, `nameWithGenericsPlain`, which is not HTML-formatted, for use in HTML "title text."
1 parent 8100ccf commit 81d5f3e

28 files changed

+1135
-326
lines changed

lib/resources/styles.css

+16
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,22 @@ h1 .category {
595595
vertical-align: middle;
596596
}
597597

598+
/* Do not display "provided by X extension" text on extension pages. */
599+
.main-content.extension-page .from-extension {
600+
display: none;
601+
}
602+
603+
sup.muted {
604+
color: var(--main-sidebar-color);
605+
font-size: 0.6em;
606+
}
607+
608+
.from-extension > span {
609+
background-color: var(--alert-warning);
610+
font-style: italic;
611+
padding: 2px;
612+
}
613+
598614
/* The badge under a declaration for things like "const", "read-only", etc. and for the badges inline like sealed or interface */
599615
/* See https://github.com/dart-lang/dartdoc/blob/main/lib/src/model/feature.dart */
600616
.feature {

lib/src/element_type.dart

+16-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ abstract class ElementType with CommentReferable, Nameable {
4848

4949
String get linkedName;
5050

51-
/// Name with generics and nullability indication.
51+
/// Name with generics and nullability indication, in HTML tags.
5252
String get nameWithGenerics;
5353

54+
/// Name with generics and nullability indication, in plain text, with
55+
/// unescaped angle brackets.
56+
String get nameWithGenericsPlain;
57+
5458
@override
5559
String get displayName => throw UnimplementedError();
5660

@@ -103,11 +107,14 @@ class UndefinedElementType extends ElementType {
103107
return type.documentableElement!.name!;
104108
}
105109

110+
@override
111+
String get linkedName => name;
112+
106113
@override
107114
String get nameWithGenerics => '$name$nullabilitySuffix';
108115

109116
@override
110-
String get linkedName => name;
117+
String get nameWithGenericsPlain => '$name$nullabilitySuffix';
111118

112119
@override
113120
Iterable<ElementType> get typeArguments => const [];
@@ -241,6 +248,9 @@ class TypeParameterElementType extends DefinedElementType {
241248

242249
@override
243250
String get nameWithGenerics => '$name$nullabilitySuffix';
251+
252+
@override
253+
String get nameWithGenericsPlain => '$name$nullabilitySuffix';
244254
}
245255

246256
/// An [ElementType] associated with an [Element].
@@ -341,6 +351,10 @@ mixin Rendered implements ElementType {
341351
@override
342352
late final String nameWithGenerics = _renderer.renderNameWithGenerics(this);
343353

354+
@override
355+
late final String nameWithGenericsPlain =
356+
_renderer.renderNameWithGenerics(this, plain: true);
357+
344358
ElementTypeRenderer<ElementType> get _renderer;
345359
}
346360

0 commit comments

Comments
 (0)