Mercurial > hg > CbC > CbC_gcc
comparison contrib/check-params-in-docs.py @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 #!/usr/bin/env python3 | |
2 # | |
3 # Find missing and extra parameters in documentation compared to | |
4 # output of: gcc --help=params. | |
5 # | |
6 # This file is part of GCC. | |
7 # | |
8 # GCC is free software; you can redistribute it and/or modify it under | |
9 # the terms of the GNU General Public License as published by the Free | |
10 # Software Foundation; either version 3, or (at your option) any later | |
11 # version. | |
12 # | |
13 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 # for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with GCC; see the file COPYING3. If not see | |
20 # <http://www.gnu.org/licenses/>. */ | |
21 # | |
22 # | |
23 # | |
24 | |
25 import sys | |
26 import json | |
27 import argparse | |
28 | |
29 from itertools import * | |
30 | |
31 def get_param_tuple(line): | |
32 line = line.strip() | |
33 i = line.find(' ') | |
34 return (line[:i], line[i:].strip()) | |
35 | |
36 parser = argparse.ArgumentParser() | |
37 parser.add_argument('texi_file') | |
38 parser.add_argument('params_output') | |
39 | |
40 args = parser.parse_args() | |
41 | |
42 params = {} | |
43 | |
44 for line in open(args.params_output).readlines(): | |
45 if line.startswith(' '): | |
46 r = get_param_tuple(line) | |
47 params[r[0]] = r[1] | |
48 | |
49 # Find section in .texi manual with parameters | |
50 texi = ([x.strip() for x in open(args.texi_file).readlines()]) | |
51 texi = dropwhile(lambda x: not 'item --param' in x, texi) | |
52 texi = takewhile(lambda x: not '@node Instrumentation Options' in x, texi) | |
53 texi = list(texi)[1:] | |
54 | |
55 token = '@item ' | |
56 texi = [x[len(token):] for x in texi if x.startswith(token)] | |
57 sorted_texi = sorted(texi) | |
58 | |
59 texi_set = set(texi) | |
60 params_set = set(params.keys()) | |
61 | |
62 extra = texi_set - params_set | |
63 if len(extra): | |
64 print('Extra:') | |
65 print(extra) | |
66 | |
67 missing = params_set - texi_set | |
68 if len(missing): | |
69 print('Missing:') | |
70 for m in missing: | |
71 print('@item ' + m) | |
72 print(params[m]) | |
73 print() | |
74 | |
75 if texi != sorted_texi: | |
76 print('WARNING: not sorted alphabetically!') |