Merge pull request #5431 from hexagonrecursion/wmllint-fix-comment-parsing
Fix comment parsing in wmllint
This commit is contained in:
commit
f0d51ac57f
1 changed files with 10 additions and 9 deletions
|
@ -1696,40 +1696,41 @@ def global_sanity_check(filename, lines):
|
|||
if line.startswith("#endif"):
|
||||
ifdef_stack.pop()
|
||||
continue
|
||||
if "[generator]" in line:
|
||||
precomment = line.split("#")[0]
|
||||
if "[generator]" in precomment:
|
||||
in_generator = True
|
||||
continue
|
||||
elif "[/generator]" in line:
|
||||
elif "[/generator]" in precomment:
|
||||
in_generator = False
|
||||
continue
|
||||
# do not use has_opening_tag() here, otherwise a [+side] tag
|
||||
# will make the sidecount variable incorrect
|
||||
elif "[side]" in line:
|
||||
elif "[side]" in precomment:
|
||||
in_side = True
|
||||
sidecount += 1
|
||||
continue
|
||||
elif "[/side]" in line:
|
||||
elif "[/side]" in precomment:
|
||||
if recruit or recruitment_pattern:
|
||||
sides.append((filename, recruit, recruitment_pattern))
|
||||
in_side = False
|
||||
recruit = {}
|
||||
recruitment_pattern = {}
|
||||
continue
|
||||
elif in_side and has_opening_tag(line, "ai"):
|
||||
elif in_side and has_opening_tag(precomment, "ai"):
|
||||
in_ai = True
|
||||
continue
|
||||
elif in_side and has_opening_tag(line, "unit"):
|
||||
elif in_side and has_opening_tag(precomment, "unit"):
|
||||
in_subunit = True
|
||||
continue
|
||||
elif in_side and "[/ai]" in line:
|
||||
elif in_side and "[/ai]" in precomment:
|
||||
in_ai = False
|
||||
continue
|
||||
elif in_side and "[/unit]" in line:
|
||||
elif in_side and "[/unit]" in precomment:
|
||||
in_subunit = False
|
||||
continue
|
||||
if "wmllint: skip-side" in line:
|
||||
sidecount += 1
|
||||
if not in_side or in_subunit or '=' not in line:
|
||||
if not in_side or in_subunit or '=' not in precomment:
|
||||
continue
|
||||
try:
|
||||
(key, prefix, value, comment) = parse_attribute(line)
|
||||
|
|
Loading…
Add table
Reference in a new issue