Files of API Reference, Docstrings, and CLI Help
wondelai/
Show the full text432 lines
API Reference, Docstrings, and CLI Help
Reference material is descriptive, complete, and formulaic on purpose. Readers arrive at a reference entry mid-task, read one entry, and leave. This file owns rules A1–A7.
Contents
- What to document (A1) · every public element, and what "public" means per language
- Method descriptions: verb by category (A2)
- Parameters (A3) · non-boolean, boolean, optional, units
- Return values and exceptions (A4)
- Deprecations (A5)
- Complete example:
StorageClient· TypeScript, plus a Python mirror - Reference voice (A7)
- CLI help text (A6) and REST reference pages — both convention
What to document (A1)
Document every public class, interface, struct, constant, field, enum value, and method. An undocumented public element reads as unsupported: developers skip it, file bugs against it, or reimplement it. A reader can't tell "not documented" from "not there".
"Public" is defined by the language, not by intent (convention — per-language norms, not the style guide):
| Language | Public surface |
|---|---|
| TypeScript / JavaScript | Exported from the package entry point, including types and enum members |
| Python | Names without a leading underscore, or listed in __all__ |
| Rust | pub items reachable from the crate root, including fields and variants |
| Go | Identifiers starting with a capital letter, including package-level errors |
| Java / C# | public and protected members of public types |
Write the summary as one sentence, first, in the entry's own paragraph. The summary answers "what does this do"; it never restates the name. A second paragraph, when one is needed, adds what the reader can't infer from the signature: side effects, cost, lifecycle, concurrency safety, ordering guarantees, or a link to the task page.
Before → after (class summary):
- Before:
/** StorageClient class. Used for storage. */ - After:
/** Reads and writes objects in a single storage bucket. */followed by a second paragraph:A client opens one connection per instance and reuses it. Create one client per bucket and share it across requests; the client is safe for concurrent use.
Before → after (enum value):
- Before:
ARCHIVE, // archive - After:
ARCHIVE — Lowest storage price, highest retrieval price. Intended for objects read less than once a year.
Source: api-reference-comments
Method descriptions: verb by category (A2)
Open a method description with a third-person present-tense verb chosen by the method's category. The verb tells the reader the shape of the call before they read the parameters. [EN] The exact verb wordings below are English; the category-to-verb discipline applies in any language.
| Category | Opening verb | Example first sentence |
|---|---|---|
| Boolean getter | Checks whether… | Checks whether the bucket has an active retention policy. |
| Other getter | Gets the… | Gets the storage class of the bucket. |
| Setter | Sets the… | Sets the retention period, in days, for objects in the bucket. |
| Creator or factory | Creates a… | Creates a signed URL that grants temporary read access to an object. |
| Everything else | Returns / Registers / Sends / Deletes / Validates / Uploads… | Deletes the object and every one of its versions. |
Drop the "This method…" and "This function…" openers, along with "A function that…" and "Method to…". The entry already appears under the member's name and signature, so the phrase spends the reader's first four words on the heading.
Before → after:
Before:
/** This method is used for getting the customer associated with a subscription. */After:
/** Gets the customer that owns the subscription. */Before:
/** Function that checks if a bucket is public or not. */After:
/** Checks whether anyone with the URL can read objects in the bucket. */Before:
/** Will create a new signed URL for the object and return it to the caller. */After:
/** Creates a signed URL that grants temporary read access to the object. */
Source: api-reference-comments
Parameters (A3)
A parameter description is a noun phrase describing the value, not a sentence about the parameter. Non-boolean parameters start with "The" or "A".
Booleans take one of two patterns, chosen by what the flag does:
| Flag means | Pattern | Example |
|---|---|---|
| An action the call performs | If true, … If false, … |
If true, deletes the bucket and every object in it. If false, fails when the bucket still contains objects. |
| A state the value carries | True if …; false otherwise |
True if the object is publicly readable; false otherwise. |
Optional parameters say so and name the default at the end of the description: "Optional. Connection options such as the region and the request timeout. Defaults to the us-east-1 region and a 30-second timeout." Where a generator already prints defaults from the signature, repeat them only where the reader can't see the signature — REST body tables and CLI help (convention).
Units and ranges belong in the description, not in the reader's head. Give the unit for every duration, size, rate, and price, and give the accepted range where one exists.
Before → after:
Before:
@param timeout timeoutAfter:
@param timeout The time to wait for a response, in milliseconds. An integer from 1000 to 600000.Before:
@param force force flagAfter:
@param force If true, deletes the bucket even when it contains objects. If false, fails when the bucket isn't empty.Before:
@param amount the amount @param currency currency (optional, default USD)After:
@param amount The amount to charge, in the currency's smallest unit — 1099 means $10.99 for USD.and@param currency Optional. The three-letter ISO 4217 currency code. Defaults to usd.
Source: api-reference-comments
Return values and exceptions (A4)
Describe the return value with the same noun-phrase pattern as parameters: "The…" or "A…", brief, one sentence where possible. A boolean return uses True if …; false otherwise. A method returning nothing needs no return entry.
Exception wording depends on whether the tool prints the word "Throws" for you:
| Situation | Write | Renders as |
|---|---|---|
Tool inserts "Throws" — JSDoc @throws {E}, Python Raises: E: |
If the bucket doesn't exist. |
Throws NotFoundError if the bucket doesn't exist |
| Nothing inserted — prose tables, hand-written reference pages | Thrown when the bucket doesn't exist. |
as written |
Document every error type the method throws, one entry each — a caller writing a catch needs the full list, including errors raised by validation before any I/O happens.
Say what comes back when there's nothing to return. null, undefined, an empty array, and a thrown error are four different contracts, and a reader who guesses wrong ships a crash.
Before → after:
Before:
@returns the objects @throws error if something goes wrongAfter:
@returns The objects whose keys start with the prefix, sorted by key. Returns an empty array when no object matches.plus@throws {NotFoundError} If the bucket doesn't exist.and@throws {PermissionDeniedError} If the credentials can't list the bucket.Before:
@returns booleanAfter:
@returns True if the connection is open; false otherwise.
Source: api-reference-comments
Deprecations (A5)
A deprecated element names its replacement in the first sentence, because the reader is looking for what to call instead. Add the removal version or date, and one line of migration guidance concrete enough to apply without opening another page.
Before → after:
- Before:
/** @deprecated Deprecated. Do not use. */ - After:
/**
* Deprecated: use `createSignedUrl` instead, which returns a URL that expires.
* Removed in v4.0.0 (2027-01-15). Replace `getObjectUrl(key)` with
* `createSignedUrl(key, { expiresInSec: 3600 })`.
*
* Gets a permanent public URL for an object.
*/
Keep the original description below the deprecation note — readers still maintaining old code need it. Where a replacement doesn't exist, say what the reader does instead ("Store the object in a public bucket and read object.publicUrl.") rather than leaving them to guess.
Source: api-reference-comments
Complete example: StorageClient
Before — typical weak comments: names restated, a flag undocumented, a thrown error invisible, a deprecation with no replacement.
/** Storage client */
export class StorageClient {
/** @param bucket bucket @param options options */
constructor(bucket: string, options?: ClientOptions) {}
/** connected? */
get isConnected(): boolean {}
/** region */
get region(): string {}
/** This method deletes a bucket. @param force force flag */
async deleteBucket(force: boolean): Promise<boolean> {}
/** Uploads an object. */
async upload(key: string, body: Buffer): Promise<ObjectMetadata> {}
/** Deprecated, don't use. */
getObjectUrl(key: string): string {}
}
After — every rule in this file applied at once.
/**
* Reads and writes objects in a single storage bucket.
*
* A client opens one connection per instance and reuses it for every request.
* Create one client per bucket and share it across requests; the client is
* safe for concurrent use.
*/
export class StorageClient {
/**
* Creates a client for the given bucket.
*
* @param bucket The name of an existing bucket in the caller's project.
* @param options Optional. Connection options such as the region and the
* request timeout. Defaults to the `us-east-1` region and a 30-second
* timeout.
*/
constructor(bucket: string, options: ClientOptions = DEFAULT_OPTIONS) {}
/**
* Checks whether the client holds an open connection to the bucket.
*
* @returns True if the connection is open; false otherwise.
*/
get isConnected(): boolean {}
/**
* Gets the region that stores the bucket.
*
* @returns The region code, for example `us-east-1`.
* @throws {NotConnectedError} If the client hasn't connected yet. Call
* `connect` first.
*/
get region(): string {}
/**
* Deletes the bucket.
*
* @param force If true, deletes the bucket and every object in it. If false,
* fails when the bucket still contains objects.
* @returns True if the bucket was deleted; false if it didn't exist.
*/
async deleteBucket(force: boolean): Promise<boolean> {}
/**
* Uploads an object and returns its stored metadata.
*
* The upload replaces any object with the same key. To make the write
* conditional, pass a generation to `uploadIfGenerationMatch`.
*
* @param key The object key, up to 1024 bytes of UTF-8.
* @param body The object contents.
* @returns The metadata of the stored object, including its generation
* number and ETag.
* @throws {QuotaExceededError} If the upload would exceed the project's
* storage quota.
* @throws {NotConnectedError} If the client hasn't connected yet.
*/
async upload(key: string, body: Buffer): Promise<ObjectMetadata> {}
/**
* Deprecated: use `createSignedUrl` instead, which returns a URL that
* expires. Removed in v4.0.0 (2027-01-15). Replace `getObjectUrl(key)` with
* `createSignedUrl(key, { expiresInSec: 3600 })`.
*
* Gets a permanent public URL for an object.
*
* @param key The object key.
* @returns The public URL of the object.
* @deprecated Use `createSignedUrl` instead.
*/
getObjectUrl(key: string): string {}
}
The same upload entry as a Python docstring, in Google Python style guide form (Args: / Returns: / Raises:):
def upload(self, key: str, body: bytes) -> ObjectMetadata:
"""Uploads an object and returns its stored metadata.
Args:
key: The object key, up to 1024 bytes of UTF-8.
body: The object contents.
Returns:
The metadata of the stored object, including its generation number
and ETag.
Raises:
QuotaExceededError: If the upload would exceed the project's storage
quota.
NotConnectedError: If the client hasn't connected yet.
"""
Source: api-reference-comments; Google Python style guide (docstring sections)
Reference voice (A7)
Reference entries describe; guides instruct. The difference is grammatical, and mixing the two inside one reference set makes entries read as inconsistent even when every fact is right.
| Surface | Voice | Example |
|---|---|---|
| Reference entry | Third-person present, descriptive | Creates a signed URL that expires after the given interval. |
| Guide, tutorial, procedure step | Second person, imperative | Create a signed URL, then send it to the browser. |
| Usage note inside an entry | Second person, addressed to the caller | Call connect before you read region. |
Second person still earns its place in an entry's usage notes and constraints — the lines telling a caller what to do about the behavior just described. Keep it out of the summary line and the parameter, return, and exception descriptions.
Hold one tense across every entry in the set; a reference where some methods "return" and others "will return" reads as two documents merged. Behavior described in the present is true whenever the reader arrives.
Before → after:
- Before:
Use this method to fetch the invoice. It will return the invoice object. - After:
Gets the invoice for the given ID. Returns the invoice, including its line items.
Voice rules for the surrounding prose — second person, active voice, present tense, no filler — are V1–V10 in voice-and-words.md.
Source: reference-verbs
CLI help text (A6, convention)
Google has no page on --help output, so this section is (convention), built on the guide's command-line syntax notation (P9, procedures-and-code.md) — [optional], {a|b}, ... — and its placeholder rules (P8, same file).
A complete --help screen carries seven parts in this order: usage line, one-line synopsis, description paragraph, positional arguments, flags with placeholder-style values and defaults, examples, and exit codes.
Before:
$ shipit deploy --help
Usage: shipit deploy
Deploys stuff. Simply pass your key and it will deploy your app really fast.
Options:
--key your api key (e.g. YOUR_API_KEY)
--env environment
--dry-run dry run
--help help
After:
$ shipit deploy --help
Usage: shipit deploy [OPTIONS] SERVICE_NAME
Deploys a service to an environment and waits for it to become healthy.
The command builds the image, uploads it, and replaces one replica at a time.
The rollout stops at the first replica that fails its health check.
Arguments:
SERVICE_NAME The name of the service to deploy, as listed by
`shipit services list`.
Options:
--key API_KEY The API key used to authenticate. Defaults to the
value of SHIPIT_API_KEY.
--env {staging|prod} The target environment. Default: staging.
--replicas COUNT The number of replicas to run. An integer from 1
to 50. Default: 3.
--dry-run If set, prints the deployment plan and exits
without changing anything.
-h, --help Prints this help text and exits.
Examples:
Deploy the checkout service to staging:
shipit deploy checkout
Preview a production rollout with five replicas:
shipit deploy --env prod --replicas 5 --dry-run checkout
Exit codes:
0 The deployment succeeded.
1 The deployment failed and was rolled back.
2 An argument or flag was invalid.
3 The API key was missing or rejected.
What the rewrite fixed: the usage line shows the optional and positional parts; the synopsis states the outcome instead of selling it; every flag names its value in placeholder caps and its default; the boolean flag uses the If set, … action pattern from A3; exit codes let a script branch on the result.
Source: convention (no Google --help page); code-syntax for the usage-line notation
REST/HTTP reference pages (convention)
Google has no REST reference page type either, so the section list below is (convention). The wording inside each cell is not: parameter descriptions follow A3, error descriptions follow A4.
A minimum endpoint page carries six parts: method and path as the heading, a one-sentence purpose, parameter tables split by location, the response with an example body, and an error table.
POST /v1/buckets/{bucketId}/objects
Uploads an object to a bucket and returns its stored metadata.
The following table lists the path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
bucketId |
string | Yes | The ID of the bucket that receives the object. |
The following table lists the query parameters:
| Name | Type | Required | Description |
|---|---|---|---|
ifGenerationMatch |
integer | No | The generation the object must currently have for the write to succeed. Omit to overwrite any generation. |
The following table lists the body parameters:
| Name | Type | Required | Description |
|---|---|---|---|
key |
string | Yes | The object key, up to 1024 bytes of UTF-8. |
contentType |
string | No | The MIME type stored with the object. Default: application/octet-stream. |
public |
boolean | No | If true, grants read access to anyone with the URL. If false, restricts access to the bucket's ACL. Default: false. |
A successful request returns 201 Created and the object's metadata:
{
"key": "invoices/2026-08.pdf",
"generation": 1724947200000001,
"sizeBytes": 48213,
"etag": "d41d8cd98f00b204e9800998ecf8427e",
"createdAt": "2026-08-29T10:00:00Z"
}
The following table lists the errors this endpoint returns:
| Status | Code | Description |
|---|---|---|
| 404 | bucket_not_found |
Returned when no bucket has the given ID, or the credentials can't see it. |
| 409 | generation_mismatch |
Returned when ifGenerationMatch doesn't equal the object's current generation. |
| 413 | object_too_large |
Returned when the body exceeds the 5 TiB per-object limit. |
| 429 | quota_exceeded |
Returned when the project exceeds its write rate. Retry after the interval in the Retry-After header. |
Give every endpoint the same section order and the same tables, including single-row ones. A reader scanning six endpoints reads position, not prose: a page that drops its query-parameter table reads as an endpoint that takes none.
Source: convention (no Google REST reference page); api-reference-comments for the parameter and error wording
| 1 | # API Reference, Docstrings, and CLI Help |
| 2 | |
| 3 | Reference material is descriptive, complete, and formulaic on purpose. Readers arrive at a reference entry mid-task, read one entry, and leave. This file owns rules **A1–A7**. |
| 4 | |
| 5 | **Contents** |
| 6 | [What to document (A1)] · every public element, and what "public" means per language |
| 7 | [Method descriptions: verb by category (A2)] |
| 8 | [Parameters (A3)] · non-boolean, boolean, optional, units |
| 9 | [Return values and exceptions (A4)] |
| 10 | [Deprecations (A5)] |
| 11 | [Complete example: `StorageClient`] · TypeScript, plus a Python mirror |
| 12 | [Reference voice (A7)] |
| 13 | [CLI help text (A6)] and [REST reference pages] — both convention |
| 14 | |
| 15 | |
| 16 | |
| 17 | ## What to document (A1) |
| 18 | |
| 19 | Document every public class, interface, struct, constant, field, enum value, and method. An undocumented public element reads as unsupported: developers skip it, file bugs against it, or reimplement it. A reader can't tell "not documented" from "not there". |
| 20 | |
| 21 | "Public" is defined by the language, not by intent (convention — per-language norms, not the style guide): |
| 22 | |
| 23 | | Language | Public surface | |
| 24 | |----------|----------------| |
| 25 | | TypeScript / JavaScript | Exported from the package entry point, including types and enum members | |
| 26 | | Python | Names without a leading underscore, or listed in `__all__` | |
| 27 | | Rust | `pub` items reachable from the crate root, including fields and variants | |
| 28 | | Go | Identifiers starting with a capital letter, including package-level errors | |
| 29 | | Java / C# | `public` and `protected` members of public types | |
| 30 | |
| 31 | Write the summary as one sentence, first, in the entry's own paragraph. The summary answers "what does this do"; it never restates the name. A second paragraph, when one is needed, adds what the reader can't infer from the signature: side effects, cost, lifecycle, concurrency safety, ordering guarantees, or a link to the task page. |
| 32 | |
| 33 | **Before → after (class summary):** |
| 34 | |
| 35 | Before: `/** StorageClient class. Used for storage. */` |
| 36 | After: `/** Reads and writes objects in a single storage bucket. */` followed by a second paragraph: `A client opens one connection per instance and reuses it. Create one client per bucket and share it across requests; the client is safe for concurrent use.` |
| 37 | |
| 38 | **Before → after (enum value):** |
| 39 | |
| 40 | Before: `ARCHIVE, // archive` |
| 41 | After: `ARCHIVE — Lowest storage price, highest retrieval price. Intended for objects read less than once a year.` |
| 42 | |
| 43 | Source: api-reference-comments |
| 44 | |
| 45 | |
| 46 | |
| 47 | ## Method descriptions: verb by category (A2) |
| 48 | |
| 49 | Open a method description with a third-person present-tense verb chosen by the method's category. The verb tells the reader the shape of the call before they read the parameters. `[EN]` The exact verb wordings below are English; the category-to-verb discipline applies in any language. |
| 50 | |
| 51 | | Category | Opening verb | Example first sentence | |
| 52 | |----------|--------------|------------------------| |
| 53 | | Boolean getter | Checks whether… | `Checks whether the bucket has an active retention policy.` | |
| 54 | | Other getter | Gets the… | `Gets the storage class of the bucket.` | |
| 55 | | Setter | Sets the… | `Sets the retention period, in days, for objects in the bucket.` | |
| 56 | | Creator or factory | Creates a… | `Creates a signed URL that grants temporary read access to an object.` | |
| 57 | | Everything else | Returns / Registers / Sends / Deletes / Validates / Uploads… | `Deletes the object and every one of its versions.` | |
| 58 | |
| 59 | Drop the "This method…" and "This function…" openers, along with "A function that…" and "Method to…". The entry already appears under the member's name and signature, so the phrase spends the reader's first four words on the heading. |
| 60 | |
| 61 | **Before → after:** |
| 62 | |
| 63 | Before: `/** This method is used for getting the customer associated with a subscription. */` |
| 64 | After: `/** Gets the customer that owns the subscription. */` |
| 65 | |
| 66 | Before: `/** Function that checks if a bucket is public or not. */` |
| 67 | After: `/** Checks whether anyone with the URL can read objects in the bucket. */` |
| 68 | |
| 69 | Before: `/** Will create a new signed URL for the object and return it to the caller. */` |
| 70 | After: `/** Creates a signed URL that grants temporary read access to the object. */` |
| 71 | |
| 72 | Source: api-reference-comments |
| 73 | |
| 74 | |
| 75 | |
| 76 | ## Parameters (A3) |
| 77 | |
| 78 | A parameter description is a noun phrase describing the value, not a sentence about the parameter. Non-boolean parameters start with "The" or "A". |
| 79 | |
| 80 | **Booleans take one of two patterns**, chosen by what the flag does: |
| 81 | |
| 82 | | Flag means | Pattern | Example | |
| 83 | |------------|---------|---------| |
| 84 | | An action the call performs | `If true, … If false, …` | `If true, deletes the bucket and every object in it. If false, fails when the bucket still contains objects.` | |
| 85 | | A state the value carries | `True if …; false otherwise` | `True if the object is publicly readable; false otherwise.` | |
| 86 | |
| 87 | **Optional parameters** say so and name the default at the end of the description: "Optional. Connection options such as the region and the request timeout. Defaults to the `us-east-1` region and a 30-second timeout." Where a generator already prints defaults from the signature, repeat them only where the reader can't see the signature — REST body tables and CLI help (convention). |
| 88 | |
| 89 | **Units and ranges** belong in the description, not in the reader's head. Give the unit for every duration, size, rate, and price, and give the accepted range where one exists. |
| 90 | |
| 91 | **Before → after:** |
| 92 | |
| 93 | Before: `@param timeout timeout` |
| 94 | After: `@param timeout The time to wait for a response, in milliseconds. An integer from 1000 to 600000.` |
| 95 | |
| 96 | Before: `@param force force flag` |
| 97 | After: `@param force If true, deletes the bucket even when it contains objects. If false, fails when the bucket isn't empty.` |
| 98 | |
| 99 | Before: `@param amount the amount @param currency currency (optional, default USD)` |
| 100 | After: `@param amount The amount to charge, in the currency's smallest unit — 1099 means $10.99 for USD.` and `@param currency Optional. The three-letter ISO 4217 currency code. Defaults to usd.` |
| 101 | |
| 102 | Source: api-reference-comments |
| 103 | |
| 104 | |
| 105 | |
| 106 | ## Return values and exceptions (A4) |
| 107 | |
| 108 | Describe the return value with the same noun-phrase pattern as parameters: "The…" or "A…", brief, one sentence where possible. A boolean return uses `True if …; false otherwise`. A method returning nothing needs no return entry. |
| 109 | |
| 110 | Exception wording depends on whether the tool prints the word "Throws" for you: |
| 111 | |
| 112 | | Situation | Write | Renders as | |
| 113 | |-----------|-------|------------| |
| 114 | | Tool inserts "Throws" — JSDoc `@throws {E}`, Python `Raises: E:` | `If the bucket doesn't exist.` | Throws `NotFoundError` if the bucket doesn't exist | |
| 115 | | Nothing inserted — prose tables, hand-written reference pages | `Thrown when the bucket doesn't exist.` | as written | |
| 116 | |
| 117 | Document every error type the method throws, one entry each — a caller writing a `catch` needs the full list, including errors raised by validation before any I/O happens. |
| 118 | |
| 119 | Say what comes back when there's nothing to return. `null`, `undefined`, an empty array, and a thrown error are four different contracts, and a reader who guesses wrong ships a crash. |
| 120 | |
| 121 | **Before → after:** |
| 122 | |
| 123 | Before: `@returns the objects @throws error if something goes wrong` |
| 124 | After: `@returns The objects whose keys start with the prefix, sorted by key. Returns an empty array when no object matches.` plus `@throws {NotFoundError} If the bucket doesn't exist.` and `@throws {PermissionDeniedError} If the credentials can't list the bucket.` |
| 125 | |
| 126 | Before: `@returns boolean` |
| 127 | After: `@returns True if the connection is open; false otherwise.` |
| 128 | |
| 129 | Source: api-reference-comments |
| 130 | |
| 131 | |
| 132 | |
| 133 | ## Deprecations (A5) |
| 134 | |
| 135 | A deprecated element names its replacement in the first sentence, because the reader is looking for what to call instead. Add the removal version or date, and one line of migration guidance concrete enough to apply without opening another page. |
| 136 | |
| 137 | **Before → after:** |
| 138 | |
| 139 | Before: `/** @deprecated Deprecated. Do not use. */` |
| 140 | After: |
| 141 | |
| 142 | |
| 143 | /** |
| 144 | * Deprecated: use `createSignedUrl` instead, which returns a URL that expires. |
| 145 | * Removed in v4.0.0 (2027-01-15). Replace `getObjectUrl(key)` with |
| 146 | * `createSignedUrl(key, { expiresInSec: 3600 })`. |
| 147 | * |
| 148 | * Gets a permanent public URL for an object. |
| 149 | */ |
| 150 | |
| 151 | |
| 152 | Keep the original description below the deprecation note — readers still maintaining old code need it. Where a replacement doesn't exist, say what the reader does instead ("Store the object in a public bucket and read `object.publicUrl`.") rather than leaving them to guess. |
| 153 | |
| 154 | Source: api-reference-comments |
| 155 | |
| 156 | |
| 157 | |
| 158 | ## Complete example: `StorageClient` |
| 159 | |
| 160 | **Before** — typical weak comments: names restated, a flag undocumented, a thrown error invisible, a deprecation with no replacement. |
| 161 | |
| 162 | |
| 163 | /** Storage client */ |
| 164 | export class StorageClient { |
| 165 | /** @param bucket bucket @param options options */ |
| 166 | constructor(bucket: string, options?: ClientOptions) {} |
| 167 | |
| 168 | /** connected? */ |
| 169 | get isConnected(): boolean {} |
| 170 | |
| 171 | /** region */ |
| 172 | get region(): string {} |
| 173 | |
| 174 | /** This method deletes a bucket. @param force force flag */ |
| 175 | async deleteBucket(force: boolean): Promise<boolean> {} |
| 176 | |
| 177 | /** Uploads an object. */ |
| 178 | async upload(key: string, body: Buffer): Promise<ObjectMetadata> {} |
| 179 | |
| 180 | /** Deprecated, don't use. */ |
| 181 | getObjectUrl(key: string): string {} |
| 182 | } |
| 183 | |
| 184 | |
| 185 | **After** — every rule in this file applied at once. |
| 186 | |
| 187 | |
| 188 | /** |
| 189 | * Reads and writes objects in a single storage bucket. |
| 190 | * |
| 191 | * A client opens one connection per instance and reuses it for every request. |
| 192 | * Create one client per bucket and share it across requests; the client is |
| 193 | * safe for concurrent use. |
| 194 | */ |
| 195 | export class StorageClient { |
| 196 | /** |
| 197 | * Creates a client for the given bucket. |
| 198 | * |
| 199 | * @param bucket The name of an existing bucket in the caller's project. |
| 200 | * @param options Optional. Connection options such as the region and the |
| 201 | * request timeout. Defaults to the `us-east-1` region and a 30-second |
| 202 | * timeout. |
| 203 | */ |
| 204 | constructor(bucket: string, options: ClientOptions = DEFAULT_OPTIONS) {} |
| 205 | |
| 206 | /** |
| 207 | * Checks whether the client holds an open connection to the bucket. |
| 208 | * |
| 209 | * @returns True if the connection is open; false otherwise. |
| 210 | */ |
| 211 | get isConnected(): boolean {} |
| 212 | |
| 213 | /** |
| 214 | * Gets the region that stores the bucket. |
| 215 | * |
| 216 | * @returns The region code, for example `us-east-1`. |
| 217 | * @throws {NotConnectedError} If the client hasn't connected yet. Call |
| 218 | * `connect` first. |
| 219 | */ |
| 220 | get region(): string {} |
| 221 | |
| 222 | /** |
| 223 | * Deletes the bucket. |
| 224 | * |
| 225 | * @param force If true, deletes the bucket and every object in it. If false, |
| 226 | * fails when the bucket still contains objects. |
| 227 | * @returns True if the bucket was deleted; false if it didn't exist. |
| 228 | */ |
| 229 | async deleteBucket(force: boolean): Promise<boolean> {} |
| 230 | |
| 231 | /** |
| 232 | * Uploads an object and returns its stored metadata. |
| 233 | * |
| 234 | * The upload replaces any object with the same key. To make the write |
| 235 | * conditional, pass a generation to `uploadIfGenerationMatch`. |
| 236 | * |
| 237 | * @param key The object key, up to 1024 bytes of UTF-8. |
| 238 | * @param body The object contents. |
| 239 | * @returns The metadata of the stored object, including its generation |
| 240 | * number and ETag. |
| 241 | * @throws {QuotaExceededError} If the upload would exceed the project's |
| 242 | * storage quota. |
| 243 | * @throws {NotConnectedError} If the client hasn't connected yet. |
| 244 | */ |
| 245 | async upload(key: string, body: Buffer): Promise<ObjectMetadata> {} |
| 246 | |
| 247 | /** |
| 248 | * Deprecated: use `createSignedUrl` instead, which returns a URL that |
| 249 | * expires. Removed in v4.0.0 (2027-01-15). Replace `getObjectUrl(key)` with |
| 250 | * `createSignedUrl(key, { expiresInSec: 3600 })`. |
| 251 | * |
| 252 | * Gets a permanent public URL for an object. |
| 253 | * |
| 254 | * @param key The object key. |
| 255 | * @returns The public URL of the object. |
| 256 | * @deprecated Use `createSignedUrl` instead. |
| 257 | */ |
| 258 | getObjectUrl(key: string): string {} |
| 259 | } |
| 260 | |
| 261 | |
| 262 | The same `upload` entry as a Python docstring, in **Google Python style guide** form (`Args:` / `Returns:` / `Raises:`): |
| 263 | |
| 264 | |
| 265 | def upload(self, key: str, body: bytes) -> ObjectMetadata: |
| 266 | """Uploads an object and returns its stored metadata. |
| 267 | |
| 268 | Args: |
| 269 | key: The object key, up to 1024 bytes of UTF-8. |
| 270 | body: The object contents. |
| 271 | |
| 272 | Returns: |
| 273 | The metadata of the stored object, including its generation number |
| 274 | and ETag. |
| 275 | |
| 276 | Raises: |
| 277 | QuotaExceededError: If the upload would exceed the project's storage |
| 278 | quota. |
| 279 | NotConnectedError: If the client hasn't connected yet. |
| 280 | """ |
| 281 | |
| 282 | |
| 283 | Source: api-reference-comments; Google Python style guide (docstring sections) |
| 284 | |
| 285 | |
| 286 | |
| 287 | ## Reference voice (A7) |
| 288 | |
| 289 | Reference entries describe; guides instruct. The difference is grammatical, and mixing the two inside one reference set makes entries read as inconsistent even when every fact is right. |
| 290 | |
| 291 | | Surface | Voice | Example | |
| 292 | |---------|-------|---------| |
| 293 | | Reference entry | Third-person present, descriptive | `Creates a signed URL that expires after the given interval.` | |
| 294 | | Guide, tutorial, procedure step | Second person, imperative | `Create a signed URL, then send it to the browser.` | |
| 295 | | Usage note inside an entry | Second person, addressed to the caller | Call `connect` before you read `region`. | |
| 296 | |
| 297 | Second person still earns its place in an entry's usage notes and constraints — the lines telling a caller what to do about the behavior just described. Keep it out of the summary line and the parameter, return, and exception descriptions. |
| 298 | |
| 299 | Hold one tense across every entry in the set; a reference where some methods "return" and others "will return" reads as two documents merged. Behavior described in the present is true whenever the reader arrives. |
| 300 | |
| 301 | **Before → after:** |
| 302 | |
| 303 | Before: `Use this method to fetch the invoice. It will return the invoice object.` |
| 304 | After: `Gets the invoice for the given ID. Returns the invoice, including its line items.` |
| 305 | |
| 306 | Voice rules for the surrounding prose — second person, active voice, present tense, no filler — are V1–V10 in [voice-and-words.md]. |
| 307 | |
| 308 | Source: reference-verbs |
| 309 | |
| 310 | |
| 311 | |
| 312 | ## CLI help text (A6, convention) |
| 313 | |
| 314 | Google has no page on `--help` output, so this section is **(convention)**, built on the guide's command-line syntax notation (P9, [procedures-and-code.md]) — `[optional]`, `{a|b}`, `...` — and its placeholder rules (P8, same file). |
| 315 | |
| 316 | A complete `--help` screen carries seven parts in this order: usage line, one-line synopsis, description paragraph, positional arguments, flags with placeholder-style values and defaults, examples, and exit codes. |
| 317 | |
| 318 | **Before:** |
| 319 | |
| 320 | |
| 321 | $ shipit deploy --help |
| 322 | Usage: shipit deploy |
| 323 | |
| 324 | Deploys stuff. Simply pass your key and it will deploy your app really fast. |
| 325 | |
| 326 | Options: |
| 327 | --key your api key (e.g. YOUR_API_KEY) |
| 328 | --env environment |
| 329 | --dry-run dry run |
| 330 | --help help |
| 331 | |
| 332 | |
| 333 | **After:** |
| 334 | |
| 335 | |
| 336 | $ shipit deploy --help |
| 337 | Usage: shipit deploy [OPTIONS] SERVICE_NAME |
| 338 | |
| 339 | Deploys a service to an environment and waits for it to become healthy. |
| 340 | |
| 341 | The command builds the image, uploads it, and replaces one replica at a time. |
| 342 | The rollout stops at the first replica that fails its health check. |
| 343 | |
| 344 | Arguments: |
| 345 | SERVICE_NAME The name of the service to deploy, as listed by |
| 346 | `shipit services list`. |
| 347 | |
| 348 | Options: |
| 349 | --key API_KEY The API key used to authenticate. Defaults to the |
| 350 | value of SHIPIT_API_KEY. |
| 351 | --env {staging|prod} The target environment. Default: staging. |
| 352 | --replicas COUNT The number of replicas to run. An integer from 1 |
| 353 | to 50. Default: 3. |
| 354 | --dry-run If set, prints the deployment plan and exits |
| 355 | without changing anything. |
| 356 | -h, --help Prints this help text and exits. |
| 357 | |
| 358 | Examples: |
| 359 | Deploy the checkout service to staging: |
| 360 | shipit deploy checkout |
| 361 | |
| 362 | Preview a production rollout with five replicas: |
| 363 | shipit deploy --env prod --replicas 5 --dry-run checkout |
| 364 | |
| 365 | Exit codes: |
| 366 | 0 The deployment succeeded. |
| 367 | 1 The deployment failed and was rolled back. |
| 368 | 2 An argument or flag was invalid. |
| 369 | 3 The API key was missing or rejected. |
| 370 | |
| 371 | |
| 372 | What the rewrite fixed: the usage line shows the optional and positional parts; the synopsis states the outcome instead of selling it; every flag names its value in placeholder caps and its default; the boolean flag uses the `If set, …` action pattern from A3; exit codes let a script branch on the result. |
| 373 | |
| 374 | Source: convention (no Google `--help` page); code-syntax for the usage-line notation |
| 375 | |
| 376 | |
| 377 | |
| 378 | ## REST/HTTP reference pages (convention) |
| 379 | |
| 380 | Google has no REST reference page type either, so the section list below is **(convention)**. The wording inside each cell is not: parameter descriptions follow A3, error descriptions follow A4. |
| 381 | |
| 382 | A minimum endpoint page carries six parts: method and path as the heading, a one-sentence purpose, parameter tables split by location, the response with an example body, and an error table. |
| 383 | |
| 384 | ### POST /v1/buckets/{bucketId}/objects |
| 385 | |
| 386 | Uploads an object to a bucket and returns its stored metadata. |
| 387 | |
| 388 | The following table lists the path parameters: |
| 389 | |
| 390 | | Name | Type | Required | Description | |
| 391 | |------|------|----------|-------------| |
| 392 | | `bucketId` | string | Yes | The ID of the bucket that receives the object. | |
| 393 | |
| 394 | The following table lists the query parameters: |
| 395 | |
| 396 | | Name | Type | Required | Description | |
| 397 | |------|------|----------|-------------| |
| 398 | | `ifGenerationMatch` | integer | No | The generation the object must currently have for the write to succeed. Omit to overwrite any generation. | |
| 399 | |
| 400 | The following table lists the body parameters: |
| 401 | |
| 402 | | Name | Type | Required | Description | |
| 403 | |------|------|----------|-------------| |
| 404 | | `key` | string | Yes | The object key, up to 1024 bytes of UTF-8. | |
| 405 | | `contentType` | string | No | The MIME type stored with the object. Default: `application/octet-stream`. | |
| 406 | | `public` | boolean | No | If true, grants read access to anyone with the URL. If false, restricts access to the bucket's ACL. Default: false. | |
| 407 | |
| 408 | A successful request returns `201 Created` and the object's metadata: |
| 409 | |
| 410 | |
| 411 | { |
| 412 | "key": "invoices/2026-08.pdf", |
| 413 | "generation": 1724947200000001, |
| 414 | "sizeBytes": 48213, |
| 415 | "etag": "d41d8cd98f00b204e9800998ecf8427e", |
| 416 | "createdAt": "2026-08-29T10:00:00Z" |
| 417 | } |
| 418 | |
| 419 | |
| 420 | The following table lists the errors this endpoint returns: |
| 421 | |
| 422 | | Status | Code | Description | |
| 423 | |--------|------|-------------| |
| 424 | | 404 | `bucket_not_found` | Returned when no bucket has the given ID, or the credentials can't see it. | |
| 425 | | 409 | `generation_mismatch` | Returned when `ifGenerationMatch` doesn't equal the object's current generation. | |
| 426 | | 413 | `object_too_large` | Returned when the body exceeds the 5 TiB per-object limit. | |
| 427 | | 429 | `quota_exceeded` | Returned when the project exceeds its write rate. Retry after the interval in the `Retry-After` header. | |
| 428 | |
| 429 | Give every endpoint the same section order and the same tables, including single-row ones. A reader scanning six endpoints reads position, not prose: a page that drops its query-parameter table reads as an endpoint that takes none. |
| 430 | |
| 431 | Source: convention (no Google REST reference page); api-reference-comments for the parameter and error wording |
| 432 |
Discussion
Alternatives
Browse more free Claude skills or everything in Development.