Skip to content

Support custom templates directory #2006

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
Aug 23, 2019

Conversation

jdkoren
Copy link
Contributor

@jdkoren jdkoren commented Aug 21, 2019

Adds a (hidden) command-line flag to supply a directory with custom
html templates to use. If not specified, dartdoc defaults to using the
packaged templates.

Change-Id: I4148ff388947b1e0e24aa63b598be00cb01ae220

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Aug 21, 2019
@jdkoren jdkoren force-pushed the custom_templates branch 3 times, most recently from 5e0f5f4 to 8b691b9 Compare August 21, 2019 20:02
@jdkoren jdkoren marked this pull request as ready for review August 21, 2019 20:23
void replacePlaceholder(String key, String placeholder, List<String> paths) {
var template = partials[key];
if (template != null && paths != null && paths.isNotEmpty) {
String replacement = paths.map((path) => File(path).readAsStringSync())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'p' instead of 'path', since path is used as prefix for package:path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

'class, constant, constructor, enum, function, index, library, method, mixin, '
'property, top_level_constant, top_level_property, typedef. Partial templates are '
'supported; they must begin with an underscore, and references to them must omit the '
'leading underscore (e.g. use {{>foo}} to reference the partial template _foo.html).'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a check to see if all the expected templates are in the directory, and fail with the a message that lets the user know what's missing. The template files can change (working on one such change now), and it will be helpful to flag this with a check rather than a failure/stack trace.

Copy link
Contributor Author

@jdkoren jdkoren Aug 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a check in templates.dart (and a test), but let me know if you want me to go about it in a different way.

Adds a (hidden) command-line flag to supply a directory with custom
html templates to use. If not specified, dartdoc defaults to using the
packaged templates.

Change-Id: I4148ff388947b1e0e24aa63b598be00cb01ae220
@keertip keertip merged commit a93e4bb into dart-lang:master Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants