@@ -6,32 +6,35 @@ def generate_rule_markdown(rule_data):
6
6
message = rule_data ['message' ]
7
7
markdown = f"### { message } \n \n "
8
8
markdown += f"**Level:** *{ rule_data ['level' ]} *\n \n "
9
+
9
10
if 'link' in rule_data :
10
11
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
+
19
20
if 'swap' in rule_data :
20
- markdown += "\n **Swap:**\n "
21
+ markdown += "**Swap:**\n "
21
22
if isinstance (rule_data ['swap' ], dict ):
22
23
for key , value in rule_data ['swap' ].items ():
23
24
markdown += f"- `{ key } ` -> `{ value } `\n "
24
25
elif isinstance (rule_data ['swap' ], list ):
25
26
for item in rule_data ['swap' ]:
26
27
markdown += f"- `{ item } `\n "
28
+ markdown += "\n "
29
+
27
30
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
+
30
33
return markdown
31
34
32
35
def process_subfolder (subfolder_path ):
33
36
markdown_content = ""
34
- for root , dirs , files in os .walk (subfolder_path ):
37
+ for root , _ , files in os .walk (subfolder_path ):
35
38
for file in files :
36
39
if file .endswith ('.yml' ):
37
40
with open (os .path .join (root , file ), 'r' ) as f :
@@ -47,7 +50,8 @@ def generate_table_of_contents(style_folders):
47
50
48
51
def main ():
49
52
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 ))]
51
55
52
56
markdown_content = "# Vale Linter Rules\n \n "
53
57
markdown_content += "This page provides a comprehensive list of the Vale linter rules used in Datadog documentation.\n \n "
0 commit comments