mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Don't require all doc fences to be valid for identifying rust code
This commit is contained in:
parent
75bf832899
commit
8a959497b1
2 changed files with 6 additions and 2 deletions
|
@ -85,6 +85,8 @@ const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[
|
||||||
"ignore",
|
"ignore",
|
||||||
"no_run",
|
"no_run",
|
||||||
"compile_fail",
|
"compile_fail",
|
||||||
|
"allow_fail",
|
||||||
|
"test_harness",
|
||||||
"edition2015",
|
"edition2015",
|
||||||
"edition2018",
|
"edition2018",
|
||||||
"edition2021",
|
"edition2021",
|
||||||
|
@ -181,7 +183,7 @@ pub(super) fn doc_comment(
|
||||||
is_codeblock = !is_codeblock;
|
is_codeblock = !is_codeblock;
|
||||||
// Check whether code is rust by inspecting fence guards
|
// Check whether code is rust by inspecting fence guards
|
||||||
let guards = &line[idx + RUSTDOC_FENCE.len()..];
|
let guards = &line[idx + RUSTDOC_FENCE.len()..];
|
||||||
let is_rust = guards.split(',').all(|sub| is_rustdoc_fence_token(sub.trim()));
|
let is_rust = guards.split(',').any(|sub| is_rustdoc_fence_token(sub.trim()));
|
||||||
is_doctest = is_codeblock && is_rust;
|
is_doctest = is_codeblock && is_rust;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = &[
|
||||||
"ignore",
|
"ignore",
|
||||||
"no_run",
|
"no_run",
|
||||||
"compile_fail",
|
"compile_fail",
|
||||||
|
"allow_fail",
|
||||||
|
"test_harness",
|
||||||
"edition2015",
|
"edition2015",
|
||||||
"edition2018",
|
"edition2018",
|
||||||
"edition2021",
|
"edition2021",
|
||||||
|
@ -28,7 +30,7 @@ pub(crate) fn format_docs(src: &str) -> String {
|
||||||
|
|
||||||
if in_code_block {
|
if in_code_block {
|
||||||
is_rust =
|
is_rust =
|
||||||
header.split(',').all(|sub| is_rust_specific_code_block_attribute(sub.trim()));
|
header.split(',').any(|sub| is_rust_specific_code_block_attribute(sub.trim()));
|
||||||
|
|
||||||
if is_rust {
|
if is_rust {
|
||||||
line = "```rust";
|
line = "```rust";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue