File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 10
10
from lintlib import parse_all , log
11
11
12
12
lint_subheadline = re .compile (r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''' )
13
+ rust_code_block = re .compile (r'''```rust.+?```''' , flags = re .DOTALL )
13
14
14
15
CONF_TEMPLATE = """\
15
16
This lint has the following configuration variables:
16
17
17
18
* `%s: %s`: %s (defaults to `%s`)."""
18
19
19
20
21
+ def parse_code_block (match ):
22
+ lines = []
23
+
24
+ for line in match .group (0 ).split ('\n ' ):
25
+ if not line .startswith ('# ' ):
26
+ lines .append (line )
27
+
28
+ return '\n ' .join (lines )
29
+
30
+
20
31
def parse_lint_def (lint ):
21
32
lint_dict = {}
22
33
lint_dict ['id' ] = lint .name
@@ -44,7 +55,7 @@ def parse_lint_def(lint):
44
55
lint_dict ['docs' ][last_section ] += text + "\n "
45
56
46
57
for section in lint_dict ['docs' ]:
47
- lint_dict ['docs' ][section ] = lint_dict ['docs' ][section ].strip ()
58
+ lint_dict ['docs' ][section ] = re . sub ( rust_code_block , parse_code_block , lint_dict ['docs' ][section ].strip () )
48
59
49
60
return lint_dict
50
61
You can’t perform that action at this time.
0 commit comments