Debian Codegraph @

context/documentation-standards.md

raw
1 # Documentation standards
2
3 ## Module and plugin documentation
4
5 - Modules and plugins require `DOCUMENTATION`, `EXAMPLES`, and `RETURN` blocks as static YAML string variables.
6 - These blocks cannot be dynamically generated -- they are parsed via AST/token parsing.
7 - Alternative: "sidecar" documentation as `.yml` files with same stem name adjacent to plugin files.
8 - All modules should have a `main()` function and `if __name__ == '__main__':` block.
9 - Use `version_added` fields in documentation following existing version format patterns.
10 - Filter, test, and lookup plugins should declare positional arguments using the `positional` key in `DOCUMENTATION`.
11
12 ## Markup in plugin documentation blocks
13
14 Plugin `DOCUMENTATION`, `EXAMPLES`, and `RETURN` blocks use Ansible-specific markup, not reStructuredText or Markdown.
15
16 ### Semantic markup
17
18 - `O(name)` -- option name, optionally with a value: `O(state=present)`.
19 - `V(value)` -- option value mentioned alone: `V(present)`.
20 - `RV(name)` -- return value name, optionally with a value: `RV(changed=true)`.
21 - `E(name)` -- environment variable: `E(ANSIBLE_CONFIG)`.
22
23 Suboptions use dot-separated paths: `O(foo.bar)`.
24 Backslash escaping is supported inside these macros.
25
26 ### Formatting
27
28 - `C()` -- monospace/code text. Example: `This works like the unix command C(grep).`.
29 - `B()` -- bold text.
30 - `I()` -- italic text.
31
32 `C()`, `B()`, and `I()` do not support escaping, so they cannot contain `)`.
33
34 Use `V()` instead of `C()` when the value may contain `)`.
35
36 ### Linking
37
38 - `M(ansible.builtin.copy)` -- link to a module (FQCN required).
39 - `P(ansible.builtin.file#lookup)` -- link to a plugin (FQCN and type required).
40 - `L(title,https://example.com)` -- link with custom title.
41 - `U(https://example.com)` -- bare URL.
42 - `R(title,rst_anchor)` -- cross-reference to an RST anchor.
43
44 `O()` and `RV()` can also link to options/return values in other plugins using the syntax
45 `O(ansible.builtin.copy#module:src)`.
46
47 ## Changelog requirements
48
49 - Changes require entries in `changelogs/fragments/` as YAML files.
50 - Create a new fragment file per PR (never reuse existing fragments to avoid merge conflicts).
51 - Fragment structure follows sections defined in `changelogs/config.yaml` under the `sections` key.
52 - Verify changelog fragments use a valid section from `changelogs/config.yaml`.
53 - Naming: `{issue_number}-{short-description}.yml` or `{component}-{description}.yml` if no issue.
54 - Format: `- {component} - {description} ({optional URL to GH issue})`.
55 - Content supports Sphinx markup (use double backticks for code references).