Skip to content

Apache DataFusion SQL Query Engine

docs: note the rustdoc trick for hiding use statements in examples (#25718)

Alessandro Solimandofcab0020c173
diff --git a/docs/source/contributor-guide/testing.md b/docs/source/contributor-guide/testing.md
index 4ba7d9d011..4c097ae498 100644
--- a/docs/source/contributor-guide/testing.md
+++ b/docs/source/contributor-guide/testing.md
@@ -176,6 +176,20 @@ cargo test --doc
As with other Rust projects, examples in doc comments in `.rs` files are
automatically checked to ensure they work and evolve along with the code.
+Prefix a line with `# ` (a `#` followed by a space) to keep it compiled and
+run, but hidden from the rendered documentation. This is most useful for
+`use` statements, since readers care about the API being demonstrated, not
+its import boilerplate:
+
+````rust
+/// ```
+/// # use std::sync::Arc;
+/// let value = Arc::new(42);
+/// ```
+````
+
+Only the `let value = ...` line renders.
+
### User Guide Documentation
Rust example code from the user guide (anything marked with \`\`\`rust) is also