You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: context/ruby-documentation.md
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@ This guide covers documentation practices and pragmas supported by the Decode ge
9
9
#### Definition Documentation
10
10
11
11
- 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...".
13
15
- Method documentation: Should clearly describe what the method does, not how it does it.
14
16
- Markdown format: All documentation comments are written in Markdown format, allowing for rich formatting including lists, emphasis, code blocks, and links.
15
17
@@ -32,8 +34,12 @@ This guide covers documentation practices and pragmas supported by the Decode ge
32
34
33
35
#### Examples
34
36
37
+
##### Data/Model Classes
38
+
39
+
For classes that model domain concepts, describe what the class is:
40
+
35
41
```ruby
36
-
#Represents a user account in the system.
42
+
#A user account in the system.
37
43
classUser
38
44
# @attribute [String] The user's email address.
39
45
attr_reader:email
@@ -70,26 +76,35 @@ class User
70
76
true
71
77
end
72
78
end
79
+
```
73
80
74
-
# Represents a collection of users with search capabilities.
75
-
classUserCollection
76
-
# Find users matching the given criteria.
77
-
# @parameter criteria [Hash] Search parameters.
78
-
# @returns [Array(User)] Matching users.
79
-
deffind(**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
+
classClient
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
+
defcall(request)
92
+
# ...
93
+
end
94
+
95
+
# Close the client and release all connections.
96
+
defclose
97
+
# ...
89
98
end
90
99
end
100
+
101
+
# Raised when a connection to the remote server cannot be established.
102
+
classConnectionError < StandardError
103
+
end
91
104
```
92
105
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
+
93
108
**Key formatting examples from above:**
94
109
-`{disable!}` - Creates a link to the `disable!` method (relative reference)
95
110
-`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
155
170
Documents class attributes, instance variables, and `attr_*` declarations. Prefer to have one attribute per line for clarity.
Copy file name to clipboardExpand all lines: guides/ruby-documentation/readme.md
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@ This guide covers documentation practices and pragmas supported by the Decode ge
9
9
#### Definition Documentation
10
10
11
11
- 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...".
13
15
- Method documentation: Should clearly describe what the method does, not how it does it.
14
16
- Markdown format: All documentation comments are written in Markdown format, allowing for rich formatting including lists, emphasis, code blocks, and links.
15
17
@@ -32,8 +34,12 @@ This guide covers documentation practices and pragmas supported by the Decode ge
32
34
33
35
#### Examples
34
36
37
+
##### Data/Model Classes
38
+
39
+
For classes that model domain concepts, describe what the class is:
40
+
35
41
```ruby
36
-
#Represents a user account in the system.
42
+
#A user account in the system.
37
43
classUser
38
44
# @attribute [String] The user's email address.
39
45
attr_reader:email
@@ -70,26 +76,35 @@ class User
70
76
true
71
77
end
72
78
end
79
+
```
73
80
74
-
# Represents a collection of users with search capabilities.
75
-
classUserCollection
76
-
# Find users matching the given criteria.
77
-
# @parameter criteria [Hash] Search parameters.
78
-
# @returns [Array(User)] Matching users.
79
-
deffind(**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
+
classClient
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
+
defcall(request)
92
+
# ...
93
+
end
94
+
95
+
# Close the client and release all connections.
96
+
defclose
97
+
# ...
89
98
end
90
99
end
100
+
101
+
# Raised when a connection to the remote server cannot be established.
102
+
classConnectionError < StandardError
103
+
end
91
104
```
92
105
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
+
93
108
**Key formatting examples from above:**
94
109
-`{disable!}` - Creates a link to the `disable!` method (relative reference)
95
110
-`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
155
170
Documents class attributes, instance variables, and `attr_*` declarations. Prefer to have one attribute per line for clarity.
0 commit comments