Claude-skill-registry lang-rust-docs-dev
Rust documentation practices for HASH codebase. Use when writing doc comments, documenting functions/types/traits/modules, creating error sections, using intra-doc links, following rustdoc conventions, or exploring crate APIs with cargo doc.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/lang-rust-docs-dev" ~/.claude/skills/majiayu000-claude-skill-registry-lang-rust-docs-dev && rm -rf "$T"
manifest:
skills/data/lang-rust-docs-dev/SKILL.mdsource content
Rust Documentation Practices
Comprehensive guidance on documenting Rust code in the HASH repository following rustdoc conventions.
Core Principles
Follow high-quality standards like
, time
, and jiff
:serde
✅ DO:
- Begin every doc comment with single-line summary
- Use intra-doc links for all type references
- Document all error conditions with
# Errors - Include practical examples for public APIs
- Link standard library types: [
], [Vec
], etc.HashMap - Use inline parameter descriptions for simple functions (0-2 params)
- Describe return values in main text, not separate sections
❌ DON'T:
- Document standard trait implementations (
,Debug
,Display
)From - Add separate
sections (inline instead)# Returns - Mention variable types already in signatures
- Use comments on same line as code
- Skip error documentation for fallible functions
Quick Reference
Basic Doc Comment
/// Retrieves an entity by its UUID. /// /// Loads the entity from the store and verifies access permissions. /// Returns the [`Entity`] if found and accessible. /// /// # Errors /// /// - [`NotFound`] if the entity doesn't exist /// - [`AuthorizationError`] if access is denied /// /// [`NotFound`]: EntityError::NotFound /// [`AuthorizationError`]: EntityError::Authorization pub fn get_entity(&self, id: EntityId) -> Result<Entity, Report<EntityError>> {
Intra-Doc Links
/// Updates the [`User`] using [`UserUpdateStrategy`]. /// /// See [`validation::user`] for validation rules. /// /// [`validation::user`]: crate::validation::user
Documentation Patterns
Simple Functions (0-2 params)
Describe parameters inline:
/// Processes the `input` elements and returns filtered results. /// /// Takes a collection of `input` elements, applies the `filter_fn`, /// and returns a [`Vec`] containing only matching elements.
Complex Functions (3+ params)
Use explicit
# Arguments section:
/// Merges multiple data sources with transformation rules. /// /// # Arguments /// /// * `sources` - Collection of data sources to merge /// * `rules` - Transformation rules to apply /// * `options` - Configuration controlling merge behavior /// * `callback` - Optional function for each merged item
Error Documentation
/// # Errors /// /// - [`WebAlreadyExists`] if web ID is taken /// - [`AuthorizationError`] if permission denied /// /// [`WebAlreadyExists`]: WebError::WebAlreadyExists /// [`AuthorizationError`]: WebError::Authorization
Module Documentation
//! Entity management functionality. //! //! Main types: //! - [`Entity`] - Core entity type //! - [`EntityStore`] - Storage trait //! //! # Examples //! //! ``` //! use hash_graph::entity::Entity; //! ```
Examples with Error Handling
/// # Examples /// /// ```rust /// let entities = get_entities_by_type(type_id)?; /// assert_eq!(entities.len(), 2); /// # Ok::<(), Box<dyn core::error::Error>>(()) /// ```
Verification
cargo doc --no-deps --all-features
Exploring Crates
Generate and use Rust documentation to understand crate APIs, structure, and code organization.
Generating Documentation
# For a specific package cargo doc --no-deps --all-features --package <package-name> # For the entire workspace cargo doc --no-deps --all-features --workspace # Include private items for internal implementation details cargo doc --no-deps --all-features --document-private-items
Key Flags
| Flag | Purpose |
|---|---|
| Document local code only (faster, less noise) |
| Include all feature-gated APIs |
| Target a specific crate |
| Document all crates in the workspace |
| Include internal implementation details |
What Generated Docs Provide
- Crate organization - Module hierarchy and component relationships
- Public API surface - All public functions, types, traits, and constants
- Usage examples - Code examples from doctest blocks
- Error documentation - Documented error conditions and handling
- Type relationships - Trait implementations, type aliases, associated types
Viewing Documentation
Docs are generated at:
target/doc/<crate_name>/index.html
Tips:
- Generate docs before diving into unfamiliar Rust code
- Cross-reference
sections for error handling patterns# Errors - Look for
sections for idiomatic usage patterns# Examples
References
- references/function-documentation.md: Functions and methods documentation patterns
- references/type-documentation.md: Types, structs, enums, and traits documentation
- references/error-documentation.md: Error conditions and panics documentation
- references/examples-and-links.md: Examples and intra-doc links usage