Skip to main content

Extract Ansible module documentation

Project description

This package contains code for Ansible collection documentation extractor. Its main audience are Ansible collection maintainers that would like to publish API docs in the HTML form without having to manually copy the data already present in the module’s metadata.

Quickstart

Documentation extractor is published on PyPI and we can install it using pip:

$ pip install ansible-doc-extractor  # If we already have ansible installed
$ pip install ansible-doc-extractor[ansible]  # To also install ansible
$ pip install ansible-doc-extractor[base]  # To also install ansible-base
$ pip install ansible-doc-extractor[core]  # To also install ansible-core

If the previous command did not fail, we are ready to start extracting the documentation:

$ ansible-doc-extractor \
    /tmp/output-folder \
    ~/.ansible/collections/ansible_collections/my/col/plugins/modules/*.py

This will extract the documentation from modules in my.col collection and place resulting rst files into /tmp/output-folder.

RST and Markdown support

By default ansible-doc-extractor will output files in .rst format using the built-in Jinja2 template for rst. Pass the --markdown flag to output files in markdown.

Custom template

ansible-doc-extractor supports a custom Jinja2 template file via --template. The following variables are sent to the template:

Variable name

Type

Description

Module’s documentation key

short_description

str

Short description of a module.

short_description

description

str / list

Longer description of a module, type depends on the module’s description type.

description

requirements

list

Requirements needed on the host that executes this module.

requirements

options

dict

All module options, often called parameters or arguments.

options

notes

list

Module’s additional notes.

notes

seealso

list

Details of any important information that doesn’t fit in one of the above sections.

seealso

deprecated

str

Marks modules that will be removed in future releases

deprecated

author

str / list

Author of the module, type can vary depending on how many authors module has.

author

metadata

dict

This section provides information about the module

Refers to ANSIBLE_METADATA block in the module.

examples

str

Code examples

Refers to EXAMPLES block in the module.

returndocs

dict

This section documents the information the module returns.

Refers to RETURN block in the module.

The output files will use the same file extension as the custom template file.

You can always refer to the default Jinja2 template for rst and the default Jinja2 template for markdown.

Development setup

Getting development environment up and running is relatively simple:

$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install -e .

To test the extractor, we can run:

$ ansible-doc-extractor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible-doc-extractor-0.1.8.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

ansible_doc_extractor-0.1.8-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file ansible-doc-extractor-0.1.8.tar.gz.

File metadata

  • Download URL: ansible-doc-extractor-0.1.8.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for ansible-doc-extractor-0.1.8.tar.gz
Algorithm Hash digest
SHA256 3bb88d45a8bb3f4ec92646da2b6d68be9288e175f4c6ec570428ac3a819e2b87
MD5 f2f84af05ab3aabc4f13f7a7eaf55cd1
BLAKE2b-256 df1d1845c1b4a57f77114cec8ad22539f747cb5a4c9353c4fcc1eb4933f8cbba

See more details on using hashes here.

File details

Details for the file ansible_doc_extractor-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: ansible_doc_extractor-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for ansible_doc_extractor-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c381dd9a039c0bb8ba97e754e3fcb1d0f904bbbf8080ea44a4a3391f0f851501
MD5 520c45718dce55bc6d739572792a1400
BLAKE2b-256 730830da39989a956a56820a3a6b50b48ff0bea71b62a99ea4c48c4f54c50192

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page