Skip to content

Code and technical terms

Decides what goes in code font, how placeholders look, when to show output, and which verbs describe what code and commands do.

This section covers code in prose and in blocks: what gets code font, how to mark the parts the reader must replace, when to show what a command prints, and the verbs for describing what code does. It applies to documentation, to interface text that quotes code, and to error messages.

The principle is that code is literal. A reader copies it, types it, or searches for it, and any change you make on the way (a paraphrase, a capital letter, a curly quote) breaks the copy. So code font marks exactly the text that must match, placeholders can’t be mistaken for real values, and nothing in code font is decorated. Interface labels are not code; they go in bold, as Interface elements says.

Code font​

Code font scope​

Tier: avoidcode-font-scopeCheck: judgment

Put in code font anything the reader types or the product returns. That includes commands, flags, filenames, paths, environment variables, API names (functions, methods, classes, parameters, fields), HTTP methods, status codes, keyboard keys, and values the reader enters or reads back. Inline, that is a backtick span; for more than a line, a fenced block. A pattern catches a flag, a path, a file extension, or a three-digit status code outside code font; the reviewer has to know which other words are commands and values, so this is a judgment check.

Instead of
Run acme deploy with the --dry-run flag and check for a 200.
Write
Run acme deploy --dry-run and check for a 200.

No code font on concepts​

Tier: avoidcode-no-font-on-conceptsCheck: judgment

Don’t put product names or general concepts in code font. Code font says “this exact text exists in the product.” A product name, a feature name, and an idea such as caching or authentication are words, so they stay in plain text. The name of a resource type as the API spells it (Deployment) is code; the idea of a deployment is not.

Instead of
Acme Cloud uses caching to speed up deployments.
Write
Acme Cloud caches build output to speed up deployments.

No emphasis in code​

Tier: avoidcode-no-emphasisCheck: mechanical

Don’t bold or italicize code. Code font is already a distinct style, and bold or italic inside a code span or block changes what the reader thinks they must type. To draw attention to one line in a block, say which line in the sentence before the block.

Instead of
Set *ACME_TOKEN* before you run the command.
Write
Set ACME_TOKEN before you run the command.

Placeholders​

Placeholder form​

Tier: avoidcode-placeholdersCheck: mechanical

Write placeholders in angle brackets with a descriptive lowercase name. Use <project-id>, not PROJECT_ID, {project_id}, or YOUR-PROJECT-ID. Capitals look like an environment variable, and curly braces look like syntax the reader must type. Hyphens separate the words in the name.

Instead of
acme deploy --project PROJECT_ID
Write
acme deploy --project <project-id>

Explain each placeholder​

Tier: avoidcode-placeholder-explainedCheck: judgment

Tell the reader what each placeholder stands for and where to find the value. Do this in the sentence before the code, or in a short list after it, the first time the placeholder appears on the page.

Instead of
Run acme deploy --project <project-id>.
Write
Run acme deploy --project <project-id>, where <project-id> is the ID shown on the project’s Settings page.

Commands and output​

Run for commands​

Tier: prefercode-run-not-executeCheck: mechanical

Write “run” for commands, not “execute.” “Run” is the everyday word and the one a reader uses at the terminal. The same goes for scripts, tests, and jobs.

Instead of
Execute the migration script.
Write
Run the migration script.

Show command output​

Tier: prefercode-show-outputCheck: judgment

Show a command’s output when the output is how the reader knows it worked. After a command that prints a result, a confirmation, or an ID the reader needs next, show what it prints, trimmed to the lines that matter. Skip the output when the command prints nothing or success is visible somewhere else. Test: cover the output and ask whether the reader can still tell, from the page alone, that the command worked; if not, the output belongs there.

Instead of
Run acme deploy.
Write
Run acme deploy. When it finishes, it prints Deployed to https://example.com.

Language on every code block​

Tier: avoidcode-block-languageCheck: mechanical

Give every fenced code block a language. Put the language name right after the opening backticks (```bash, ```json, ```python) so the block is highlighted and tools can tell what it holds. Use text for command output and for anything with no language of its own. The example shows the opening fence line.

Instead of
```
Write
```bash

Errors and verbs​

Error messages verbatim​

Tier: avoidcode-error-verbatimCheck: judgment

Quote error messages exactly as the product prints them, in code font. Keep the wording, capitalization, punctuation, and any error code. Readers search for the message they see, and a paraphrase doesn’t match. If the message includes a value that varies, replace that value with a placeholder and say so.

Instead of
You’ll see an error saying the token has expired.
Write
The command fails with Error: token expired (code 401).

Returns and responds with​

Tier: prefercode-returns-respondsCheck: mechanical

Write “returns” for functions and “responds with” for HTTP. A function or method returns a value. An endpoint or server responds with a status code and a body. Don’t write that an API “gives back” or “sends” a result, and don’t write that a function “responds.”

Instead of
The endpoint returns a 404, and getUser() responds with a user object.
Write
The endpoint responds with 404, and getUser() returns a user object.