Add check for missing userscript description

This commit is contained in:
Florian Bruhin 2019-09-25 16:03:42 +02:00
parent d0e8d22ae0
commit ad83f4c340
2 changed files with 38 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import subprocess
import tokenize
import traceback
import collections
import pathlib
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir))
@ -146,9 +147,42 @@ def check_vcs_conflict():
return None
def check_userscripts_descriptions():
"""Make sure all userscripts are described properly."""
folder = pathlib.Path('misc/userscripts')
readme = folder / 'README.md'
described = set()
for line in readme.open('r'):
line = line.strip()
if line == '## Others':
break
match = re.fullmatch(r'- \[([^]]*)\].*', line)
if match:
described.add(match.group(1))
present = {path.name for path in folder.iterdir()}
present.remove('README.md')
missing = present - described
additional = described - present
ok = True
if missing:
print("Missing userscript descriptions: {}".format(missing))
ok = False
if additional:
print("Additional userscript descriptions: {}".format(additional))
ok = False
return ok
def main():
parser = argparse.ArgumentParser()
parser.add_argument('checker', choices=('git', 'vcs', 'spelling'),
parser.add_argument('checker',
choices=('git', 'vcs', 'spelling', 'userscripts'),
help="Which checker to run.")
args = parser.parse_args()
if args.checker == 'git':
@ -157,6 +191,8 @@ def main():
ok = check_vcs_conflict()
elif args.checker == 'spelling':
ok = check_spelling()
elif args.checker == 'userscripts':
ok = check_userscripts_descriptions()
return 0 if ok else 1

View File

@ -75,6 +75,7 @@ commands =
{envpython} scripts/dev/misc_checks.py git
{envpython} scripts/dev/misc_checks.py vcs
{envpython} scripts/dev/misc_checks.py spelling
{envpython} scripts/dev/misc_checks.py userscripts
[testenv:vulture]
basepython = {env:PYTHON:python3}