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

Commit 93e7b82

Browse files
Add new doc codeblock standalone attribute
1 parent 8010f43 commit 93e7b82

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
@@ -868,6 +868,7 @@ pub(crate) struct LangString {
868868
pub(crate) rust: bool,
869869
pub(crate) test_harness: bool,
870870
pub(crate) compile_fail: bool,
871+
pub(crate) standalone: bool,
871872
pub(crate) error_codes: Vec<String>,
872873
pub(crate) edition: Option<Edition>,
873874
pub(crate) added_classes: Vec<String>,
@@ -1179,6 +1180,7 @@ impl Default for LangString {
11791180
rust: true,
11801181
test_harness: false,
11811182
compile_fail: false,
1183+
standalone: false,
11821184
error_codes: Vec::new(),
11831185
edition: None,
11841186
added_classes: Vec::new(),
@@ -1248,6 +1250,10 @@ impl LangString {
12481250
seen_rust_tags = !seen_other_tags || seen_rust_tags;
12491251
data.no_run = true;
12501252
}
1253+
LangStringToken::LangToken("standalone") => {
1254+
data.standalone = true;
1255+
seen_rust_tags = !seen_other_tags || seen_rust_tags;
1256+
}
12511257
LangStringToken::LangToken(x) if x.starts_with("edition") => {
12521258
data.edition = x[7..].parse::<Edition>().ok();
12531259
}

0 commit comments

Comments
 (0)