39 |
39 |
40 ignorere = re.compile(br''' |
40 ignorere = re.compile(br''' |
41 \#\s(?P<reason>internal|experimental|deprecated|developer|inconsistent)\s |
41 \#\s(?P<reason>internal|experimental|deprecated|developer|inconsistent)\s |
42 config:\s(?P<config>\S+\.\S+)$ |
42 config:\s(?P<config>\S+\.\S+)$ |
43 ''', re.VERBOSE | re.MULTILINE) |
43 ''', re.VERBOSE | re.MULTILINE) |
|
44 |
|
45 if sys.version_info[0] > 2: |
|
46 def mkstr(b): |
|
47 if isinstance(b, str): |
|
48 return b |
|
49 return b.decode('utf8') |
|
50 else: |
|
51 mkstr = lambda x: x |
44 |
52 |
45 def main(args): |
53 def main(args): |
46 for f in args: |
54 for f in args: |
47 sect = b'' |
55 sect = b'' |
48 prevname = b'' |
56 prevname = b'' |
90 documented[m.group(1)] = 1 |
98 documented[m.group(1)] = 1 |
91 |
99 |
92 # look for ignore markers |
100 # look for ignore markers |
93 m = ignorere.search(l) |
101 m = ignorere.search(l) |
94 if m: |
102 if m: |
95 if m.group('reason') == 'inconsistent': |
103 if m.group('reason') == b'inconsistent': |
96 allowinconsistent.add(m.group('config')) |
104 allowinconsistent.add(m.group('config')) |
97 else: |
105 else: |
98 documented[m.group('config')] = 1 |
106 documented[m.group('config')] = 1 |
99 |
107 |
100 # look for code-like bits |
108 # look for code-like bits |
104 ctype = m.group('ctype') |
112 ctype = m.group('ctype') |
105 if not ctype: |
113 if not ctype: |
106 ctype = 'str' |
114 ctype = 'str' |
107 name = m.group('section') + b"." + m.group('option') |
115 name = m.group('section') + b"." + m.group('option') |
108 default = m.group('default') |
116 default = m.group('default') |
109 if default in (None, 'False', 'None', '0', '[]', '""', "''"): |
117 if default in ( |
|
118 None, b'False', b'None', b'0', b'[]', b'""', b"''"): |
110 default = b'' |
119 default = b'' |
111 if re.match(b'[a-z.]+$', default): |
120 if re.match(b'[a-z.]+$', default): |
112 default = b'<variable>' |
121 default = b'<variable>' |
113 if (name in foundopts and (ctype, default) != foundopts[name] |
122 if (name in foundopts and (ctype, default) != foundopts[name] |
114 and name not in allowinconsistent): |
123 and name not in allowinconsistent): |
115 print(l.rstrip()) |
124 print(mkstr(l.rstrip())) |
116 print("conflict on %s: %r != %r" % (name, (ctype, default), |
125 fctype, fdefault = foundopts[name] |
117 foundopts[name])) |
126 print("conflict on %s: %r != %r" % ( |
118 print("at %s:%d:" % (f, linenum)) |
127 mkstr(name), |
|
128 (mkstr(ctype), mkstr(default)), |
|
129 (mkstr(fctype), mkstr(fdefault)))) |
|
130 print("at %s:%d:" % (mkstr(f), linenum)) |
119 foundopts[name] = (ctype, default) |
131 foundopts[name] = (ctype, default) |
120 carryover = b'' |
132 carryover = b'' |
121 else: |
133 else: |
122 m = re.search(configpartialre, line) |
134 m = re.search(configpartialre, line) |
123 if m: |
135 if m: |
130 if not (name.startswith(b"devel.") or |
142 if not (name.startswith(b"devel.") or |
131 name.startswith(b"experimental.") or |
143 name.startswith(b"experimental.") or |
132 name.startswith(b"debug.")): |
144 name.startswith(b"debug.")): |
133 ctype, default = foundopts[name] |
145 ctype, default = foundopts[name] |
134 if default: |
146 if default: |
|
147 if isinstance(default, bytes): |
|
148 default = mkstr(default) |
135 default = ' [%s]' % default |
149 default = ' [%s]' % default |
136 print("undocumented: %s (%s)%s" % (name, ctype, default)) |
150 elif isinstance(default, bytes): |
|
151 default = mkstr(default) |
|
152 print("undocumented: %s (%s)%s" % ( |
|
153 mkstr(name), mkstr(ctype), default)) |
137 |
154 |
138 if __name__ == "__main__": |
155 if __name__ == "__main__": |
139 if len(sys.argv) > 1: |
156 if len(sys.argv) > 1: |
140 sys.exit(main(sys.argv[1:])) |
157 sys.exit(main(sys.argv[1:])) |
141 else: |
158 else: |