|
2 | 2 |
|
3 | 3 | # Script for extracting compilable fragments from markdown
|
4 | 4 | # documentation. See prep.js for a description of the format
|
5 |
| -# recognized by this tool. Expects a directory fragements/ to exist |
| 5 | +# recognized by this tool. Expects a directory fragments/ to exist |
6 | 6 | # under the current directory, and writes the fragments in there as
|
7 | 7 | # individual .rs files.
|
8 | 8 |
|
9 |
| -import sys, re; |
| 9 | +import sys, re |
10 | 10 |
|
11 | 11 | if len(sys.argv) < 3:
|
12 | 12 | print("Please provide an input filename")
|
|
26 | 26 | while cur < len(lines):
|
27 | 27 | line = lines[cur]
|
28 | 28 | cur += 1
|
29 |
| - chap = re.match("# (.*)", line); |
| 29 | + chap = re.match("# (.*)", line) |
30 | 30 | if chap:
|
31 | 31 | chapter = re.sub(r"\W", "_", chap.group(1)).lower()
|
32 | 32 | chapter_n = 1
|
|
51 | 51 | else:
|
52 | 52 | # Lines beginning with '# ' are turned into valid code
|
53 | 53 | line = re.sub("^# ", "", line)
|
54 |
| - # Allow elipses in code snippets |
| 54 | + # Allow ellipses in code snippets |
55 | 55 | line = re.sub("\.\.\.", "", line)
|
56 | 56 | block += line
|
57 | 57 | if not ignore:
|
58 | 58 | if not re.search(r"\bfn main\b", block):
|
59 | 59 | block = "fn main() {\n" + block + "\n}\n"
|
60 | 60 | if not re.search(r"\bextern mod std\b", block):
|
61 |
| - block = "extern mod std;\n" + block; |
| 61 | + block = "extern mod std;\n" + block |
| 62 | + block = """#[ forbid(ctypes) ]; |
| 63 | +#[ forbid(deprecated_mode) ]; |
| 64 | +#[ forbid(deprecated_pattern) ]; |
| 65 | +#[ forbid(implicit_copies) ]; |
| 66 | +#[ forbid(non_implicitly_copyable_typarams) ]; |
| 67 | +#[ forbid(path_statement) ]; |
| 68 | +#[ forbid(type_limits) ]; |
| 69 | +#[ forbid(unrecognized_lint) ]; |
| 70 | +#[ forbid(unused_imports) ]; |
| 71 | +#[ forbid(vecs_implicitly_copyable) ]; |
| 72 | +#[ forbid(while_true) ]; |
| 73 | +
|
| 74 | +#[ warn(deprecated_self) ]; |
| 75 | +#[ warn(non_camel_case_types) ]; |
| 76 | +#[ warn(structural_records) ];\n |
| 77 | +""" + block |
62 | 78 | if xfail:
|
63 | 79 | block = "// xfail-test\n" + block
|
64 | 80 | filename = (dest + "/" + str(chapter)
|
|
0 commit comments