Skip to content

Commit fd0dbac

Browse files
Rollup merge of #80617 - GuillaumeGomez:detect-invalid-rustdoc-test-commands, r=jyn514
Detect invalid rustdoc test commands Fixes #80570. There are now errors displayed in case of bad command syntax: ``` ---- [rustdoc] rustdoc/remove-url-from-headings.rs stdout ---- error: htmldocck failed! status: exit code: 1 command: "/usr/bin/python" "/home/imperio/rust/rust/src/etc/htmldocck.py" "/home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc/remove-url-from-headings" "/home/imperio/rust/rust/src/test/rustdoc/remove-url-from-headings.rs" stdout: ------------------------------------------ ------------------------------------------ stderr: ------------------------------------------ 3: Invalid command: `!`@has`,` (try with ``@!has`)` // !`@has` - '//a[`@href="http://a.a"]'` Encountered 1 errors ``` r? `@camelid`
2 parents 2072e11 + da3eef6 commit fd0dbac

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/etc/htmldocck.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def concat_multi_lines(f):
218218

219219

220220
LINE_PATTERN = re.compile(r'''
221-
(?<=(?<!\S)@)(?P<negated>!?)
221+
(?<=(?<!\S))(?P<invalid>!?)@(?P<negated>!?)
222222
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
223223
(?P<args>.*)$
224224
''', re.X | re.UNICODE)
@@ -233,6 +233,16 @@ def get_commands(template):
233233

234234
negated = (m.group('negated') == '!')
235235
cmd = m.group('cmd')
236+
if m.group('invalid') == '!':
237+
print_err(
238+
lineno,
239+
line,
240+
'Invalid command: `!@{0}{1}`, (help: try with `@!{1}`)'.format(
241+
'!' if negated else '',
242+
cmd,
243+
),
244+
)
245+
continue
236246
args = m.group('args')
237247
if args and not args[:1].isspace():
238248
print_err(lineno, line, 'Invalid template syntax')

0 commit comments

Comments
 (0)