summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
commitba233a0cbad76b4783a03893e7bf4716fbc0f0ec (patch)
treead369728c1edbe3631c8150585659078ae5d7d0b /tools
parentReleasing progress-linux version 6.17.2-3~progress7.99u1. (diff)
downloadansible-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-xtools/generate_docs.py36
-rwxr-xr-xtools/test-hook.sh2
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