Skip to main content

Documentation engine for YAML.

Project description

Documentation Engine for YAML

PyPI version CircleCI codecov Downloads

This package converts a YAML file into markdown, formatting values and associated metadata in a doxygen-like way. To get started, check out the documentation and tutorials.

Installation

pip install yamldoc

This will install the python package, which contains a command line interface yamldoc. To see usage instructions, invoke the --help flag:

yamldoc -h

Features and Supported Syntax

yamldoc does not support the full syntax of YAML, which is vast and complex. Instead, it supports a subset of YAML that is useful for documenting configuration files. This subset includes:

Syntax Supported Description
key: value Yes Basic key-value pairs. Values can be any type and are not subject to coercion. (i.e. yes will remain yes in yamldoc output. It will not be coerced to True as a YAML parser would. The goal of yamldoc is to be transparent, not feature complete.
key: [value1, value2, ...] Yes Arrays are understood by yamldoc if they are either listed on one line or each entry given on a new line with dashes to indicate entries.
Comments Yes Non-yamldoc comments are ignored. yamldoc comments are indicated by a special character (default #') at the beginning of the line. yamldoc comments can be broken over as many lines as you like, they will be added together when the markdown is constructed.

Things YAML does not support:

  • Nested arrays past two levels of nesting. yamldoc will not parse nested arrays past two levels of nesting. Issue #14 tracks this request.
  • Multi-line strings (unquoted or quoted scalars) indicated by | or > are not supported.
  • Lists of dictionaries are not supported.
  • Multiple documents in a single file are supported, but no special handling is done to separate them. It is assumed that each document is a separate configuration file.
  • Complex mapping keys starting with !! or ? are not supported. yamldoc will not parse complex mappings, tags, or explicit tags.

Philosophy

Many programs and utilities use YAML (YAML Ain't Markup Language) as a human and machine readable interface to configuration parameters and other values. More broadly, many kinds of data can be stored in YAML with minimal effort from the user. However, often a configuration file accumulates a highly specific set of configurations marked up with vague, difficult to interpret comments. It is the goal of this package to provide an easy interface for developers to document data in their YAML files as well as the expected types from a JSON YAML schema validator. Doing so will allow a transparent interface between the developer's expectations and the user's configurations.

Specific Application to Snakemake

This package was designed specifically to document the possible configuration options of a Snakemake pipeline. In this application, the developer of the pipeline encodes many different specific options that the user may configure at run time, but these are often poorly documented. When they are, it is easy for the documentation to fall out of sync with the actual options in the configuration file. yamldoc automatically documents all configuration paramters as well as taking types from a schema file. The package will also read any comments that are present above each paramter and insert them into a parameter table for easy reference.

For more details on using YAML to configure Snakemake pipelines, see here.

Example Files

For a minimal example of yamldoc, see the files in /test/yaml and /test/schema.

Usage

For a basic report, point the command line interface to a YAML file.

yamldoc test/yaml/basic.yaml

You can also include type information from a schema file.

yamldoc test/yaml/basic.yaml -s test/schema/basic.schema

Other Options

yamldoc defaults to using #' as a special marker, but you can choose this character yourself if you wish. Just set it on the command line at parse-time:

yamldoc test/yaml/basic.yaml -c "YOURCHAR"

yamldoc also includes support for certain special declarations in the schema file. Right now these include:

  • _yamldoc_title: This specifies the overall title of the markdown page generated.
  • _yamldoc_description: A description to follow the title.

These are picked out of the schema file and reported.

yamldoc has support for skipping individual entries in the reported markdown. Note this is seperate from adding comments that are not meta-data, these are respected and never reported. Skipping refers to actual entries in the YAML file. To skip an entry, add the skip character (by default, #'!) to the beginning of the line.

# This is a comment, it will not be reported
#' This entry will be included in the report 
entry1: value1

#'! This entry will be skipped
entry2: value2

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

yamldoc-0.3.7.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

yamldoc-0.3.7-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file yamldoc-0.3.7.tar.gz.

File metadata

  • Download URL: yamldoc-0.3.7.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yamldoc-0.3.7.tar.gz
Algorithm Hash digest
SHA256 491d9c7328be7bafd971aba592525d093998a91d2e08916548a8bf18c6f035bc
MD5 17014813f5dc98a641862227b72a9b43
BLAKE2b-256 007058303ee92645fb3c8c99ec0319e9f9ef59bd0aebf76517417f4d3557cb2a

See more details on using hashes here.

File details

Details for the file yamldoc-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: yamldoc-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yamldoc-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5545479ff18726b0b95f93ca36cbc68a142f6e4e1e9428fcc3e94eed76a9a4a0
MD5 26fca3ae54c38bae57203d93d4437205
BLAKE2b-256 bc372091173c537fa2e63aabd5eea9eb92b597a60dc49a54b7e910a7fa60a9e5

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