| name | rust-docs |
| description | Write Rust documentation comments following project conventions. Use when writing doc comments, documenting functions, structs, modules, or creating crate-level documentation. Handles /// for items, //! for crate/module docs, markdown formatting, code examples, and panic/safety sections. |
Rust Documentation Comments
Guidelines for writing Rust documentation comments that match this project's conventions.
When to Use This Skill
- Writing documentation for public functions, structs, enums, traits, or modules
- Creating crate-level documentation (
//!)
- Adding code examples to documentation
- Documenting safety requirements or panic conditions
- Writing module-level documentation
Documentation Comment Types
Item Documentation (///)
Use /// for documenting public items (functions, structs, enums, traits, etc.):
pub fn function(param1: Type1, param2: Type2) -> Result<ReturnType, Error> {
}
Crate/Module Documentation (//!)
Use //! for crate-level or module-level documentation at the top of the file:
Project Conventions
- Start with a brief summary: First line should be a concise description
- Use markdown: Format with headers, lists, code blocks, and emphasis
- Include examples: Add
# Examples section with runnable code when helpful
- Document errors: Use
# Errors section for Result-returning functions
- Note important details: Use
**Note** or **Warning** for important information
- Code examples: Use
no_run when examples can't compile standalone: ```rust,no_run
Common Patterns
Documenting Structs
pub struct StructName {
pub field1: Type1,
}
Documenting Enums
pub enum EnumName {
Variant1,
Variant2,
}
Documenting Modules
Markdown Formatting
- Use
**bold** for emphasis
- Use
*italic* for subtle emphasis
- Use
`code` for inline code
- Use
# Section for major sections
- Use
## Subsection for subsections
- Use
- Item for bullet lists
- Use
1. Item for numbered lists
Examples from Project
See fcs/src/gpu/matrix.rs and fcs/src/lib.rs for examples of module-level documentation.