2 # Generate the wiki Home.md page from the contained doc comments
3 # requires the checked out wiki in ../rust-clippy.wiki/
4 # with -c option, print a warning and set exit status 1 if the file would be
11 def parse_path(p="src"):
13 for f in os.listdir(p):
15 parse_file(d, os.path.join(p, f))
29 if line.startswith("///"):
30 if line.startswith("/// "):
31 last_comment.append(line[4:])
33 last_comment.append(line[3:])
34 elif line.startswith("declare_lint!"):
40 m = re.search(r"pub\s+([A-Z_]+)", l)
42 print("found %s in %s" % (m.group(1).lower(), f))
43 d[m.group(1).lower()] = last_comment
47 print("Warning: Missing Lint-Name in", f)
50 PREFIX = """Welcome to the rust-clippy wiki!
52 Here we aim to collect further explanations on the lints clippy provides. So \
60 Clippy works as a *plugin* to the compiler, which means using an unstable \
61 internal API. We have gotten quite good at keeping pace with the API \
62 evolution, but the consequence is that clippy absolutely needs to be compiled \
63 with the version of `rustc` it will run on, otherwise you will get strange \
64 errors of missing symbols."""
67 def write_wiki_page(d, f):
70 with open(f, "w") as w:
73 w.write("[`%s`](#%s)\n" % (k, k))
76 w.write("\n# `%s`\n\n%s" % (k, "".join(d[k])))
79 def check_wiki_page(d, f):
83 m = re.match("# `([a-z_]+)`", line)
85 v = d.pop(m.group(1), "()")
87 errors.append("Missing wiki entry: " + m.group(1))
91 errors.append("Spurious wiki entry: " + k)
93 print("\n".join(errors))
100 check_wiki_page(d, "../rust-clippy.wiki/Home.md")
102 write_wiki_page(d, "../rust-clippy.wiki/Home.md")
104 if __name__ == "__main__":