Skip to content

Commit 331aed6

Browse files
Improved documentation guides.
1 parent 56401c1 commit 331aed6

4 files changed

Lines changed: 70 additions & 40 deletions

File tree

context/documentation-coverage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ A definition is considered documented if it has:
6060
- A `@namespace` pragma (for organizational modules).
6161

6262
```ruby
63-
# Represents a user in the system.
63+
# A user in the system.
6464
class MyClass
6565
end
6666

@@ -130,7 +130,7 @@ Returns true if authentication is successful.
130130
### Document all public APIs
131131

132132
```ruby
133-
# Represents a user management system.
133+
# A user account with authentication and email.
134134
class User
135135
# @attribute [String] The user's email address.
136136
attr_reader :email

context/ruby-documentation.md

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This guide covers documentation practices and pragmas supported by the Decode ge
99
#### Definition Documentation
1010

1111
- Full sentences: All documentation for definitions (classes, modules, methods) should be written as complete sentences with proper grammar and punctuation.
12-
- Class documentation: Documentation for classes should generally start with "Represents a ..." to clearly indicate what the class models or encapsulates.
12+
- Class documentation: Should directly describe what the class *is* or *does*.
13+
- For data/model classes, "A user account in the system." works well.
14+
- For functional classes (servers, clients, connections), lead with what the class does: "An HTTP client that manages persistent connections...".
1315
- Method documentation: Should clearly describe what the method does, not how it does it.
1416
- Markdown format: All documentation comments are written in Markdown format, allowing for rich formatting including lists, emphasis, code blocks, and links.
1517

@@ -32,8 +34,12 @@ This guide covers documentation practices and pragmas supported by the Decode ge
3234

3335
#### Examples
3436

37+
##### Data/Model Classes
38+
39+
For classes that model domain concepts, describe what the class is:
40+
3541
```ruby
36-
# Represents a user account in the system.
42+
# A user account in the system.
3743
class User
3844
# @attribute [String] The user's email address.
3945
attr_reader :email
@@ -70,26 +76,35 @@ class User
7076
true
7177
end
7278
end
79+
```
7380

74-
# Represents a collection of users with search capabilities.
75-
class UserCollection
76-
# Find users matching the given criteria.
77-
# @parameter criteria [Hash] Search parameters.
78-
# @returns [Array(User)] Matching users.
79-
def find(**criteria)
80-
# Start with all users:
81-
results = @users.dup
82-
83-
# Apply each filter criterion:
84-
criteria.each do |key, value|
85-
results = filter_by(results, key, value)
86-
end
87-
88-
results
81+
##### Functional/Service Classes
82+
83+
For classes that *do* something (clients, servers, processors), lead with what the class does:
84+
85+
```ruby
86+
# An HTTP client that manages persistent connections to a remote server, with automatic retries for idempotent requests.
87+
class Client
88+
# Send a request to the remote server.
89+
# @parameter request [Protocol::HTTP::Request] The request to send.
90+
# @returns [Protocol::HTTP::Response] The response from the server.
91+
def call(request)
92+
# ...
93+
end
94+
95+
# Close the client and release all connections.
96+
def close
97+
# ...
8998
end
9099
end
100+
101+
# Raised when a connection to the remote server cannot be established.
102+
class ConnectionError < StandardError
103+
end
91104
```
92105

106+
Note the difference: `User` is described as a thing ("A user account..."), while `Client` is described by what it does ("An HTTP client that manages..."), and `ConnectionError` is described by when it occurs ("Raised when...").
107+
93108
**Key formatting examples from above:**
94109
- `{disable!}` - Creates a link to the `disable!` method (relative reference)
95110
- `active?` - Formats the method name in monospace (backticks for code formatting)
@@ -155,7 +170,7 @@ Type signatures are used to specify the expected types of parameters, return val
155170
Documents class attributes, instance variables, and `attr_*` declarations. Prefer to have one attribute per line for clarity.
156171

