Skip to content

Commit

Permalink
Auto merge of rust-lang#4409 - jeremystucki:export, r=phansch
Browse files Browse the repository at this point in the history
[Doc] Ignore lines starting with #

Resolves rust-lang#4353

changelog: none
  • Loading branch information
bors committed Aug 23, 2019
2 parents a175ca4 + df211ff commit 56f51b3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion util/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
from lintlib import parse_all, log

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

CONF_TEMPLATE = """\
This lint has the following configuration variables:
* `%s: %s`: %s (defaults to `%s`)."""


def parse_code_block(match):
lines = []

for line in match.group(0).split('\n'):
if not line.startswith('# '):
lines.append(line)

return '\n'.join(lines)


def parse_lint_def(lint):
lint_dict = {}
lint_dict['id'] = lint.name
Expand Down Expand Up @@ -44,7 +55,7 @@ def parse_lint_def(lint):
lint_dict['docs'][last_section] += text + "\n"

for section in lint_dict['docs']:
lint_dict['docs'][section] = lint_dict['docs'][section].strip()
lint_dict['docs'][section] = re.sub(rust_code_block, parse_code_block, lint_dict['docs'][section].strip())

return lint_dict

Expand Down

0 comments on commit 56f51b3

Please sign in to comment.