Skip to content

Develop doc-comment style guide #4361

Closed
@ghost

Description

With a lot of library code expected to change before the 1.0 release, it doesn't make much sense to do this now, but the core and std libraries should use a consistent style for API documentation. The wiki makes some attempt at specifying conventions, but these need to be fleshed out and actually applied to the codebase.

Right now, some doc-comments are written in the third-person indicative:

pub fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
    //! Maps a `some` value by reference from one type to another

and some are written in the imperative:

pub fn chain<T, U>(opt: Option<T>,
                   f: fn(t: T) -> Option<U>) -> Option<U> {
    /*!
     * Update an optional value by optionally running its content through a
     * function that returns an option.
     */

These two examples illustrate another inconsistency: Some summaries (the first line of the comment) have no terminal punctuation, while others end with a period.

One more thing that varies is the comment style itself. Some doc-comments look like

/*!
 * foo...
 * bar...
 * baz...
 */

while others look like

/*!
 foo...
 bar...
 baz...
 */

Once these rules (and others) are codified, I'd be happy to start going through the doc-comments and updating them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions