Skip to content

Commit 10defd7

Browse files
Added a bit so the transition from short to long docstrings flows better
1 parent 3c0b027 commit 10defd7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

docs/writing/documentation.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,20 @@ really obvious cases, such as::
194194
return a + b
195195

196196
The docstring should describe the function in a way that is easy to understand.
197-
Embedding the function's signature in the docstring is unnecessary because it
198-
can easily be obtained using the `inspect` module, and doesn't provide much
199-
additional information.
197+
For simple cases like trivial functions and classes, simply embedding the
198+
function's signature (i.e. `add(a, b) -> result`) in the docstring is
199+
unnecessary. This is because with Python's `inspect` module, it is already
200+
quite easy to find this information if needed, and it is also readily available
201+
by reading the source code.
202+
203+
In larger or more complex projects however, it is often a good idea to give
204+
more information about a function, what it does, any exceptions it may raise,
205+
what it returns, or relevant details about the parameters.
200206

201207
For more detailed documentation of code a popular style is the one used for the
202208
Numpy project, often called `Numpy style`_ docstrings. While it can take up a
203-
few more lines than usual, it allows the developer to include a lot more
204-
information about a method, function, or class. ::
209+
few more lines the previous example, it allows the developer to include a lot
210+
more information about a method, function, or class. ::
205211

206212
def random_number_generator(arg1, arg2):
207213
"""

0 commit comments

Comments
 (0)