doctest-conventions
Skill166 starsChanged 7 days agoApache-2.0View on GitHub
Conventions for authoring rustdoc doctests in playwright-rust — the `no_run` annotation, module-level placement, hidden scaffolding lines, and how doctests are exercised in CI vs pre-commit.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- driver-bumpSkill
- release-processSkill
- supply-chainSkill
- playwright-rs-usageSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Every rustdoc example is compile-checked on every cargo test --doc (pre-commit and CI).
- Very specific: line 44
Prefer one comprehensive module-level doctest (//!) per protocol file, demonstrating related APIs in a realistic scenario.
- Very specific: line 49
Use hidden scaffolding lines (# -prefixed) so the rendered docs show only the instructive lines while the compiler sees a complete program:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Doctest Conventions
Philosophy: documentation that cannot rot
Every rustdoc example is compile-checked on every cargo test --doc
(pre-commit and CI). Browser automation can't execute in a doctest
harness, so examples are compiled but not run — same contract as the
agent-doc snippets (verify-agent-docs) and landing-page snippets
(verify-site-snippets).
The annotation: no_run
no_run — compiled every time, never executed. ← use this
ignore — never compiled, never executed; rustdoc only highlights it.
(none) — compiled AND executed; only for pure, browser-free examples.Use ```no_run for anything that would launch a browser or talk to
the Playwright server. Plain ```rust is fine for pure logic
(selector builders, option construction) that can really execute.
Never use ```ignore except when the code genuinely cannot
compile in this crate — the only sanctioned case is the macros/trace
crates' module docs showing downstream playwright-rs usage, which
would need a cyclic dev-dependency to compile.
History. Until 2026-06, the convention was
ignore+ a CI step runningcargo test --doc -- --ignored, believed to execute them. It never did: rustdoc surfacesignoreblocks as empty always-pass stubs (83 "passed" in 0.00s). The examples had zero protection and ~10 had silently rotted.no_runis what the convention always intended.
Structure
Prefer one comprehensive module-level doctest (//!) per protocol
file, demonstrating related APIs in a realistic scenario. Per-function
examples are allowed where they pull their weight — they must compile
like everything else.
Use hidden scaffolding lines (# -prefixed) so the rendered docs
show only the instructive lines while the compiler sees a complete
program:
/// # Example
///
/// ```no_run
/// # use playwright_rs::Playwright;
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// # let pw = Playwright::launch().await?;
/// # let page = pw.chromium().launch().await?.new_page().await?;
/// page.goto("https://example.com", None).await?;
/// let title = page.title().await?;
/// # Ok(())
/// # }
/// ```Module-level (//!) doctests use //! # for hidden lines. A full
#[tokio::main] async fn main() is also fine when showing the whole
program is the point.
Running doctests
# Compile-check all doctests (pre-commit AND CI run exactly this)
cargo test --doc --workspace
# Pure examples without no_run also execute in the same passCI / pre-commit integration
Both run the same command — there is no separate execution lane:
- name: Compile doc-tests
run: cargo test --doc --workspaceDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

