From ba46240921ac7f70eef57c90e24923e528971d4f Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 21 Jan 2015 08:02:25 +0100 Subject: [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 --- test/CheckTexinfo.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/CheckTexinfo.py') 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', -- cgit v1.2.3