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
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.
acme deploy --dry-run and check for a 200.No code font on concepts
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.
Acme Cloud uses caching to speed up deployments.No emphasis in code
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.
*ACME_TOKEN* before you run the command.ACME_TOKEN before you run the command.Placeholders
Placeholder form
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.
acme deploy --project PROJECT_IDacme deploy --project <project-id>Explain each placeholder
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.
acme deploy --project <project-id>.acme deploy --project <project-id>, where <project-id> is the ID shown on the project’s Settings page.Commands and output
Run for commands
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.
Show command output
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.
acme deploy.acme deploy. When it finishes, it prints Deployed to https://example.com.Language on every code block
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.
``````bashErrors and verbs
Error messages verbatim
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.
Error: token expired (code 401).Returns and responds with
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.”
getUser() responds with a user object.404, and getUser() returns a user object.