From 793e6b538c95c54c647f7127d634818547028999 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 30 Jun 2026 07:06:07 +0800 Subject: feat(docs): add @@@ hidden code block support for compile-tested examples --- dev_tools/src/verify.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'dev_tools/src') diff --git a/dev_tools/src/verify.rs b/dev_tools/src/verify.rs index 36283d3..2ddff0c 100644 --- a/dev_tools/src/verify.rs +++ b/dev_tools/src/verify.rs @@ -73,6 +73,24 @@ fn parse_single_block(lines: &[&str], start: usize, source_file: &str) -> Option break; } + // @@@ lines: strip the prefix and treat as regular Rust code + // These lines are hidden in the rendered docs (filtered by a docsify plugin) + // but must still compile. + if trimmed.starts_with("@@@") { + in_header = false; + // Strip @@@ and optionally one following space + let code = trimmed[3..].trim_start(); + if code.contains("fn main") { + has_main = true; + } + if code.contains("gen_program!") { + has_gen_program = true; + } + code_lines.push(code.to_string()); + idx += 1; + continue; + } + // Parse header comments // Check for NOT VERIFIED marker if in_header && trimmed == "// NOT VERIFIED" { -- cgit