diff --git a/docs/Contributing.rst b/docs/Contributing.rst index 809929df6..d29c4acef 100644 --- a/docs/Contributing.rst +++ b/docs/Contributing.rst @@ -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 diff --git a/travis/script-in-readme.py b/travis/script-in-readme.py index b8ad67b65..66ea18605 100644 --- a/travis/script-in-readme.py +++ b/travis/script-in-readme.py @@ -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'):