Require a short help string for "ls"

The linter change will enforce it for scripts.  Plugins always include
the line, and length will have to be checked manually.
develop
PeridexisErrant 2015-11-10 13:20:12 +11:00
parent 3ab963499a
commit feff83cedc
2 changed files with 21 additions and 3 deletions

@ -137,6 +137,11 @@ there are a few important standards for completeness and consistent style. Trea
this section as a guide rather than iron law, match the surrounding text, and you'll
be fine.
Each command should have a short (~54 character) help string, which is shown
by the `ls` command. For scripts, this is a comment on the first line
(the comment marker and whitespace is stripped). For plugins it's the second
argument to ``PluginCommand``. Please make this brief but descriptive!
Everything should be documented! If it's not clear *where* a particular
thing should be documented, ask on IRC or in the DFHack thread on Bay12 -
as well as getting help, you'll be providing valuable feedback that

@ -13,12 +13,25 @@ def expected_cmd(path):
return fname
def check_ls(fname, line):
"""Check length & existence of leading comment for "ls" builtin command."""
line = line.strip()
comment = '--' if fname.endswith('.lua') else '#'
if line.endswith('=begin') or not line.startswith(comment):
print('Error: no leading comment in ' + fname)
return 1
if len(line.replace(comment, '').strip()) > 53:
print('Error: leading comment too long in ' + fname)
return 1
return 0
def check_file(fname):
errors, doclines = 0, []
with open(fname, errors='ignore') as f:
for l in f.readlines():
if not l.strip():
continue
lines = f.readlines()
errors += check_ls(fname, lines[0])
for l in lines:
if doclines or l.strip().endswith('=begin'):
doclines.append(l.rstrip())
if l.startswith('=end'):