Refactor asciidocs to use jinja2 templates#865
Merged
ebeahan merged 18 commits intoelastic:masterfrom Jun 25, 2020
Merged
Conversation
webmat
reviewed
Jun 18, 2020
Contributor
webmat
left a comment
There was a problem hiding this comment.
This looks great! Thanks Eric :-)
The main goal of adding these templates is to make contributions to ECS simpler for non technical or non-Python contributors. This is a great step in this direction!
In the same vein, I have a few more small things I think we could do here:
- Can we move the templates to
scripts/templates/...? They'll be a bit easier to find for folks who never play in the code. - Can we add to the "Documentation" section of
CONTRIBUTING.md, with some details about this?- mention which files are generated, and where to find their templates
- we have a link to asciidoc already, we can add another one for Jinja2
- [stretch goal] add a mini primer to help people know what's J2 vs what's asciidoc. Perhaps we only need to cover
{{ }}and{% %}?
Member
Author
|
@webmat thanks for the feedback! Let me know your thoughts on the additions to |
webmat
approved these changes
Jun 25, 2020
Contributor
webmat
left a comment
There was a problem hiding this comment.
Looking great! Thanks for the adjustments :-)
This was referenced Jul 17, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors the
ascii_fieldsgenerator to usejinja2templating. Motivation is better decoupling the asciidoc formatting from the content generation.Template changes can be made in the
./scripts/generators/templatesdirectory without modifying the generator code directly. Formatting was tested by generating docs and ensuring no changes from their existing structure and content.Templating implementation
The
@templated('template_file_name')decorator is used to inject the additional functionality that renders and returns the template's content to the generator.Decorated functions should return a
dictused to generate the template. When the decorated function returns, the dictionary is passed to the template renderer.NOTE: Leaving as draft until #864 is merged. I'll update and resolve conflicts accordingly.#864 is merged 😎