wmllint: rewrite test of permitted tags in [part]

The tags are now tested directly, rather than as a parent of a key. The old
test was probably not missing tags like the test for illegal child of [if]
did, because [part] could be anywhere in ancestors. Anyway, [part] rarely
contains other tags.
This commit is contained in:
Groggy Dice 2013-12-22 22:10:02 -05:00
parent b68feb74f4
commit 20bc51302e

View file

@ -945,8 +945,11 @@ def local_sanity_check(filename, nav, key, prefix, value, comment):
if m and not m.group(1):
print errlead + 'translatability mark before non-string'
# Most tags are not allowed with [part]
if "[part]" in ancestors and parent not in ("[part]", "[image]", "[insert_tag]", "[if]", "[then]", "[else]", "[switch]", "[case]", "[variable]", "[deprecated_message]") and not parent.startswith("#"):
print errlead + '%s not permitted within [part] tag' % parent
if ("[part]" in ancestors or parent == "[part]") and isOpener(nav.element) and \
nav.element not in ("[part]", "[image]", "[insert_tag]",
"[if]", "[then]", "[else]", "[switch]", "[case]",
"[variable]", "[deprecated_message]"):
print errlead + '%s not permitted within [part] tag' % nav.element
# Most tags are not permitted inside [if]
if (len(ancestors) >= 1 and parent == "[if]") or \
(len(ancestors) >= 2 and parent == "#ifdef" and ancestors[-1] == "[if]"):