Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3147520

Browse files
Add new doc codeblock standalone attribute
1 parent 58cd70e commit 3147520

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/librustdoc/doctest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ impl CreateRunnableDoctests {
779779
let is_standalone = !self.can_merge_doctests
780780
|| scraped_test.langstr.compile_fail
781781
|| scraped_test.langstr.test_harness
782+
|| scraped_test.langstr.standalone
782783
|| self.rustdoc_options.nocapture
783784
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output")
784785
|| doctest.crate_attrs.contains("#![no_std]");

src/librustdoc/html/markdown.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ pub(crate) struct LangString {
869869
pub(crate) rust: bool,
870870
pub(crate) test_harness: bool,
871871
pub(crate) compile_fail: bool,
872+
pub(crate) standalone: bool,
872873
pub(crate) error_codes: Vec<String>,
873874
pub(crate) edition: Option<Edition>,
874875
pub(crate) added_classes: Vec<String>,
@@ -1191,6 +1192,7 @@ impl Default for LangString {
11911192
rust: true,
11921193
test_harness: false,
11931194
compile_fail: false,
1195+
standalone: false,
11941196
error_codes: Vec::new(),
11951197
edition: None,
11961198
added_classes: Vec::new(),
@@ -1260,6 +1262,10 @@ impl LangString {
12601262
seen_rust_tags = !seen_other_tags || seen_rust_tags;
12611263
data.no_run = true;
12621264
}
1265+
LangStringToken::LangToken("standalone") => {
1266+
data.standalone = true;
1267+
seen_rust_tags = !seen_other_tags || seen_rust_tags;
1268+
}
12631269
LangStringToken::LangToken(x) if x.starts_with("edition") => {
12641270
data.edition = x[7..].parse::<Edition>().ok();
12651271
}

0 commit comments

Comments
 (0)