Skip to content

Commit 80f0aff

Browse files
committed
More docs lint.
1 parent b0ca8f5 commit 80f0aff

File tree

4 files changed

+125
-26
lines changed

4 files changed

+125
-26
lines changed

nexus/types/src/external_api/params.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub struct SamlIdentityProviderSelector {
207207

208208
// The shape of this selector is slightly different than the others given that
209209
// silos users can only be specified via ID and are automatically provided by
210-
// the environment the user is authetnicated in
210+
// the environment the user is authenticated in
211211
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
212212
pub struct SshKeySelector {
213213
/// ID of the silo user
@@ -542,9 +542,9 @@ pub struct SiloAuthSettingsUpdate {
542542
/// Create-time parameters for a `User`
543543
#[derive(Clone, Deserialize, JsonSchema)]
544544
pub struct UserCreate {
545-
/// username used to log in
545+
/// Username used to log in
546546
pub external_id: UserId,
547-
/// how to set the user's login password
547+
/// How to set the user's login password
548548
pub password: UserPassword,
549549
}
550550

@@ -641,11 +641,11 @@ pub struct UsernamePasswordCredentials {
641641

642642
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
643643
pub struct DerEncodedKeyPair {
644-
/// request signing public certificate (base64 encoded der file)
644+
/// Request signing public certificate (base64 encoded DER file)
645645
#[serde(deserialize_with = "x509_cert_from_base64_encoded_der")]
646646
pub public_cert: String,
647647

648-
/// request signing RSA private key in PKCS#1 format (base64 encoded der file)
648+
/// Request signing RSA private key in PKCS#1 format (base64 encoded DER file)
649649
#[serde(deserialize_with = "key_from_base64_encoded_der")]
650650
pub private_key: String,
651651
}
@@ -765,25 +765,25 @@ pub struct SamlIdentityProviderCreate {
765765
#[serde(flatten)]
766766
pub identity: IdentityMetadataCreateParams,
767767

768-
/// the source of an identity provider metadata descriptor
768+
/// The source of an identity provider metadata descriptor.
769769
pub idp_metadata_source: IdpMetadataSource,
770770

771-
/// idp's entity id
771+
/// IdP's entity ID.
772772
pub idp_entity_id: String,
773773

774-
/// sp's client id
774+
/// SP's client ID.
775775
pub sp_client_id: String,
776776

777-
/// service provider endpoint where the response will be sent
777+
/// Service provider endpoint where the response will be sent.
778778
pub acs_url: String,
779779

780-
/// service provider endpoint where the idp should send log out requests
780+
/// Service provider endpoint where the IdP should send log out requests.
781781
pub slo_url: String,
782782

783-
/// customer's technical contact for saml configuration
783+
/// Customer's technical contact for SAML configuration.
784784
pub technical_contact_email: String,
785785

786-
/// request signing key pair
786+
/// Request signing key pair.
787787
#[serde(default)]
788788
#[serde(deserialize_with = "validate_key_pair")]
789789
pub signing_keypair: Option<DerEncodedKeyPair>,
@@ -992,7 +992,7 @@ pub struct InstanceNetworkInterfaceUpdate {
992992
/// Create-time parameters for a `Certificate`
993993
#[derive(Clone, Deserialize, Serialize, JsonSchema)]
994994
pub struct CertificateCreate {
995-
/// common identifying metadata
995+
/// Common identifying metadata
996996
#[serde(flatten)]
997997
pub identity: IdentityMetadataCreateParams,
998998
/// PEM-formatted string containing public certificate chain
@@ -1328,7 +1328,7 @@ pub struct InstanceCreate {
13281328
#[serde(default)]
13291329
pub auto_restart_policy: Option<InstanceAutoRestartPolicy>,
13301330

1331-
/// Anti-Affinity groups which this instance should be added.
1331+
/// Anti-affinity groups to which this instance should be added.
13321332
#[serde(default)]
13331333
pub anti_affinity_groups: Vec<NameOrId>,
13341334

@@ -1694,7 +1694,7 @@ impl JsonSchema for BlockSize {
16941694
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
16951695
metadata: Some(Box::new(schemars::schema::Metadata {
16961696
id: None,
1697-
title: Some("disk block size in bytes".to_string()),
1697+
title: Some("Disk block size in bytes".to_string()),
16981698
..Default::default()
16991699
})),
17001700
instance_type: Some(schemars::schema::InstanceType::Integer.into()),
@@ -1733,7 +1733,7 @@ impl From<DiskVariant> for PhysicalDiskKind {
17331733
pub enum DiskSource {
17341734
/// Create a blank disk
17351735
Blank {
1736-
/// size of blocks for this Disk. valid values are: 512, 2048, or 4096
1736+
/// Size of blocks for this disk. Valid values are: 512, 2048, or 4096.
17371737
block_size: BlockSize,
17381738
},
17391739

@@ -1817,7 +1817,7 @@ pub struct AddressLotCreate {
18171817
pub blocks: Vec<AddressLotBlockCreate>,
18181818
}
18191819

1820-
/// Parameters for creating an address lot block. Fist and last addresses are
1820+
/// Parameters for creating an address lot block. First and last addresses are
18211821
/// inclusive.
18221822
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
18231823
pub struct AddressLotBlockCreate {
@@ -1849,6 +1849,7 @@ pub struct LoopbackAddressCreate {
18491849
pub mask: u8,
18501850

18511851
/// Address is an anycast address.
1852+
///
18521853
/// This allows the address to be assigned to multiple locations simultaneously.
18531854
pub anycast: bool,
18541855
}
@@ -2198,7 +2199,7 @@ pub struct BgpAnnouncementCreate {
21982199
pub network: IpNet,
21992200
}
22002201

2201-
/// Parameters for creating a BGP configuration. This includes and autonomous
2202+
/// Parameters for creating a BGP configuration. This includes an autonomous
22022203
/// system number (ASN) and a virtual routing and forwarding (VRF) identifier.
22032204
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
22042205
pub struct BgpConfigCreate {
@@ -2378,7 +2379,7 @@ pub struct Distribution {
23782379
/// Create-time parameters for an `Image`
23792380
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
23802381
pub struct ImageCreate {
2381-
/// common identifying metadata
2382+
/// Common identifying metadata
23822383
#[serde(flatten)]
23832384
pub identity: IdentityMetadataCreateParams,
23842385

@@ -2397,7 +2398,7 @@ pub struct ImageCreate {
23972398
/// Create-time parameters for a `Snapshot`
23982399
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
23992400
pub struct SnapshotCreate {
2400-
/// common identifying metadata
2401+
/// Common identifying metadata
24012402
#[serde(flatten)]
24022403
pub identity: IdentityMetadataCreateParams,
24032404

nexus/types/src/external_api/shared.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,9 @@ pub struct BfdStatus {
422422
pub mode: BfdMode,
423423
}
424424

425-
/// Opaque object representing link state. The contents of this object are not
426-
/// yet stable.
425+
/// Opaque object representing link state.
426+
///
427+
/// The contents of this object are not yet stable.
427428
#[derive(Clone, Debug, Deserialize, Serialize)]
428429
pub struct SwitchLinkState {
429430
link: serde_json::Value,

nexus/types/src/external_api/views.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ pub struct Vpc {
294294
#[serde(flatten)]
295295
pub identity: IdentityMetadata,
296296

297-
/// id for the project containing this VPC
297+
/// ID for the project containing this VPC
298298
pub project_id: Uuid,
299299

300-
/// id for the system router where subnet default routes are registered
300+
/// ID for the system router where subnet default routes are registered
301301
pub system_router_id: Uuid,
302302

303303
/// The unique local IPv6 address range for subnets in this VPC
@@ -312,7 +312,7 @@ pub struct Vpc {
312312
/// them, within an IPv4 subnetwork or optionally an IPv6 subnetwork.
313313
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
314314
pub struct VpcSubnet {
315-
/// common identifying metadata
315+
/// Common identifying metadata
316316
#[serde(flatten)]
317317
pub identity: IdentityMetadata,
318318

@@ -340,7 +340,7 @@ pub enum VpcRouterKind {
340340
/// should be sent depending on its destination.
341341
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
342342
pub struct VpcRouter {
343-
/// common identifying metadata
343+
/// Common identifying metadata
344344
#[serde(flatten)]
345345
pub identity: IdentityMetadata,
346346

prompts/openapi_lint.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# API Docstring Style Guide
2+
3+
This guide covers public docstrings (`///` or `/** ... */`) on structs, fields,
4+
and enums in `nexus/types/src/external_api/`. These docstrings become user-facing
5+
API documentation.
6+
7+
## Capitalization
8+
9+
- Start all docstrings with a capital letter.
10+
11+
```rust
12+
// Bad
13+
/// the source of an identity provider metadata descriptor
14+
pub idp_metadata_source: IdpMetadataSource,
15+
16+
// Good
17+
/// The source of an identity provider metadata descriptor.
18+
pub idp_metadata_source: IdpMetadataSource,
19+
```
20+
21+
## Punctuation
22+
23+
- End all sentences with periods, including single-sentence docstrings.
24+
- Non-sentence fragments (e.g., short labels) do not need to end with periods.
25+
26+
```rust
27+
// Bad
28+
/// The IP address held by this resource
29+
pub ip: IpAddr,
30+
31+
// Good
32+
/// The IP address held by this resource.
33+
pub ip: IpAddr,
34+
35+
// Also acceptable - fragment, not a sentence
36+
/// Common identifying metadata
37+
pub identity: IdentityMetadata,
38+
```
39+
40+
## Paragraph Separation
41+
42+
- Separate distinct thoughts or notes with a blank `///` line. This produces
43+
proper paragraph breaks in rendered documentation.
44+
45+
```rust
46+
// Bad - renders as one run-on paragraph
47+
/// A unique, immutable, system-controlled identifier for the token.
48+
/// Note that this ID is not the bearer token itself, which starts with
49+
/// "oxide-token-".
50+
pub id: Uuid,
51+
52+
// Good - renders as two paragraphs
53+
/// A unique, immutable, system-controlled identifier for the token.
54+
///
55+
/// Note that this ID is not the bearer token itself, which starts with
56+
/// "oxide-token-".
57+
pub id: Uuid,
58+
```
59+
60+
## Acronyms and Abbreviations
61+
62+
- Use standard casing for acronyms:
63+
- "IdP" (Identity Provider)
64+
- "SP" (Service Provider)
65+
- "SAML", "ID", "IP", "VPC", "CPU", "RAM"
66+
67+
## Doc Comments vs Regular Comments
68+
69+
- Use `///` for public API documentation that users will see.
70+
- Use `//` for internal implementation notes that should not appear in generated
71+
docs.
72+
73+
```rust
74+
// Bad - this won't appear in API docs
75+
// A list containing the IDs of the secret keys.
76+
pub secrets: Vec<WebhookSecret>,
77+
78+
// Good - this will appear in API docs
79+
/// A list containing the IDs of the secret keys.
80+
pub secrets: Vec<WebhookSecret>,
81+
```
82+
83+
## Scope
84+
85+
These rules apply to:
86+
- Public struct docstrings (`/// View of a Silo`)
87+
- Public field docstrings (`/// The IP address held by this resource.`)
88+
- Public enum variant docstrings (`/// The sled is currently active.`)
89+
90+
These rules do NOT apply to:
91+
- Private functions or structs
92+
- Internal comments (`//`)
93+
- Module-level documentation (`//!`)
94+
95+
## General
96+
97+
- Follow standard English grammatical rules.

0 commit comments

Comments
 (0)