Skip to content

Move HTML templates into lib/templates and other clean up. #3677

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 1 commit into from
Feb 26, 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
652 changes: 309 additions & 343 deletions lib/src/generator/templates.aot_renderers_for_html.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/src/generator/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ abstract class Templates {
resourceProvider: context.resourceProvider);
} else if (forceRuntimeTemplates) {
var directory = await context.resourceProvider
.getResourceFolder('package:dartdoc/templates/html');
.getResourceFolder('package:dartdoc/templates');
return RuntimeTemplates._create(directory,
resourceProvider: context.resourceProvider);
} else {
Expand Down
16 changes: 3 additions & 13 deletions lib/src/mustachio/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class Renderer {
/// render the [context] object while generating documentation in HTML.
final String standardHtmlTemplate;

/// The unparsed, string form of the URI of the _standard_ Markdown template.
///
/// This represents the Mustache template that dartdoc uses out-of-the-box to
/// render the [context] object while generating documentation in Markdown.
final String standardMdTemplate;

/// A set of types which are "visible" to the Mustache runtime interpreter.
/// Mustache runtime-rendering has access to all of a type's public getters if
/// the type is visible to Mustache.
Expand All @@ -53,20 +47,16 @@ class Renderer {
this.context,
String standardTemplateBasename, {
this.visibleTypes = const {},
}) : standardHtmlTemplate =
'lib/templates/html/$standardTemplateBasename.html',
standardMdTemplate = 'lib/templates/md/$standardTemplateBasename.md';
}) : standardHtmlTemplate = 'lib/templates/$standardTemplateBasename.html';

@visibleForTesting
const Renderer.forTest(
this.name,
this.context,
String standardTemplateBasename, {
this.visibleTypes = const {},
}) : standardHtmlTemplate =
'test/mustachio/templates/$standardTemplateBasename.html',
standardMdTemplate =
'test/mustachio/templates/$standardTemplateBasename.md';
}) : standardHtmlTemplate =
'test/mustachio/templates/$standardTemplateBasename.html';
}

/// A container for a type, [T], which is the type of a context object,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 9 additions & 11 deletions test/mustachio/aot_compiler_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library foo;
import 'annotations.dart';
''',
additionalAssets: () => [
d.dir('lib/templates/html', [
d.dir('lib/templates', [
d.file('foo.html', '{{ >foo_header }}'),
d.file('_foo_header.html', 'EMPTY'),
]),
Expand Down Expand Up @@ -57,7 +57,7 @@ library foo;
import 'annotations.dart';
''',
additionalAssets: () => [
d.dir('lib/templates/html', [
d.dir('lib/templates', [
d.file('foo.html', 's1 is {{ s1 }}'),
]),
d.dir('md', [
Expand All @@ -84,10 +84,8 @@ import 'annotations.dart';
additionalAssets: () => [
d.dir('lib', [
d.dir('templates', [
d.dir('html', [
d.file('foo.html', '{{ >foo_header }}'),
d.file('_foo_header.html', 's1 is {{ s1 }}'),
]),
d.file('foo.html', '{{ >foo_header }}'),
d.file('_foo_header.html', 's1 is {{ s1 }}'),
]),
]),
],
Expand Down Expand Up @@ -138,7 +136,7 @@ library foo;
import 'annotations.dart';
''',
additionalAssets: () => [
d.dir('lib/templates/html', [
d.dir('lib/templates', [
d.file('foo.html', '{{ >base }}'),
d.file('bar.html', '{{ >base }}'),
d.file('_base.html', 's1 is {{ s1 }}'),
Expand All @@ -149,16 +147,16 @@ import 'annotations.dart';
expect(
generatedContent,
contains('String _renderFoo_partial_base_0(Foo context0) =>\n'
' _deduplicated_lib_templates_html__base_html(context0);\n'),
' _deduplicated_lib_templates__base_html(context0);\n'),
);
expect(
generatedContent,
contains('String _renderBar_partial_base_0(Bar context0) =>\n'
' _deduplicated_lib_templates_html__base_html(context0);\n'),
' _deduplicated_lib_templates__base_html(context0);\n'),
);
expect(
generatedContent,
contains('String _deduplicated_lib_templates_html__base_html('),
contains('String _deduplicated_lib_templates__base_html('),
);
});

Expand All @@ -185,7 +183,7 @@ library foo;
import 'annotations.dart';
''',
additionalAssets: () => [
d.dir('lib/templates/html', [
d.dir('lib/templates', [
d.file('foo.html', '{{ >base }}'),
d.file('bar.html', '{{ >base }}'),
d.file('_base.html', 's1 is {{ s1 }}'),
Expand Down
Loading