Ansible Documentation Template Extractor
Project description
ansible-doc-template-extractor
ansible-doc-template-extractor is a documentation extractor that supports
the format Ansible roles use in their meta/argument_specs.yml files as input,
and arbitrary Jinja2 template files to control what is generated as output.
It can also be used for Ansible playbooks (and other Ansible items), as long as a spec file in YAML format is provided that documents it. The format can differ from the argument spec files for roles, but of course the template file needs to support the format of the spec file.
The format of the spec files for Ansible roles is described here: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#specification-format
Template files for Markdown and RST format for the spec files for Ansible roles are included with the ansible-doc-template-extractor package. You can write your own templates for other formats or for Ansible playbooks (and other Ansible items).
Disclaimer: The ansible-doc-template-extractor tool should be seen as a temporary bridge until there is official documentation extraction support for Ansible roles and playbooks. There have been discussions in Ansible forums to add support for Ansible roles to the ansible-doc and ansible-navigator tools. Once that happens, the ansible-doc-template-extractor tool is probably no longer needed for Ansible roles. In the event that an official spec format for Ansible playbooks gets defined one day and that this format gets supported by the ansible-doc and ansible-navigator tools, the ansible-doc-template-extractor tool is probably no longer needed at all.
Installation
If you want to install the package into a virtual Python environment:
$ pip install ansible-doc-template-extractor
Otherwise, you can also install it without depending on a virtual Python environment:
-
If not yet available, install the "pipx" command as described in https://pipx.pypa.io/stable/installation/.
-
Then, install the package using "pipx":
$ pipx install ansible-doc-template-extractor
Example use
Suppose you have the following subtree:
├── my_collection
| ├── roles
| ├── my_role
| └── meta
| └── argument_specs.yml
├── docs
Then you can run the extractor as follows:
$ ansible-doc-template-extractor -o docs my_collection/roles/my_role/meta/argument_specs.yml
Loading template file: .../templates/role.md.j2
Ansible name: my_role
Loading spec file: my_collection/roles/my_role/meta/argument_specs.yml
Created output file: docs/my_role.md
This will create an .md file in Markdown format with the documentation of the role:
├── docs
│ └── my_role.md
Writing templates
The template files for roles and for the Markdown and RST formats are included with the installed ansible-doc-template-extractor package.
You can write your own templates for any other format or for Ansible playbooks (or other Ansible items).
The following rules apply when writing templates:
-
The templating language is Jinja2.
-
The following Jinja2 extensions are enabled for use by the template:
-
The filters provided by the jinja2-ansible-filters package. For a description, see Ansible built-in filters.
-
The
to_rstandto_mdfilters that are provided by the ansible-doc-template-extractor package. They convert text to RST and Markdown, respectively. They handle formatting and resolve Ansible-specific constructs such as "C(...)".
-
-
The following Jinja2 variables are set for use by the template:
-
name (str): Name of the Ansible role or playbook.
-
spec_file_name (str): Path name of the spec file.
-
spec_file_dict (dict): Content of the spec file.
-
Reporting issues
If you encounter a problem, please report it as an issue on GitHub.
License
This package is licensed under the Apache 2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ansible_doc_template_extractor-0.9.0.tar.gz.
File metadata
- Download URL: ansible_doc_template_extractor-0.9.0.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86bba476d96c32cb2c519da1d20cd2b01dbe4ecd3de3159f406a94266bc16d29
|
|
| MD5 |
af6a4e60bb0b671f77c4d0622bdb10e7
|
|
| BLAKE2b-256 |
dc9de8befbba46fe6ad1a0f7cd9ebef4e621485a3d158ed19d8ac7187732d832
|
Provenance
The following attestation bundles were made for ansible_doc_template_extractor-0.9.0.tar.gz:
Publisher:
publish.yml on andy-maier/ansible-doc-template-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansible_doc_template_extractor-0.9.0.tar.gz -
Subject digest:
86bba476d96c32cb2c519da1d20cd2b01dbe4ecd3de3159f406a94266bc16d29 - Sigstore transparency entry: 660924630
- Sigstore integration time:
-
Permalink:
andy-maier/ansible-doc-template-extractor@bc5603acef23ab15fb7544ea57d10dc49b64f9b5 -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/andy-maier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc5603acef23ab15fb7544ea57d10dc49b64f9b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ansible_doc_template_extractor-0.9.0-py3-none-any.whl.
File metadata
- Download URL: ansible_doc_template_extractor-0.9.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed87770e3876d487b7425bc9003555e3c245fc6b1aec0d860e17b24a2946030
|
|
| MD5 |
67486268fed19acf99d9ecec0d5ced21
|
|
| BLAKE2b-256 |
120979c07cf6238832d5b5fed0684ba078d20292adffa9fccf68735e7510ac13
|
Provenance
The following attestation bundles were made for ansible_doc_template_extractor-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on andy-maier/ansible-doc-template-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansible_doc_template_extractor-0.9.0-py3-none-any.whl -
Subject digest:
8ed87770e3876d487b7425bc9003555e3c245fc6b1aec0d860e17b24a2946030 - Sigstore transparency entry: 660924634
- Sigstore integration time:
-
Permalink:
andy-maier/ansible-doc-template-extractor@bc5603acef23ab15fb7544ea57d10dc49b64f9b5 -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/andy-maier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc5603acef23ab15fb7544ea57d10dc49b64f9b5 -
Trigger Event:
push
-
Statement type: