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 /tools | |
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 'tools')
-rwxr-xr-x | tools/generate_docs.py | 36 | ||||
-rwxr-xr-x | tools/test-hook.sh | 2 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tools/generate_docs.py b/tools/generate_docs.py new file mode 100755 index 0000000..9b2b5dc --- /dev/null +++ b/tools/generate_docs.py @@ -0,0 +1,36 @@ +#!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") + + # Write the injected contents to the file. + with file.open(encoding="utf-8", mode="w") as fh: + fh.writelines(contents) diff --git a/tools/test-hook.sh b/tools/test-hook.sh index 85d2d27..d83918e 100755 --- a/tools/test-hook.sh +++ b/tools/test-hook.sh @@ -12,7 +12,7 @@ set -euo pipefail rm -rf .tox/x mkdir -p .tox/x cd .tox/x -git init +git init --initial-branch=main # we add a file to the repo to avoid error due to no file to to lint touch foo.yml git add foo.yml |