]>
git.ipfire.org Git - thirdparty/gcc.git/blob - contrib/check-params-in-docs.py
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
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
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/>. */
26 from itertools
import dropwhile
, takewhile
29 def get_param_tuple(line
):
30 line
= line
.strip().replace('--param=', '')
34 name
= name
[:name
.find('=')]
35 description
= line
[i
:].strip()
36 return (name
, description
)
39 parser
= argparse
.ArgumentParser()
40 parser
.add_argument('texi_file')
41 parser
.add_argument('params_output')
43 args
= parser
.parse_args()
45 ignored
= set(['logical-op-non-short-circuit'])
48 for line
in open(args
.params_output
).readlines():
49 if line
.startswith(' '):
50 r
= get_param_tuple(line
)
53 # Find section in .texi manual with parameters
54 texi
= ([x
.strip() for x
in open(args
.texi_file
).readlines()])
55 texi
= dropwhile(lambda x
: 'item --param' not in x
, texi
)
56 texi
= takewhile(lambda x
: '@node Instrumentation Options' not in x
, texi
)
60 texi
= [x
[len(token
):] for x
in texi
if x
.startswith(token
)]
61 sorted_texi
= sorted(texi
)
63 texi_set
= set(texi
) - ignored
64 params_set
= set(params
.keys()) - ignored
66 extra
= texi_set
- params_set
71 missing
= params_set
- texi_set
79 if texi
!= sorted_texi
:
80 print('WARNING: not sorted alphabetically!')