File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
scripts/knowledgebase-checker Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -38,20 +38,18 @@ def check_yaml_tags(directory, allowed_tags):
38
38
try :
39
39
frontmatter_data = yaml .safe_load (frontmatter_str )
40
40
# check tags exist and are one of the allowed tags
41
- is_correct = False
41
+ tagged_correct = False
42
+ has_description = False
43
+ has_precontent_tags = False
42
44
43
45
# check that KB articles are tagged with one of the correct tags
44
46
if 'tags' in frontmatter_data and frontmatter_data ['tags' ] is not None :
45
47
if all (tag in allowed_tags for tag in frontmatter_data ['tags' ]):
46
- is_correct = True
47
- else :
48
- is_correct = False
48
+ tagged_correct = True
49
49
50
50
# check that KB articles have a description
51
51
if 'description' in frontmatter_data and frontmatter_data ['description' ] is not None :
52
- is_correct = True
53
- else :
54
- is_correct = False
52
+ has_description = True
55
53
56
54
# check that KB articles contain the appropriate tags (given by pattern below) before the article content:
57
55
@@ -60,12 +58,10 @@ def check_yaml_tags(directory, allowed_tags):
60
58
61
59
pattern = r"\{frontMatter.description\}\n\{\/\* truncate \*\/\}\n"
62
60
if bool (re .search (pattern , content , flags = re .DOTALL )):
63
- is_correct = True
64
- else :
65
- is_correct = False
61
+ has_precontent_tags = True
66
62
67
63
# add filename as appropriate if issues occured
68
- if is_correct is True :
64
+ if tagged_correct and has_description and has_precontent_tags :
69
65
correctly_tagged_files .append (filename )
70
66
else :
71
67
incorrectly_tagged_files .append (filename )
You can’t perform that action at this time.
0 commit comments