File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1010from lintlib import parse_all , log
1111
1212lint_subheadline = re .compile (r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''' )
13+ rust_code_block = re .compile (r'''```rust.+?```''' , flags = re .DOTALL )
1314
1415CONF_TEMPLATE = """\
1516 This lint has the following configuration variables:
1617
1718* `%s: %s`: %s (defaults to `%s`)."""
1819
1920
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+
2031def parse_lint_def (lint ):
2132 lint_dict = {}
2233 lint_dict ['id' ] = lint .name
@@ -44,7 +55,7 @@ def parse_lint_def(lint):
4455 lint_dict ['docs' ][last_section ] += text + "\n "
4556
4657 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 () )
4859
4960 return lint_dict
5061
You can’t perform that action at this time.
0 commit comments