Skip to content
The style guide is in beta: content and structure may change.

Overview and remarks

This page describes the rules for the overview and remarks of an API element description, the two parts that follow the intro. The overview describes when to use the element and how it relates to its neighbors. The remarks add the behavior that a caller can’t infer from the signature.

This guide uses overview for a role, not a heading. The overview is whatever the description covers after the intro, whether your build renders it as the rest of the description, as a Summary or Overview section, or as part of the remarks. Remarks are a section of their own in most builds and the end of the description in the rest.

Reference text doesn’t need contractions. Use one when a sentence sounds stiff without it. The members and parameters page specifies what to document for each member.

api-details-001 must API docs

In reference documentation, describe methods using third-person singular present tense (Creates, Gets, Lists) rather than the imperative or infinitive form.

Examples

  • ✓ createUser: Creates a user in the current project.
  • ✗ createUser: Create a user in the current project.

Rationale

A method description states what the method does. A third-person verb such as Creates describes the method’s behavior, and an imperative such as Create sounds like an instruction to the reader.

Examples

  • ✓ Returns the list of open sessions.
  • ✗ Will return the list of open sessions.

Rationale

API reference documentation describes how the API behaves, and present tense states that behavior directly. Will return suggests that the behavior happens later or only under some condition.

Scope the overview to use and relationships

Section titled “Scope the overview to use and relationships”
api-details-003 should API docs

In the overview, or the section your build uses for it, describe when to use the element and how it relates to its neighbors. The element’s neighbors are the elements it works with, its alternatives, and the members a caller reaches for first. Don’t repeat member detail or syntax that the member sections and the syntax block already show.

Examples

  • ✓ Use a RetryPolicy object with any client that accepts a policy; for a one-off request, pass a timeout instead. A RateLimiter object throttles requests before they are sent, so the two are often used together.
  • ✗ The RetryPolicy class has a maxAttempts property of type int, a delay property of type Duration, and a constructor that takes both.

Rationale

The overview is where a reader decides whether this element is the one they need. When to use the element and how it relates to other elements answer that question. Member details are one click away, and a repeated copy drifts out of date when the member changes.

api-details-004 should API docs

When the overview or remarks depend on a concept that a developer guide explains, link to the guide and restate only what the reader needs to understand the element. Don’t teach the concept on the reference page.

Examples

  • ✓ A refresh token extends the session without a new sign-in. For the full lifecycle, see the authentication guide.
  • ✗ A refresh token is a credential that the authorization server issues alongside the access token so that the client can obtain a new access token when the current one expires, without involving the user again, which matters because access tokens are deliberately short-lived to limit the damage if one leaks.

Rationale

A reader on a reference page has already chosen the element and wants its facts. A developer guide is where a reader learns a concept, and a second explanation on the reference page drifts out of date when the guide changes.

Keep each member’s facts in its own entry

Section titled “Keep each member’s facts in its own entry”
api-details-005 should API docs

Document a parameter, return value, or exception in its own entry, not in the remarks and not in another member’s description. Where another entry needs the fact, link to the entry that holds it. An overload’s description is complete without its siblings’ descriptions. It can repeat a sibling overload’s description and add the detail that distinguishes the two overloads.

Examples

  • ✗ In the remarks of open(path, mode): The mode parameter accepts read, write, or append, and defaults to read.
  • ✓ In the mode parameter’s entry: The access mode: read, write, or append. Default: read.
  • ✓ open(path): Opens the file for reading.
  • ✓ open(path, mode): Opens the file with the specified access mode. (A sibling overload’s description, plus the detail that distinguishes it.)

Rationale

A reader who wants to know what a parameter accepts looks at the parameter’s entry. A fact filed under the remarks or under a sibling member is easy to miss, and when the fact is written in both places, the two copies drift apart. Overloads are the one place where a reader expects near-identical descriptions, because a summary table shows each overload’s description separately.

api-details-006 should API docs

Don’t describe what the syntax block already shows, such as the number of parameters, their types, or the return type. State such a fact only when the description needs it, for example to explain what a type means in this context.

Examples

  • ✓ Formats the record as one line for the audit log.
  • ✗ Takes four parameters and returns a string that formats the record as one line for the audit log.

Rationale

The syntax block is generated from the code, so it’s the authoritative statement of the signature. A description that restates the signature in words adds nothing a caller can use, and it becomes wrong when the signature changes.

Use the remarks for what the signature doesn’t show

Section titled “Use the remarks for what the signature doesn’t show”
api-details-007 should API docs

Use the remarks for behavior that a caller can’t infer from the signature and the intro, such as side effects, limits, idempotency (whether repeated calls are safe), ordering guarantees, thread safety, and performance characteristics. Include only what a caller needs to use the element correctly.

Examples

  • ✓ Calling close() on a closed stream has no effect. The stream is not safe to share between threads.
  • ✗ This method is implemented with a ring buffer and was rewritten in version 3 to improve throughput.

Rationale

A caller reads the remarks to avoid surprises, such as a call that isn’t safe to repeat, a limit that isn’t in the signature, or an ordering they can’t assume. Implementation history and internal details don’t tell a caller anything they can act on.