Skip to content

Commit a4a902b

Browse files
authored
Remove the deprecated templates-dir option (#4026)
1 parent 37de749 commit a4a902b

File tree

6 files changed

+5
-119
lines changed

6 files changed

+5
-119
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 9.0.0-wip
22
* Remove deprecated `missingCodeBlockLanguage` warning.
3+
* Remove the deprecated `templates-dir` option.
34

45
## 8.3.4
56
* The URL for category pages now uses _category name_ instead of

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/generator_frontend.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:dartdoc/src/generator/generator.dart';
66
import 'package:dartdoc/src/generator/generator_backend.dart';
7-
import 'package:dartdoc/src/generator/templates.dart';
87
import 'package:dartdoc/src/logging.dart';
98
import 'package:dartdoc/src/model/model.dart';
109
import 'package:dartdoc/src/model_utils.dart';
@@ -20,14 +19,6 @@ class GeneratorFrontEnd implements Generator {
2019

2120
@override
2221
Future<void> generate(PackageGraph? packageGraph) async {
23-
if (_generatorBackend.templates is RuntimeTemplates) {
24-
packageGraph?.defaultPackage.warn(
25-
PackageWarning.deprecated,
26-
message: "The '--templates-dir' option is deprecated, and will soon no "
27-
'longer be supported.',
28-
);
29-
}
30-
3122
await _generatorBackend.generateAdditionalFiles();
3223

3324
if (packageGraph == null) {

lib/src/generator/templates.dart

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

119-
/// Creates a [Templates] instance either from the default set of templates,
120-
/// or a custom set if the 'templatesDir' Dartdoc option is used.
119+
/// Creates a [Templates] instance from the default set of templates.
121120
///
122121
/// [forceRuntimeTemplates] should only be given `true` during tests.
123122
static Future<Templates> fromContext(DartdocGeneratorOptionContext context,
123+
// TODO(srawlins): Remove this option, as runtime templates are no longer
124+
// supported.
124125
{bool forceRuntimeTemplates = false}) async {
125-
var templatesDir = context.templatesDir;
126-
if (templatesDir != null) {
127-
return RuntimeTemplates._create(
128-
context.resourceProvider.getFolder(templatesDir),
129-
resourceProvider: context.resourceProvider);
130-
} else if (forceRuntimeTemplates) {
126+
if (forceRuntimeTemplates) {
131127
var directory = await context.resourceProvider
132128
.getResourceFolder('package:dartdoc/templates');
133129
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)