Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
hashintel avatar

Documenting Rust Code

  • 4 installs
  • 1.6k repo stars
  • Updated August 5, 2026
  • hashintel/hash

Applies rustdoc documentation conventions for the HASH codebase, covering doc comments, error sections, intra-doc links, and examples.

About

A Rust documentation skill codifying high-quality rustdoc practices modeled on crates like time, jiff, and serde. A developer uses it when writing doc comments for functions, types, traits, and modules.

  • Requires single-line summaries, intra-doc links, and # Errors sections
  • Explicit do/don't list, e.g. skip documenting standard trait impls

Documenting Rust Code by the numbers

  • 4 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #1,241 of 1,879 Documentation skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/hashintel/hash --skill documenting-rust-code

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs4
repo stars1.6k
Last updatedAugust 5, 2026
Repositoryhashintel/hash

What it does

Applies rustdoc documentation conventions for the HASH codebase, covering doc comments, error sections, intra-doc links, and examples.

Files

SKILL.mdMarkdownGitHub ↗

Rust Documentation Practices

Comprehensive guidance on documenting Rust code in the HASH repository following rustdoc conventions.

Core Principles

Follow high-quality standards like `time`, `jiff`, and `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], [HashMap], etc.
  • 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 # Returns sections (inline instead)
  • 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

References

  • [references/function-documentation.md](references/function-documentation.md): Functions and methods documentation patterns
  • [references/type-documentation.md](references/type-documentation.md): Types, structs, enums, and traits documentation
  • [references/error-documentation.md](references/error-documentation.md): Error conditions and panics documentation
  • [references/examples-and-links.md](references/examples-and-links.md): Examples and intra-doc links usage

Related skills

Documentationdocsbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.