Skip to content

Commit 4416f2d

Browse files
MONGOID-5415: Misc code doc changes (#5429)
* MONGOID-5415: Misc code doc changes * Update docs/contributing/code-documentation.txt Co-authored-by: shields <[email protected]> Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 6c6c0a8 commit 4416f2d

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

source/contributing/code-documentation.txt

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,30 @@ Structure
4848
# @return [ Tiger ] The transmogrified result.
4949
def transmogrify(person)
5050

51+
- **Errors:** Use ``@raise`` to explain errors specific to the method.
52+
53+
.. code-block:: ruby
54+
55+
# @raise [ Errors::Validations ] If validation failed.
56+
def validate!
57+
5158
- **Private Methods:** Private methods should be documented unless they are
5259
so brief and straightforward that it is obvious what they do. Note that,
5360
for example, a method may be brief and straightforward but the type of
54-
its parameter may not be obvious, in which case the parameter needs to
55-
be appropriately documented.
61+
its parameter may not be obvious, in which case the parameter must be
62+
appropriately documented.
5663

5764
.. code-block:: ruby
5865

5966
private
6067

6168
# Documentation is optional here.
62-
def my_internal_method
63-
64-
- **Notes:** Use the ``@note`` macro to explain caveats, edge cases,
65-
and behavior which may surprise users.
66-
67-
.. code-block:: ruby
68-
69-
# Clear all stored data.
70-
#
71-
# @note This operation deletes data in the database.
72-
def erase_data!
69+
def do_something_obvious
7370

7471
- **API Private:** Classes and public methods which are not intended for
7572
external usage should be marked ``@api private``. This macro does not
7673
require a comment.
77-
74+
7875
Note that, because Mongoid's modules are mixed into application classes,
7976
``private`` visibility of a method does not necessarily indicate its
8077
status as an API private method.
@@ -86,6 +83,18 @@ Structure
8683
# @api private
8784
def dont_call_me_from_outside
8885

86+
- **Notes and TODOs:** Use ``@note`` to explain caveats, edge cases,
87+
and behavior which may surprise users. Use ``@todo`` to record
88+
follow-ups and suggestions for future improvement.
89+
90+
.. code-block:: ruby
91+
92+
# Clear all stored data.
93+
#
94+
# @note This operation deletes data in the database.
95+
# @todo Refactor this method for performance.
96+
def erase_data!
97+
8998
- **Deprecation:** Use the ``@deprecated`` macro to indicate deprecated
9099
functionality. This macro does not require a comment.
91100

0 commit comments

Comments
 (0)