Back to all reviewers

Structure API doc blocks

tokio-rs/tokio
Based on 5 comments
Rust

Each public API documentation block should follow a consistent structure: 1. Start with a single-line summary that concisely describes the item 2. Add an empty line after the summary

Documentation Rust

Reviewer Prompt

Each public API documentation block should follow a consistent structure:

  1. Start with a single-line summary that concisely describes the item
  2. Add an empty line after the summary
  3. Follow with detailed documentation paragraphs
  4. Use empty lines between sections (paragraphs, code blocks, headers)
  5. Format Rust types using backticks (e.g., [String])

Example:

/// Receives the next value from the channel.
///
/// This method returns `None` if the channel has been closed and there are
/// no remaining messages in the channel's queue. The channel is closed when
/// all senders have been dropped.
///
/// # Examples
///
/// ```
/// use tokio::sync::mpsc;
///
/// #[tokio::main]
/// async fn main() {
///     let (tx, mut rx) = mpsc::channel(100);
///     assert!(rx.recv().await.is_none());
/// }
/// ```
pub async fn recv(&mut self) -> Option<T> {
    // Implementation
}

This structure improves readability and ensures documentation is both scannable and detailed when needed. The single-line summary is particularly important as it appears in module documentation and IDE tooltips.

5
Comments Analyzed
Rust
Primary Language
Documentation
Category

Source Discussions