Skip to content

Commit 8dad2ce

Browse files
committed
HMTL Docs: Add Configuration, Fix Example Section
1 parent bbbd0a5 commit 8dad2ce

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

util/export.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,34 @@
77
level_re = re.compile(r'''(Forbid|Deny|Warn|Allow)''')
88
conf_re = re.compile(r'''define_Conf! {\n([^}]*)\n}''', re.MULTILINE)
99
confvar_re = re.compile(r'''/// Lint: (\w+). (.*).*\n *\("([^"]*)", (?:[^,]*), (.*) => (.*)\),''')
10-
lint_subheadline = re.compile(r'''^\*\*([\w\s]+)[:?.!]\*\*(.*)''')
10+
lint_subheadline = re.compile(r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''')
11+
12+
conf_template = """
13+
This lint has the following configuration variables:
14+
15+
* `%s: %s`: %s (defaults to `%s`).
16+
"""
1117

1218
# TODO: actual logging
1319
def warn(*args): print(args)
1420
def debug(*args): print(args)
1521
def info(*args): print(args)
1622

1723
def parse_path(p="clippy_lints/src"):
18-
d = []
24+
lints = []
1925
for f in os.listdir(p):
2026
if f.endswith(".rs"):
21-
parse_file(d, os.path.join(p, f))
22-
return (d, parse_conf(p))
27+
parse_file(lints, os.path.join(p, f))
28+
29+
conf = parse_conf(p)
30+
info(conf)
31+
32+
for lint_id in conf:
33+
lint = next(l for l in lints if l['id'] == lint_id)
34+
if lint:
35+
lint['docs']['Configuration'] = (conf_template % conf[lint_id]).strip()
36+
37+
return lints
2338

2439

2540
def parse_conf(p):
@@ -120,7 +135,7 @@ def parse_file(d, f):
120135
comment = True
121136

122137
def main():
123-
(lints, config) = parse_path()
138+
lints = parse_path()
124139
info("got %s lints" % len(lints))
125140
with open("util/gh-pages/lints.json", "w") as file:
126141
json.dump(lints, file, indent=2)

0 commit comments

Comments
 (0)