Support TI mode and soft float on PA64
[official-gcc.git] / contrib / check-params-in-docs.py
blob440549f5fd89dcbd67493d6319292898ec7f80b4
1 #!/usr/bin/env python3
3 # Find missing and extra parameters in documentation compared to
4 # output of: gcc --help=params.
6 # This file is part of GCC.
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.
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.
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/>. */
25 import argparse
26 import sys
27 from itertools import dropwhile, takewhile
30 def get_param_tuple(line):
31 line = line.strip().replace('--param=', '')
32 i = line.find(' ')
33 name = line[:i]
34 if '=' in name:
35 name = name[:name.find('=')]
36 description = line[i:].strip()
37 return (name, description)
40 parser = argparse.ArgumentParser()
41 parser.add_argument('texi_file')
42 parser.add_argument('params_output')
44 args = parser.parse_args()
46 ignored = {'logical-op-non-short-circuit'}
47 params = {}
49 for line in open(args.params_output).readlines():
50 if line.startswith(' '):
51 r = get_param_tuple(line)
52 params[r[0]] = r[1]
54 # Find section in .texi manual with parameters
55 texi = ([x.strip() for x in open(args.texi_file).readlines()])
56 texi = dropwhile(lambda x: 'item --param' not in x, texi)
57 texi = takewhile(lambda x: '@node Instrumentation Options' not in x, texi)
58 texi = list(texi)[1:]
60 token = '@item '
61 texi = [x[len(token):] for x in texi if x.startswith(token)]
62 # skip digits
63 texi = [x for x in texi if not x[0].isdigit()]
64 # skip aarch64 params
65 texi = [x for x in texi if not x.startswith('aarch64')]
66 sorted_texi = sorted(texi)
68 texi_set = set(texi) - ignored
69 params_set = set(params.keys()) - ignored
71 success = True
72 extra = texi_set - params_set
73 if len(extra):
74 print('Extra:')
75 print(extra)
76 success = False
78 missing = params_set - texi_set
79 if len(missing):
80 print('Missing:')
81 for m in missing:
82 print('@item ' + m)
83 print(params[m])
84 print()
85 success = False
87 if texi != sorted_texi:
88 print('WARNING: not sorted alphabetically!')
90 sys.exit(0 if success else 1)