Skip to content

Commit 17cb0a8

Browse files
committed
docs: add concrete Rust code style examples to linting guidelines
- Add error enum formatting rules with line breaks between variants - Add documentation comment formatting rules with blank lines after headings - Include clear examples showing incorrect vs correct formatting
1 parent 4399a84 commit 17cb0a8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

docs/linting.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,60 @@ and CI environments. The workflow runs on every push and pull request.
5151
- **YAML**: `.yamllint-ci.yml` - Controls line length, indentation, etc.
5252
- **TOML**: `.taplo.toml` - Controls formatting, indentation, array handling, etc.
5353

54+
## Rust Code Style Guidelines
55+
56+
### Error Enums
57+
58+
Error enum variants should be separated by blank lines for better readability.
59+
60+
**Incorrect** - No line breaks between variants:
61+
62+
```rust
63+
/// Errors that can occur when creating a `CloudInitContext`
64+
#[derive(Error, Debug, Clone)]
65+
pub enum CloudInitContextError {
66+
#[error("SSH public key is required but not provided")]
67+
MissingSshPublicKey,
68+
#[error("Failed to read SSH public key from file: {0}")]
69+
SshPublicKeyReadError(String),
70+
}
71+
```
72+
73+
**Correct** - Line breaks between variants:
74+
75+
```rust
76+
/// Errors that can occur when creating a `CloudInitContext`
77+
#[derive(Error, Debug, Clone)]
78+
pub enum CloudInitContextError {
79+
#[error("SSH public key is required but not provided")]
80+
MissingSshPublicKey,
81+
82+
#[error("Failed to read SSH public key from file: {0}")]
83+
SshPublicKeyReadError(String),
84+
}
85+
```
86+
87+
### Documentation Comments
88+
89+
Documentation sections like `# Errors`, `# Panics`, `# Examples`, etc. should have a blank line after the heading.
90+
91+
**Incorrect** - No blank line after heading:
92+
93+
```rust
94+
/// # Errors
95+
/// Returns an error if the file cannot be read
96+
pub fn name() { /* ... */ }
97+
```
98+
99+
**Correct** - Blank line after heading:
100+
101+
```rust
102+
/// # Errors
103+
///
104+
/// Returns an error if the file cannot be read
105+
pub fn name() { /* ... */ }
106+
```
107+
54108
## Benefits
55109

56110
**Consistent formatting** across all team members

0 commit comments

Comments
 (0)