diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2015-01-21 08:02:25 +0100 |
---|---|---|
committer | Alexis Hildebrandt <afh@surryhill.net> | 2015-01-21 08:03:53 +0100 |
commit | ba46240921ac7f70eef57c90e24923e528971d4f (patch) | |
tree | f0affce96178171305065b2a6b4cadc07b50e753 /test/CheckTexinfo.py | |
parent | c7a30bf7d8e2b79624925a6f27281a0297217398 (diff) | |
download | fork-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-x | test/CheckTexinfo.py | 34 |
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', |