Add new doc codeblock standalone attribute

This commit is contained in:
Guillaume Gomez 2024-06-10 15:40:17 +02:00
parent 58cd70e062
commit 3147520d34
2 changed files with 7 additions and 0 deletions

View File

@ -779,6 +779,7 @@ impl CreateRunnableDoctests {
let is_standalone = !self.can_merge_doctests
|| scraped_test.langstr.compile_fail
|| scraped_test.langstr.test_harness
|| scraped_test.langstr.standalone
|| self.rustdoc_options.nocapture
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output")
|| doctest.crate_attrs.contains("#![no_std]");

View File

@ -869,6 +869,7 @@ pub(crate) struct LangString {
pub(crate) rust: bool,
pub(crate) test_harness: bool,
pub(crate) compile_fail: bool,
pub(crate) standalone: bool,
pub(crate) error_codes: Vec<String>,
pub(crate) edition: Option<Edition>,
pub(crate) added_classes: Vec<String>,
@ -1191,6 +1192,7 @@ impl Default for LangString {
rust: true,
test_harness: false,
compile_fail: false,
standalone: false,
error_codes: Vec::new(),
edition: None,
added_classes: Vec::new(),
@ -1260,6 +1262,10 @@ impl LangString {
seen_rust_tags = !seen_other_tags || seen_rust_tags;
data.no_run = true;
}
LangStringToken::LangToken("standalone") => {
data.standalone = true;
seen_rust_tags = !seen_other_tags || seen_rust_tags;
}
LangStringToken::LangToken(x) if x.starts_with("edition") => {
data.edition = x[7..].parse::<Edition>().ok();
}