summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/generate_docs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ansiblelint/generate_docs.py')
-rw-r--r--src/ansiblelint/generate_docs.py11
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