Skip to content

Commit 56f51b3

Browse files
committed
Auto merge of #4409 - jeremystucki:export, r=phansch
[Doc] Ignore lines starting with # Resolves #4353 changelog: none
2 parents a175ca4 + df211ff commit 56f51b3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

util/export.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
from lintlib import parse_all, log
1111

1212
lint_subheadline = re.compile(r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''')
13+
rust_code_block = re.compile(r'''```rust.+?```''', flags=re.DOTALL)
1314

1415
CONF_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+
2031
def 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

0 commit comments

Comments
 (0)