157172
```ruby
158-
# Represents a person with basic attributes.
173+
# A person with basic attributes.
159174
class Person
160175
# @attribute [String] The person's full name.
161176
attr_reader :name

guides/documentation-coverage/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ A definition is considered documented if it has:
6060
- A `@namespace` pragma (for organizational modules).
6161

6262
```ruby
63-
# Represents a user in the system.
63+
# A user in the system.
6464
class MyClass
6565
end
6666

@@ -130,7 +130,7 @@ Returns true if authentication is successful.
130130
### Document all public APIs
131131

132132
```ruby
133-
# Represents a user management system.
133+
# A user account with authentication and email.
134134
class User
135135
# @attribute [String] The user's email address.
136136
attr_reader :email

guides/ruby-documentation/readme.md

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This guide covers documentation practices and pragmas supported by the Decode ge
99
#### Definition Documentation
1010

1111
- Full sentences: All documentation for definitions (classes, modules, methods) should be written as complete sentences with proper grammar and punctuation.
12-
- Class documentation: Documentation for classes should generally start with "Represents a ..." to clearly indicate what the class models or encapsulates.
12+
- Class documentation: Should directly describe what the class *is* or *does*.
13+
- For data/model classes, "A user account in the system." works well.
14+
- For functional classes (servers, clients, connections), lead with what the class does: "An HTTP client that manages persistent connections...".
1315
- Method documentation: Should clearly describe what the method does, not how it does it.
1416
- Markdown format: All documentation comments are written in Markdown format, allowing for rich formatting including lists, emphasis, code blocks, and links.
1517

@@ -32,8 +34,12 @@ This guide covers documentation practices and pragmas supported by the Decode ge
3234

3335
#### Examples
3436

37+
##### Data/Model Classes
38+
39+
For classes that model domain concepts, describe what the class is:
40+
3541
```ruby
36-
# Represents a user account in the system.
42+
# A user account in the system.
3743
class User
3844
# @attribute [String] The user's email address.
3945
attr_reader :email
@@ -70,26 +76,35 @@ class User
7076
true
7177
end
7278
end
79+
```
7380

74-
# Represents a collection of users with search capabilities.
75-
class UserCollection
76-
# Find users matching the given criteria.
77-
# @parameter criteria [Hash] Search parameters.
78-
# @returns [Array(User)] Matching users.
79-
def find(**criteria)
80-
# Start with all users:
81-
results = @users.dup
82-
83-
# Apply each filter criterion:
84-
criteria.each do |key, value|
85-
results = filter_by(results, key, value)
86-
end
87-
88-
results
81+
##### Functional/Service Classes
82+
83+
For classes that *do* something (clients, servers, processors), lead with what the class does:
84+
85+
```ruby
86+
# An HTTP client that manages persistent connections to a remote server, with automatic retries for idempotent requests.
87+
class Client
88+
# Send a request to the remote server.
89+
# @parameter request [Protocol::HTTP::Request] The request to send.
90+
# @returns [Protocol::HTTP::Response] The response from the server.
91+
def call(request)
92+
# ...
93+
end
94+
95+
# Close the client and release all connections.
96+
def close
97+
# ...
8998
end
9099
end
100+
101+
# Raised when a connection to the remote server cannot be established.
102+
class ConnectionError < StandardError
103+
end
91104
```
92105

106+
Note the difference: `User` is described as a thing ("A user account..."), while `Client` is described by what it does ("An HTTP client that manages..."), and `ConnectionError` is described by when it occurs ("Raised when...").
107+
93108
**Key formatting examples from above:**
94109
- `{disable!}` - Creates a link to the `disable!` method (relative reference)
95110
- `active?` - Formats the method name in monospace (backticks for code formatting)
@@ -155,7 +170,7 @@ Type signatures are used to specify the expected types of parameters, return val
155170
Documents class attributes, instance variables, and `attr_*` declarations. Prefer to have one attribute per line for clarity.
156171

157172
```ruby
158-
# Represents a person with basic attributes.
173+
# A person with basic attributes.
159174
class Person
160175
# @attribute [String] The person's full name.
161176
attr_reader :name

0 commit comments

Comments
 (0)