Skip to content

About

pre-commit hook to generate Ansible role documentation with aar-doc.

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pre-commit-aar-doc

pre-commit hook to generate the documentation of Ansible roles with aar-doc.

The hook runs aar-doc <role> markdown for every role in the roles directory that has a meta/argument_specs.yml (or .yaml). If a README changes, the commit is aborted: review and stage the updated README and commit again. This way the role documentation can't be forgotten anymore.

Usage

Add the hook to the .pre-commit-config.yaml of your Ansible collection:

---
repos:
  - repo: https://github.com/lingfra/pre-commit-aar-doc
    rev: v1.1.0
    hooks:
      - id: aar-doc

And install the git hook:

pre-commit install

aar-doc is installed by pre-commit in the version pinned by this hook (see pyproject.toml). It doesn't need to be installed separately.

The hook runs on every commit, because the documentation also depends on files pre-commit doesn't pass to hooks, for example a bumped git submodule with templates like aar-doc-config.

Arguments

Argument Description
--roles-dir DIR Directory containing the roles, relative to the repository root. Can be given multiple times. Default: roles.
--config-file FILE aar-doc configuration file. Default: .aar_doc.yml.
--output-template TEMPLATE aar-doc output template as string or path to a file. Default: from the configuration file.

All other arguments are passed to aar-doc as options, for example --output-file:

      - id: aar-doc
        args: [--roles-dir, ansible/roles, --config-file, ansible/.aar_doc.yml, --output-file, DOCS.md]

aar-doc is executed from the repository root, so its default configuration file .aar_doc.yml is read from there.

If the output template is configured as a file path, the hook fails when the file doesn't exist instead of letting aar-doc use the path itself as template. This happens if the template is provided by a git submodule that isn't checked out yet:

git submodule update --init

The hook also fails if a meta/argument_specs.yml isn't valid YAML, instead of removing the generated documentation from the README.

License

The Unlicense

About

pre-commit hook to generate Ansible role documentation with aar-doc.

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages