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:
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 lint_dict['docs'][last_section] = \
43 (lint_dict['docs'].get(last_section, "") + "\n" + text).strip()
49 lintlist, configs = parse_all()
52 lints[lint.name] = parse_lint_def(lint)
53 if lint.name in configs:
54 lints[lint.name]['docs']['Configuration'] = \
55 CONF_TEMPLATE % configs[lint.name]
57 outfile = sys.argv[1] if len(sys.argv) > 1 else "util/gh-pages/lints.json"
58 with open(outfile, "w") as fp:
59 json.dump(list(lints.values()), fp, indent=2)
60 log.info("wrote JSON for great justice")
63 if __name__ == "__main__":