Skip to content

Commit 5a1700f

Browse files
authored
Deprecate --templates-dir option. (#3667)
* Deprecate option. * Add deprecation warning.
1 parent 0efd1b0 commit 5a1700f

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 8.0.6-wip
22

33
* Add troubleshooting information when the sidebars failed to load.
4+
* Deprecate the `--templates-dir` option.
45

56
## 8.0.5
67

lib/src/dartdoc_options.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ class DartdocGeneratorOptionContext extends DartdocOptionContext {
14091409
String? get relCanonicalPrefix =>
14101410
optionSet['relCanonicalPrefix'].valueAt(context);
14111411

1412+
// TODO(kallentu): Remove --templates-dir completely.
14121413
String? get templatesDir => optionSet['templatesDir'].valueAt(context);
14131414

14141415
// TODO(jdkoren): duplicated temporarily so that GeneratorContext is enough for configuration.

lib/src/generator/generator.dart

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,22 @@ 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-
DartdocOptionArgOnly<String?>('templatesDir', null, resourceProvider,
86-
optionIs: OptionKind.dir,
87-
mustExist: true,
88-
hide: true,
89-
help:
90-
'Path to a directory with templates to use instead of the default '
91-
'ones. Directory must contain a file for each of the following: '
92-
'404error, category, class, constant, constructor, enum, function, '
93-
'index, library, method, mixin, property, top_level_constant, '
94-
'top_level_property, typedef. Partial templates are supported; '
95-
'they must begin with an underscore, and references to them must '
96-
'omit the leading underscore (e.g. use {{>foo}} to reference the '
97-
'partial template named _foo).'),
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+
),
98102
];
99103
}

lib/src/generator/generator_frontend.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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';
78
import 'package:dartdoc/src/logging.dart';
89
import 'package:dartdoc/src/model/model.dart';
910
import 'package:dartdoc/src/model_utils.dart';
@@ -19,6 +20,14 @@ class GeneratorFrontEnd implements Generator {
1920

2021
@override
2122
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+
2231
var indexElements = packageGraph == null
2332
? const <Indexable>[]
2433
: _generateDocs(packageGraph);

0 commit comments

Comments
 (0)