Skip to content

Commit 2de17d6

Browse files
committed
Remove the deprecated templates-dir option
1 parent f41bd3a commit 2de17d6

File tree

4 files changed

+4
-110
lines changed

4 files changed

+4
-110
lines changed

lib/src/dartdoc_options.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,9 +1278,6 @@ class DartdocGeneratorOptionContext extends DartdocOptionContext {
12781278
String? get relCanonicalPrefix =>
12791279
optionSet['relCanonicalPrefix'].valueAt(context);
12801280

1281-
// TODO(kallentu): Remove --templates-dir completely.
1282-
String? get templatesDir => optionSet['templatesDir'].valueAt(context);
1283-
12841281
// TODO(jdkoren): duplicated temporarily so that GeneratorContext is enough for configuration.
12851282
@override
12861283
bool get useBaseHref => optionSet['useBaseHref'].valueAt(context);

lib/src/generator/generator.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,5 @@ List<DartdocOption> createGeneratorOptions(
8282
'If provided, add a rel="canonical" prefixed with provided value. '
8383
'Consider using if building many versions of the docs for public '
8484
'SEO; learn more at https://goo.gl/gktN6F.'),
85-
// TODO(kallentu): Remove --templates-dir completely.
86-
DartdocOptionArgOnly<String?>(
87-
'templatesDir',
88-
null,
89-
resourceProvider,
90-
optionIs: OptionKind.dir,
91-
mustExist: true,
92-
hide: true,
93-
help: '(deprecated) Path to a directory with templates to use instead of '
94-
'the default ones. Directory must contain a file for each of the '
95-
'following: 404error, category, class, constant, constructor, '
96-
'enum, function, index, library, method, mixin, property, '
97-
'top_level_constant, top_level_property, typedef. Partial '
98-
'templates are supported; they must begin with an underscore, and '
99-
'references to them must omit the leading underscore '
100-
'(e.g. use {{>foo}} to reference the partial template named _foo).',
101-
),
10285
];
10386
}

lib/src/generator/templates.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,14 @@ abstract class Templates {
112112
String renderTopLevelProperty(TopLevelPropertyTemplateData context);
113113
String renderTypedef(TypedefTemplateData context);
114114

115-
/// Creates a [Templates] instance either from the default set of templates,
116-
/// or a custom set if the 'templatesDir' Dartdoc option is used.
115+
/// Creates a [Templates] instance from the default set of templates.
117116
///
118117
/// [forceRuntimeTemplates] should only be given `true` during tests.
119118
static Future<Templates> fromContext(DartdocGeneratorOptionContext context,
119+
// TODO(srawlins): Remove this option, as runtime templates are no longer
120+
// supported.
120121
{bool forceRuntimeTemplates = false}) async {
121-
var templatesDir = context.templatesDir;
122-
if (templatesDir != null) {
123-
return RuntimeTemplates._create(
124-
context.resourceProvider.getFolder(templatesDir),
125-
resourceProvider: context.resourceProvider);
126-
} else if (forceRuntimeTemplates) {
122+
if (forceRuntimeTemplates) {
127123
var directory = await context.resourceProvider
128124
.getResourceFolder('package:dartdoc/templates');
129125
return RuntimeTemplates._create(directory,

test/options_test.dart

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -438,88 +438,6 @@ class C1 {}
438438
package.documentedCategoriesSorted.map((c) => c.name), equals(['One']));
439439
}
440440

441-
void
442-
test_templatesDirOption_referencingANonExistentDirectory_resultsInDartdocFailure() async {
443-
await createPackage(
444-
libFiles: [
445-
d.file('library_1.dart', '''
446-
library library_1;
447-
class Foo {}
448-
'''),
449-
],
450-
);
451-
expect(
452-
() => buildDartdoc(additionalArguments: ['--templates-dir', 'bad']),
453-
throwsA(const TypeMatcher<DartdocFailure>().having(
454-
(f) => f.message,
455-
'message',
456-
startsWith(
457-
'Argument --templates-dir, set to bad, resolves to missing path'),
458-
)));
459-
}
460-
461-
void test_templatesDirOption_specifiesTheTemplatesToUse() async {
462-
await createPackage(
463-
libFiles: [
464-
d.file('library_1.dart', '''
465-
library library_1;
466-
class Foo {}
467-
'''),
468-
],
469-
files: [
470-
d.dir('templates', [
471-
d.file('_sidebar_for_container.html', 'EMPTY'),
472-
d.file('_sidebar_for_library.html', 'EMPTY'),
473-
d.file('404error.html', 'EMPTY'),
474-
d.file('category.html', 'EMPTY'),
475-
d.file('class.html', 'CLASS FILE'),
476-
d.file('constructor.html', 'EMPTY'),
477-
d.file('enum.html', 'EMPTY'),
478-
d.file('extension.html', 'EMPTY'),
479-
d.file('function.html', 'EMPTY'),
480-
d.file('index.html', 'EMPTY'),
481-
d.file('library.html', 'EMPTY'),
482-
d.file('method.html', 'EMPTY'),
483-
d.file('mixin.html', 'EMPTY'),
484-
d.file('property.html', 'EMPTY'),
485-
d.file('top_level_property.html', 'EMPTY'),
486-
d.file('typedef.html', 'EMPTY'),
487-
d.file('search.html', 'EMPTY'),
488-
]),
489-
],
490-
);
491-
var customTemplatesDir = path.join(packagePath, 'templates');
492-
var dartdoc = await buildDartdoc(
493-
additionalArguments: ['--templates-dir', customTemplatesDir]);
494-
await dartdoc.generateDocsBase();
495-
final indexContent = resourceProvider
496-
.getFile(
497-
path.joinAll([packagePath, 'doc', 'library_1', 'Foo-class.html']))
498-
.readAsStringSync();
499-
expect(indexContent, contains('CLASS FILE'));
500-
}
501-
502-
void
503-
test_templatesDirOptionReferencingAnEmptyDirectory_resultsInDartdocFailure() async {
504-
await createPackage(
505-
libFiles: [
506-
d.file('library_1.dart', '''
507-
library library_1;
508-
class Foo {}
509-
'''),
510-
],
511-
);
512-
var customTemplatesDir = resourceProvider
513-
.newFolder(resourceProvider.pathContext
514-
.canonicalize(resourceProvider.convertPath('/custom_templates')))
515-
.path;
516-
expect(
517-
() => buildDartdoc(
518-
additionalArguments: ['--templates-dir', customTemplatesDir]),
519-
throwsA(const TypeMatcher<DartdocFailure>().having((f) => f.message,
520-
'message', startsWith('Missing required template file'))));
521-
}
522-
523441
void test_emptyPackage() async {
524442
await createPackage();
525443
await (await buildDartdoc()).generateDocs();

0 commit comments

Comments
 (0)