-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document custom Jinja emplate filters
- Loading branch information
Showing
9 changed files
with
350 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import textwrap | ||
|
||
from tmt.utils import TEMPLATE_FILTERS, Path, render_template_file | ||
|
||
HELP = textwrap.dedent(""" | ||
Usage: generate-template-filters.py <TEMPLATE-PATH> <OUTPUT-PATH> | ||
Generate docs for all known Jinja2 template filters. | ||
""").strip() | ||
|
||
|
||
def main() -> None: | ||
if len(sys.argv) != 3: | ||
print(HELP) | ||
|
||
sys.exit(1) | ||
|
||
template_filepath = Path(sys.argv[1]) | ||
output_filepath = Path(sys.argv[2]) | ||
|
||
output_filepath.write_text(render_template_file(template_filepath, TEMPLATES=TEMPLATE_FILTERS)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{# | ||
This template is rendered by conf.py & Sphinx when building documentation. | ||
The reST comment below should land in the rendered file, to discourage people | ||
from editing it instead of this template. | ||
#} | ||
|
||
.. | ||
Please, do not edit this file, is is rendered from template-filters.rst.j2, | ||
and all your changes would be overwritten. | ||
|
||
Template filters | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
When it comes to creating text documents, like | ||
:ref:`custom templates <custom_templates>` or exporting tests, plans | ||
and stories into ReST or Markdown, tmt relies on the well-known | ||
`Jinja`__ package. All Jinja templating features are supported, and, on | ||
top of `filters`__ shipped with Jinja, tmt adds several custom ones. | ||
|
||
__ https://palletsprojects.com/p/jinja/ | ||
__ https://jinja.palletsprojects.com/en/3.1.x/templates/#filters | ||
|
||
{% for filter_name in TEMPLATES.keys() | sort %} | ||
{% set filter_callable = TEMPLATES[filter_name] %} | ||
|
||
{{ filter_name }} | ||
{{ '-' * (filter_name | length)}} | ||
|
||
{% if filter_callable.__doc__ %} | ||
{{ filter_callable.__doc__ | dedent | trim }} | ||
{% endif %} | ||
|
||
{% endfor %} |
This file contains 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
Oops, something went wrong.