Skip to main content

Linting/reformatting tool for YAML files documented with inline RST

Project description

Build Status Read the Docs CII Best Practices Code Coverage Status
Version License Python versions dev status pypi monthly downloads

yaml4rst is a linting/checking/reformatting tool for YAML files documented with inline RST which goes hand in hand with yaml2rst.

It has been written to help with keeping the defaults/main.yml file in Ansible roles, maintained in DebOps, up-to-date and to assist with writing or including new roles. DebOps uses Sphinx to generate Ansible role documentation which also includes the default role variables. Refer to debops/docs for details.

Usage

The typical use case for this program is to improve the defaults YAML file of Ansible roles.

The recommended way to do this is to commit all your changes in the repository of the role, then run:

yaml4rst -e 'ansible_full_role_name=ROLE_OWNER.ROLE_NAME' defaults/main.yml -i

from the root of the role repository. Be sure to replace ROLE_OWNER.ROLE_NAME with the particular Ansible role name.

This will check and reformat the defaults/main.yml file in place.

Now you can check the reformatted file with a diffing/editing tool of your choosing and fix any warning which yaml4rst might have emitted.

Refer to input_files and output_files in the tests directory for automatically tested examples of input and output files.

Note that for continues usage yaml4rst is invoked from debops-optimize when yaml4rst is installed so you might want to try debops-optimize.

Features

Checks for:

  • Reasonable variable namespace

  • Undocumented variables

Automatically fixes:

  • RST sections which are not folds

  • Undocumented variables (adds a FIXME for the user)

  • Documented variables which are not folds

  • YAML documents without a defined header

  • Spacing between variables and sections

Known limitations

  • Does not handle folds with implicit level and missing closing fold marker.

    Status: Should be doable but currently not needed nor implemented. A NotImplementedError exception is thrown which causes the CLI program to terminate immediately with an error and reference to this section.

    As workaround just strip out the opening folds with your favorite editor as yaml4rst will add missing folds for sections and variables anyway. Refer to the Makefile (prepare-real-data target) where such a workaround is used for integration testing. Note that this is not perfect as can be seen on the debops.apt_install test case.

Authors

License

GNU Affero General Public License v3 (AGPL-3.0)

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

yaml4rst-0.1.2.tar.gz (106.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaml4rst-0.1.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file yaml4rst-0.1.2.tar.gz.

File metadata

  • Download URL: yaml4rst-0.1.2.tar.gz
  • Upload date:
  • Size: 106.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yaml4rst-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1eb869913201111616d748344bea6157f1beff0ad3e381684fdd491ec6226d1f
MD5 afa9133a18f38dbc110c55e8aa0f684b
BLAKE2b-256 25fa8ef2294ea76788667318db5a8fec44fa1f221f1fd369874bf94a9c3ce7f8

See more details on using hashes here.

File details

Details for the file yaml4rst-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for yaml4rst-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 41717f9a9b203f65eedfafc5e5628a5e5d63ab70d7580e578b181c4a2cb84d26
MD5 6ae0dccec2648868a237e03c35e1409f
BLAKE2b-256 0fdf349b1e6fe9fe99b13afb2803957c77240dc58b8f0c692245f12ef4519065

See more details on using hashes here.

Supported by

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