Skip to content
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

Display an extension's extended type in a few places. #3708

Merged
merged 1 commit into from
Mar 8, 2024
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 lib/src/generator/template_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ abstract class TemplateDataBase {
return navLinksWithGenerics.last;
}

bool get isParentExtension => parent is Extension;

Extension get parentAsExtension => parent as Extension;

bool get hasHomepage => false;

String? get homepage => null;
Expand Down
123 changes: 79 additions & 44 deletions lib/src/generator/templates.aot_renderers_for_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ String renderExtension<T extends Extension>(ExtensionTemplateData<T> context0) {
if (context2.hasPublicInstanceFields) {
buffer.writeln();
buffer.write('''
<section class="summary offset-anchor" id="instance-properties">
<section class="summary offset-anchor" id="instance-properties">
<h2>Properties</h2>

<dl class="properties">''');
Expand All @@ -770,7 +770,7 @@ String renderExtension<T extends Extension>(ExtensionTemplateData<T> context0) {
buffer.writeln();
buffer.write('''
</dl>
</section>''');
</section>''');
}
buffer.write('\n\n ');
buffer.write(_renderExtension_partial_instance_methods_7(context2));
Expand All @@ -782,17 +782,18 @@ String renderExtension<T extends Extension>(ExtensionTemplateData<T> context0) {
buffer.write(_renderExtension_partial_static_methods_10(context2));
buffer.write('\n ');
buffer.write(_renderExtension_partial_static_constants_11(context2));
var context6 = context0.extension;
buffer.writeln();
buffer.write('''

</div> <!-- /.main-content -->

<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
''');
''');
buffer.write(_renderExtension_partial_search_sidebar_12(context0));
buffer.writeln();
buffer.write('''
<h5>''');
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
Expand All @@ -807,6 +808,7 @@ String renderExtension<T extends Extension>(ExtensionTemplateData<T> context0) {
buffer.write(_renderExtension_partial_footer_13(context0));
buffer.writeln();
buffer.writeln();
buffer.writeln();

return buffer.toString();
}
Expand Down Expand Up @@ -1142,38 +1144,38 @@ String renderLibrary(LibraryTemplateData context0) {
buffer.writeln();
buffer.write('''

<div
id="dartdoc-main-content"
class="main-content"
data-above-sidebar="''');
<div
id="dartdoc-main-content"
class="main-content"
data-above-sidebar="''');
buffer.writeEscaped(context0.aboveSidebarPath);
buffer.write('''"
data-below-sidebar="''');
data-below-sidebar="''');
buffer.writeEscaped(context0.belowSidebarPath);
buffer.write('''">
''');
''');
var context1 = context0.self;
buffer.writeln();
buffer.write('''
<div>
''');
<div>
''');
buffer.write(_renderLibrary_partial_source_link_1(context1));
buffer.writeln();
buffer.write('''
<h1>
<span class="kind-library">''');
<h1>
<span class="kind-library">''');
buffer.write(context1.displayName);
buffer.write('''</span>
''');
''');
buffer.writeEscaped(context1.kind.toString());
buffer.write(' ');
buffer.write(_renderLibrary_partial_feature_set_2(context1));
buffer.write(' ');
buffer.write(_renderLibrary_partial_categorization_3(context1));
buffer.writeln();
buffer.write('''
</h1>
</div>''');
</h1>
</div>''');
buffer.writeln();
var context2 = context0.library;
buffer.write('\n ');
Expand All @@ -1190,7 +1192,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context4 = context3.library;
var context5 = context4.publicClassesSorted;
for (var context6 in context5) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_container_5(context6));
}
buffer.writeln();
Expand All @@ -1210,7 +1212,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context8 = context7.library;
var context9 = context8.publicEnumsSorted;
for (var context10 in context9) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_container_5(context10));
}
buffer.writeln();
Expand All @@ -1230,7 +1232,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context12 = context11.library;
var context13 = context12.publicMixinsSorted;
for (var context14 in context13) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_container_5(context14));
}
buffer.writeln();
Expand All @@ -1250,7 +1252,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context16 = context15.library;
var context17 = context16.publicExtensionTypesSorted;
for (var context18 in context17) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_extension_type_6(context18));
}
buffer.writeln();
Expand All @@ -1270,7 +1272,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context20 = context19.library;
var context21 = context20.publicExtensionsSorted;
for (var context22 in context21) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_extension_7(context22));
}
buffer.writeln();
Expand All @@ -1290,7 +1292,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context24 = context23.library;
var context25 = context24.publicConstantsSorted;
for (var context26 in context25) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_constant_8(context26));
}
buffer.writeln();
Expand All @@ -1310,7 +1312,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context28 = context27.library;
var context29 = context28.publicPropertiesSorted;
for (var context30 in context29) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_property_9(context30));
}
buffer.writeln();
Expand All @@ -1330,7 +1332,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context32 = context31.library;
var context33 = context32.publicFunctionsSorted;
for (var context34 in context33) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_callable_10(context34));
}
buffer.writeln();
Expand Down Expand Up @@ -1370,7 +1372,7 @@ String renderLibrary(LibraryTemplateData context0) {
var context40 = context39.library;
var context41 = context40.publicExceptionsSorted;
for (var context42 in context41) {
buffer.write('\n ');
buffer.write('\n ');
buffer.write(_renderLibrary_partial_container_5(context42));
}
buffer.writeln();
Expand Down Expand Up @@ -1420,19 +1422,19 @@ String renderMethod(MethodTemplateData context0) {
buffer.writeln();
buffer.write('''

<div
id="dartdoc-main-content"
class="main-content"
data-above-sidebar="''');
<div
id="dartdoc-main-content"
class="main-content"
data-above-sidebar="''');
buffer.writeEscaped(context0.aboveSidebarPath);
buffer.write('''"
data-below-sidebar="''');
data-below-sidebar="''');
buffer.writeEscaped(context0.belowSidebarPath);
buffer.write('''">''');
var context1 = context0.self;
buffer.writeln();
buffer.write('''
<div>''');
<div>''');
buffer.write(_renderMethod_partial_source_link_1(context1));
buffer.write('''<h1><span class="kind-method">''');
buffer.write(context1.nameWithGenerics);
Expand Down Expand Up @@ -1465,18 +1467,33 @@ String renderMethod(MethodTemplateData context0) {
<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
''');
buffer.write(_renderMethod_partial_search_sidebar_7(context0));
if (context0.isParentExtension) {
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write(''' on ''');
buffer.write(context0.parentAsExtension.extendedType.linkedName);
buffer.write('''</h5>''');
}
if (!context0.isParentExtension) {
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write('''</h5>''');
}
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write('''</h5>
<div id="dartdoc-sidebar-left-content"></div>
</div><!--/.sidebar-offcanvas-->

<div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
</div><!--/.sidebar-offcanvas-->
</div><!--/.sidebar-offcanvas-->

''');
buffer.write(_renderMethod_partial_footer_8(context0));
Expand Down Expand Up @@ -1699,13 +1716,28 @@ String renderProperty(PropertyTemplateData context0) {
<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
''');
buffer.write(_renderProperty_partial_search_sidebar_10(context0));
if (context0.isParentExtension) {
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write(''' on ''');
buffer.write(context0.parentAsExtension.extendedType.linkedName);
buffer.write('''</h5>''');
}
if (!context0.isParentExtension) {
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write('''</h5>''');
}
buffer.writeln();
buffer.write('''
<h5>''');
buffer.writeEscaped(context0.parent!.name);
buffer.write(' ');
buffer.writeEscaped(context0.parent!.kind.toString());
buffer.write('''</h5>
<div id="dartdoc-sidebar-left-content"></div>
</div><!--/.sidebar-offcanvas-->

Expand Down Expand Up @@ -3717,7 +3749,10 @@ String _deduplicated_lib_templates__extension_html(Extension context0) {
}
buffer.write('''">''');
buffer.write(context0.linkedName);
buffer.write('''</span> ''');
buffer.write('''</span>
on ''');
buffer.write(context0.extendedType.linkedName);
buffer.write('\n ');
buffer.write(
__deduplicated_lib_templates__extension_html_partial_categorization_0(
context0));
Expand Down
30 changes: 30 additions & 0 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13842,6 +13842,13 @@ class _Renderer_TemplateDataBase extends RendererBase<TemplateDataBase> {
self.renderSimpleVariable(c, remainingNames, 'bool'),
getBool: (CT_ c) => c.includeVersion,
),
'isParentExtension': Property(
getValue: (CT_ c) => c.isParentExtension,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(c, remainingNames, 'bool'),
getBool: (CT_ c) => c.isParentExtension,
),
'layoutTitle': Property(
getValue: (CT_ c) => c.layoutTitle,
renderVariable:
Expand Down Expand Up @@ -13945,6 +13952,29 @@ class _Renderer_TemplateDataBase extends RendererBase<TemplateDataBase> {
parent: r);
},
),
'parentAsExtension': Property(
getValue: (CT_ c) => c.parentAsExtension,
renderVariable:
(CT_ c, Property<CT_> self, List<String> remainingNames) {
if (remainingNames.isEmpty) {
return self.getValue(c).toString();
}
var name = remainingNames.first;
var nextProperty =
_Renderer_Extension.propertyMap().getValue(name);
return nextProperty.renderVariable(
self.getValue(c) as Extension,
nextProperty,
[...remainingNames.skip(1)]);
},
isNullValue: (CT_ c) => false,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
_render_Extension(
c.parentAsExtension, ast, r.template, sink,
parent: r);
},
),
'relCanonicalPrefix': Property(
getValue: (CT_ c) => c.relCanonicalPrefix,
renderVariable:
Expand Down
4 changes: 3 additions & 1 deletion lib/templates/_extension.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<dt id="{{ htmlId }}">
<span class="name {{ #isDeprecated }}deprecated{{ /isDeprecated }}">{{{ linkedName }}}</span> {{ >categorization }}
<span class="name {{ #isDeprecated }}deprecated{{ /isDeprecated }}">{{{ linkedName }}}</span>
on {{{ extendedType.linkedName }}}
{{ >categorization }}
</dt>
<dd>
{{{ oneLineDoc }}}
Expand Down
Loading