8 from lintlib import parse_all, log
10 lint_subheadline = re.compile(r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''')
13 This lint has the following configuration variables:
15 * `%s: %s`: %s (defaults to `%s`)."""
18 def parse_lint_def(lint):
20 lint_dict['id'] = lint.name
21 lint_dict['level'] = lint.level
22 lint_dict['docs'] = {}
27 if len(line.strip()) == 0 and not last_section.startswith("Example"):
30 match = re.match(lint_subheadline, line)
32 last_section = match.groups()[0]
34 text = match.groups()[1]
39 log.warn("Skipping comment line as it was not preceded by a heading")
40 log.debug("in lint `%s`, line `%s`", lint.name, line)
42 fragment = lint_dict['docs'].get(last_section, "")
44 line = fragment + text
46 line = (fragment + "\n" + text).strip()
48 lint_dict['docs'][last_section] = line
54 lintlist, configs = parse_all()
57 lints[lint.name] = parse_lint_def(lint)
58 if lint.name in configs:
59 lints[lint.name]['docs']['Configuration'] = \
60 CONF_TEMPLATE % configs[lint.name]
62 outfile = sys.argv[1] if len(sys.argv) > 1 else "util/gh-pages/lints.json"
63 with open(outfile, "w") as fp:
64 json.dump(list(lints.values()), fp, indent=2)
65 log.info("wrote JSON for great justice")
68 if __name__ == "__main__":