This script will generate Markdown sections from the contents of an Ansible role's meta/argument_specs.yml.
Each variable found in the argument specs will result in a block in the following style:
| Type | Default | Required |
|---|---|---|
| string | default value here |
❌/✅ |
Raw, this looks like:
### `option_name`
| Type | Default | Required |
| ------ | -------------------- | -------- |
| string | `default value here` | ❌/✅ |- The generated markdown will be inserted into the README.md file between the markers below if they are found. If they are not found, the markdown will be dumped to stdout.
- Begin marker:
<!-- BEGIN ANSIBLE ROLE VARIABLES --> - End marker:
<!-- END ANSIBLE ROLE VARIABLES -->
- Begin marker:
- Any single quotes (
') that seem to be wrapping a value (as opposed to being used as grammatical syntax, e.g. as an apostrophe) will be replaced with backticks. For example:- Before: Set this variable's value to 'null' to omit
- After: Set this variable's value to
nullto omit
- Bare URLs will be wrapped in angle brackets (
<>). - Any lines in the
descriptionkeys starting with one of the following (case-insensitive) will be converted to a matching GitHub markdown callout (as shown here):NOTE:TIP:IMPORTANT:WARNING:CAUTION:
For example, given the following meta/argument_specs.yml:
argument_specs:
main:
...
options:
myapp_int:
type: "int"
required: false
default: 42
description:
- "The integer value, defaulting to '42'."
- "This is a second paragraph."
myapp_str:
type: "str"
required: true
description: "The string's value description."
myapp_list:
type: "list"
elements: "str"
required: true
description:
- "A list of string values."
- "Note: This is a notice callout"
version_added: 1.3.0The following Markdown will be generated:
| Type | Default | Required |
|---|---|---|
| int | 42 |
❌ |
The integer value, defaulting to 42.
This is a second paragraph.
| Type | Default | Required |
|---|---|---|
| string | None | ✅ |
The string's value description.
| Type | Default | Required |
|---|---|---|
| list[str] | None | ✅ |
A list of string values.
Note
This is a notice callout
Raw, this looks like:
### `myapp_int`
| Type | Default | Required |
| ---- | ------- | -------- |
| int | `42` | ❌ |
The integer value, defaulting to `42`.
This is a second paragraph.
### `myapp_str`
| Type | Default | Required |
| ------ | ------- | -------- |
| string | None | ✅ |
The string's value description.
### `myapp_list`
| Type | Default | Required |
| --------- | ------- | -------- |
| list[str] | None | ✅ |
A list of string values.
> [!NOTE]
> This is a notice callout