Skip to content

Commit 86291bb

Browse files
committed
Rename file. Add workflow.
1 parent b1eba5f commit 86291bb

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Generate Rule Overview Page
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- brett0000FF/generate-rules-page
8+
paths:
9+
- 'styles/**'
10+
- '.github/workflows/generate-rule-markdown.yml'
11+
12+
jobs:
13+
generate_markdown:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.x
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install pyyaml
28+
29+
- name: Run script to generate Markdown
30+
run: python generate-overview.py
31+
32+
- name: Commit and push changes
33+
run: |
34+
git config --local user.email "action@github.com"
35+
git config --local user.name "GitHub Action"
36+
git add rules_overview.md
37+
git commit -m "Update rules overview Markdown" || echo "No changes to commit"
38+
git push

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Docshtml.zip
22
Docsmd.zip
3-
rules_overview.md
43
.DS_Store

scripts/generate-reference.py scripts/generate-overview.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@ def generate_rule_markdown(rule_data):
66
message = rule_data['message']
77
markdown = f"### {message}\n\n"
88
markdown += f"**Level:** *{rule_data['level']}*\n\n"
9+
910
if 'link' in rule_data:
1011
markdown += f"[Link]({rule_data['link']})\n\n"
11-
if 'tokens' in rule_data:
12-
markdown += "**Tokens:**\n"
13-
for token in rule_data['tokens']:
14-
markdown += f"- `{token}`\n"
15-
if 'exceptions' in rule_data:
16-
markdown += "\n**Exceptions:**\n"
17-
for exception in rule_data['exceptions']:
18-
markdown += f"- `{exception}`\n"
12+
13+
for field in ['tokens', 'exceptions']:
14+
if field in rule_data:
15+
markdown += f"**{field.capitalize()}:**\n"
16+
for item in rule_data[field]:
17+
markdown += f"- `{item}`\n"
18+
markdown += "\n"
19+
1920
if 'swap' in rule_data:
20-
markdown += "\n**Swap:**\n"
21+
markdown += "**Swap:**\n"
2122
if isinstance(rule_data['swap'], dict):
2223
for key, value in rule_data['swap'].items():
2324
markdown += f"- `{key}` -> `{value}`\n"
2425
elif isinstance(rule_data['swap'], list):
2526
for item in rule_data['swap']:
2627
markdown += f"- `{item}`\n"
28+
markdown += "\n"
29+
2730
if 'ignorecase' in rule_data:
28-
markdown += f"\n**Ignore Case:** {rule_data['ignorecase']}\n"
29-
markdown += "\n"
31+
markdown += f"**Ignore Case:** {rule_data['ignorecase']}\n\n"
32+
3033
return markdown
3134

3235
def process_subfolder(subfolder_path):
3336
markdown_content = ""
34-
for root, dirs, files in os.walk(subfolder_path):
37+
for root, _, files in os.walk(subfolder_path):
3538
for file in files:
3639
if file.endswith('.yml'):
3740
with open(os.path.join(root, file), 'r') as f:
@@ -47,7 +50,8 @@ def generate_table_of_contents(style_folders):
4750

4851
def main():
4952
styles_folder = 'styles'
50-
style_folders = [folder for folder in os.listdir(styles_folder) if os.path.isdir(os.path.join(styles_folder, folder))]
53+
style_folders = [folder for folder in os.listdir(styles_folder)
54+
if os.path.isdir(os.path.join(styles_folder, folder))]
5155

5256
markdown_content = "# Vale Linter Rules\n\n"
5357
markdown_content += "This page provides a comprehensive list of the Vale linter rules used in Datadog documentation.\n\n"

0 commit comments

Comments
 (0)