Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/_autofix_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- [command-instead-of-shell](rules/command-instead-of-shell.md)
- [deprecated-local-action](rules/deprecated-local-action.md)
- [fqcn](rules/fqcn.md)
- [jinja](rules/jinja.md)
- [key-order](rules/key-order.md)
- [name](rules/name.md)
- [no-free-form](rules/no-free-form.md)
- [no-jinja-when](rules/no-jinja-when.md)
- [no-log-password](rules/no-log-password.md)
- [partial-become](rules/partial-become.md)
13 changes: 3 additions & 10 deletions docs/autofix.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ You can disable running transforms by setting `write_list: ["none"]`. Or only en

Following is the list of supported rules covered under autofix functionality.

- [command-instead-of-shell](rules/command-instead-of-shell.md#auto-fixing-capability)
- [deprecated-local-action](rules/deprecated-local-action.md)
- [fqcn](rules/fqcn.md)
- [jinja](rules/jinja.md)
- [key-order](rules/key-order.md)
- [name](rules/name.md)
- [no-free-form](rules/no-free-form.md)
- [no-jinja-when](rules/no-jinja-when.md)
- [no-log-password](rules/no-log-password.md)
- [partial-become](rules/partial-become.md)
```yaml
{!_autofix_rules.md!}
```
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ nav:
- Contributing: contributing.md
- custom-rules.md

exclude_docs: |
_autofix_rules.md

plugins:
- autorefs
- markdown-exec
Expand Down
38 changes: 32 additions & 6 deletions tools/generate_docs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
#!/bin/env python3
"""Script that tests rule markdown documentation."""
from __future__ import annotations

import subprocess
from pathlib import Path

from ansiblelint.cli import get_rules_dirs
from ansiblelint.config import Options
from ansiblelint.rules import RulesCollection, TransformMixin

if __name__ == "__main__":
subprocess.run(
"ansible-lint -L --format=md", # noqa: S607
shell=True, # noqa: S602
check=True,
stdout=subprocess.DEVNULL,
)

file = Path("docs/_autofix_rules.md")
options = Options()
options.rulesdirs = get_rules_dirs([])
options.list_rules = True
rules = RulesCollection(
options.rulesdirs,
options=options,
)
contents: list[str] = []
for rule in rules.alphabetical():
if issubclass(rule.__class__, TransformMixin):
url = f"rules/{rule.id}.md"
contents.append(f"- [{rule.id}]({url})\n")

subprocess.run(
"ansible-lint -L --format=md", # noqa: S607
shell=True, # noqa: S602
check=True,
stdout=subprocess.DEVNULL,
)
# Write the injected contents to the file.
with file.open(encoding="utf-8", mode="w") as fh:
fh.writelines(contents)