summaryrefslogtreecommitdiff
path: root/test/CheckTexinfo.py
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2015-01-21 08:02:25 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2015-01-21 08:03:53 +0100
commitba46240921ac7f70eef57c90e24923e528971d4f (patch)
treef0affce96178171305065b2a6b4cadc07b50e753 /test/CheckTexinfo.py
parentc7a30bf7d8e2b79624925a6f27281a0297217398 (diff)
downloadfork-ledger-ba46240921ac7f70eef57c90e24923e528971d4f.tar.gz
fork-ledger-ba46240921ac7f70eef57c90e24923e528971d4f.tar.bz2
fork-ledger-ba46240921ac7f70eef57c90e24923e528971d4f.zip
[tests] Improve option parsing in CheckTexinfo.py
* Replace @ftable @code argument with @option of @command depending on the documented items * Remove @c option comment from @items documenting options
Diffstat (limited to 'test/CheckTexinfo.py')
-rwxr-xr-xtest/CheckTexinfo.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/CheckTexinfo.py b/test/CheckTexinfo.py
index c289da68..eedd975d 100755
--- a/test/CheckTexinfo.py
+++ b/test/CheckTexinfo.py
@@ -20,6 +20,40 @@ class CheckTexinfo (CheckOptions):
self.source_file = join(self.source, 'doc', 'ledger3.texi')
self.source_type = 'texinfo'
+ def find_options(self, filename):
+ options = set()
+ state_normal = 0
+ state_option_table = 1
+ state = state_normal
+ option = None
+ opt_doc = str()
+ item_regex = re.compile('^@item --([-A-Za-z]+)')
+ itemx_regex = re.compile('^@itemx')
+ fix_regex = re.compile('FIX')
+ for line in open(filename):
+ line = line.strip()
+ if state == state_normal:
+ if line == '@ftable @option':
+ state = state_option_table
+ elif state == state_option_table:
+ if line == '@end ftable':
+ if option and len(opt_doc) and not fix_regex.search(opt_doc):
+ options.add(option)
+ state = state_normal
+ option = None
+ continue
+ match = item_regex.match(line)
+ if match:
+ if option and len(opt_doc) and not fix_regex.search(opt_doc):
+ options.add(option)
+ option = match.group(1)
+ opt_doc = str()
+ elif itemx_regex.match(line):
+ continue
+ else:
+ opt_doc += line
+ return options
+
if __name__ == "__main__":
def getargs():
parser = argparse.ArgumentParser(prog='CheckTexinfo',