diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:24:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:24:58 +0000 |
commit | ba233a0cbad76b4783a03893e7bf4716fbc0f0ec (patch) | |
tree | ad369728c1edbe3631c8150585659078ae5d7d0b /src/ansiblelint/generate_docs.py | |
parent | Releasing progress-linux version 6.17.2-3~progress7.99u1. (diff) | |
download | ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.tar.xz ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.zip |
Merging upstream version 24.6.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ansiblelint/generate_docs.py')
-rw-r--r-- | src/ansiblelint/generate_docs.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ansiblelint/generate_docs.py b/src/ansiblelint/generate_docs.py index 1498a67..6e319fb 100644 --- a/src/ansiblelint/generate_docs.py +++ b/src/ansiblelint/generate_docs.py @@ -1,4 +1,5 @@ """Utils to generate rules documentation.""" + import logging from collections.abc import Iterable @@ -9,7 +10,7 @@ from rich.table import Table from ansiblelint.config import PROFILES from ansiblelint.constants import RULE_DOC_URL -from ansiblelint.rules import RulesCollection +from ansiblelint.rules import RulesCollection, TransformMixin DOC_HEADER = """ # Default Rules @@ -27,6 +28,8 @@ def rules_as_str(rules: RulesCollection) -> RenderableType: """Return rules as string.""" table = Table(show_header=False, header_style="title", box=box.SIMPLE) for rule in rules.alphabetical(): + if issubclass(rule.__class__, TransformMixin): + rule.tags.insert(0, "autofix") tag = f"[dim] ({', '.join(rule.tags)})[/dim]" if rule.tags else "" table.add_row( f"[link={RULE_DOC_URL}{rule.id}/]{rule.id}[/link]", @@ -56,6 +59,12 @@ def rules_as_md(rules: RulesCollection) -> str: result += f"\n\n## {title}\n\n**{rule.shortdesc}**\n\n{description}" + # Safety net for preventing us from adding autofix to rules and + # forgetting to mention it inside their documentation. + if "autofix" in rule.tags and "autofix" not in rule.description: + msg = f"Rule {rule.id} is invalid because it has 'autofix' tag but this ability is not documented in its description." + raise RuntimeError(msg) + return result |