| name | rust-doc-comments |
| description | Audit and fix Rust doc comments to follow rustdoc conventions, ensuring docs.rs compatibility. Use when writing new Rust code, reviewing existing comments, or after refactoring. |
| allowed-tools | Read, Grep, Glob, Edit, Bash |
| argument-hint | [file or directory path] |
Rust Doc Comment Conventions
Audit the target path (default: src/) and rewrite all comments to follow rustdoc / docs.rs conventions.
Target: $ARGUMENTS (fallback to src/ if empty)
What to fix
1. Delete style/separator lines
These are purely decorative and generate no documentation:
2. Module-level docs use //!
Every module file (mod.rs, lib.rs, named modules) should open with //!:
Keep it concise — 1–3 lines for leaf modules, up to a short paragraph for important ones.
3. Public items use ///
All pub types, functions, methods, enum variants, and significant fields get ///:
pub fn truncate(s: &str, max_chars: usize) -> String { ... }
Rules:
- First line is a single sentence summary (shows in module index on docs.rs).
- Use
`backticks` for parameter names, types, and code fragments.
- Use [
intra-doc links] for cross-references: [Event], [Event::IssueCreated], [crate::event].
- Document panics under
# Panics, errors under # Errors, only when non-obvious.
- Don't doc trivial getters, simple struct fields, or items whose name is already self-explanatory.
4. Internal comments stay as //
Implementation details, inline clarifications, and TODOs remain plain //:
.or_else(|| old_state.as_str())
Don't convert these to /// — they describe how, not what.
5. No redundant / echo comments
pub fn new() -> Foo { ... }
pub fn new() -> Foo { ... }
pub fn new() -> Foo { ... }
Execution steps
Grep for // --- separator lines across the target — delete all of them.
- Check each
.rs file for //! module docs — add where missing.
Grep for pub fn, pub struct, pub enum, pub trait without a preceding /// — add doc comments.
- Verify no
/// on private internals unless genuinely helpful.
- Run
cargo clippy — zero warnings.
- Run
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps — zero warnings.