@@ -17,7 +17,7 @@ Also, it is a common practice to generate online (html) documentation
17
17
automatically from docstrings. `Sphinx <https://www.sphinx-doc.org >`_ serves
18
18
this purpose.
19
19
20
- Next example gives an idea on how a docstring looks like:
20
+ The next example gives an idea of what a docstring looks like:
21
21
22
22
.. code-block :: python
23
23
@@ -26,8 +26,8 @@ Next example gives an idea on how a docstring looks like:
26
26
Add up two integer numbers.
27
27
28
28
This function simply wraps the `+` operator, and does not
29
- do anything interesting, except for illustrating what is
30
- the docstring of a very simple function.
29
+ do anything interesting, except for illustrating what
30
+ the docstring of a very simple function looks like .
31
31
32
32
Parameters
33
33
----------
@@ -56,14 +56,14 @@ Next example gives an idea on how a docstring looks like:
56
56
"""
57
57
return num1 + num2
58
58
59
- Some standards exist about docstrings, so they are easier to read, and they can
60
- be exported to other formats such as html or pdf.
59
+ Some standards regarding docstrings exist, which make them easier to read, and allow them
60
+ be easily exported to other formats such as html or pdf.
61
61
62
62
The first conventions every Python docstring should follow are defined in
63
63
`PEP-257 <https://www.python.org/dev/peps/pep-0257/ >`_.
64
64
65
- As PEP-257 is quite open, and some other standards exist on top of it . In the
66
- case of pandas, the numpy docstring convention is followed. The conventions is
65
+ As PEP-257 is quite broad, other more specific standards also exist . In the
66
+ case of pandas, the numpy docstring convention is followed. These conventions are
67
67
explained in this document:
68
68
69
69
* `numpydoc docstring guide <https://numpydoc.readthedocs.io/en/latest/format.html >`_
@@ -83,8 +83,8 @@ about reStructuredText can be found in:
83
83
pandas has some helpers for sharing docstrings between related classes, see
84
84
:ref: `docstring.sharing `.
85
85
86
- The rest of this document will summarize all the above guides , and will
87
- provide additional convention specific to the pandas project.
86
+ The rest of this document will summarize all the above guidelines , and will
87
+ provide additional conventions specific to the pandas project.
88
88
89
89
.. _docstring.tutorial :
90
90
@@ -101,9 +101,9 @@ left before or after the docstring. The text starts in the next line after the
101
101
opening quotes. The closing quotes have their own line
102
102
(meaning that they are not at the end of the last sentence).
103
103
104
- In rare occasions reST styles like bold text or italics will be used in
104
+ On rare occasions reST styles like bold text or italics will be used in
105
105
docstrings, but is it common to have inline code, which is presented between
106
- backticks. It is considered inline code:
106
+ backticks. The following are considered inline code:
107
107
108
108
* The name of a parameter
109
109
* Python code, a module, function, built-in, type, literal... (e.g. ``os ``,
@@ -235,8 +235,8 @@ The extended summary provides details on what the function does. It should not
235
235
go into the details of the parameters, or discuss implementation notes, which
236
236
go in other sections.
237
237
238
- A blank line is left between the short summary and the extended summary. And
239
- every paragraph in the extended summary is finished by a dot.
238
+ A blank line is left between the short summary and the extended summary.
239
+ Every paragraph in the extended summary ends with a dot.
240
240
241
241
The extended summary should provide details on why the function is useful and
242
242
their use cases, if it is not too generic.
@@ -542,19 +542,19 @@ first (not an alias like ``np``). If the function is in a module which is not
542
542
the main one, like ``scipy.sparse ``, list the full module (e.g.
543
543
``scipy.sparse.coo_matrix ``).
544
544
545
- This section, as the previous, also has a header, "See Also" (note the capital
546
- S and A). Also followed by the line with hyphens, and preceded by a blank line.
545
+ This section has a header, "See Also" (note the capital
546
+ S and A), followed by the line with hyphens and preceded by a blank line.
547
547
548
548
After the header, we will add a line for each related method or function,
549
549
followed by a space, a colon, another space, and a short description that
550
- illustrated what this method or function does, why is it relevant in this
551
- context, and what are the key differences between the documented function and
552
- the one referencing . The description must also finish with a dot.
550
+ illustrates what this method or function does, why is it relevant in this
551
+ context, and what the key differences are between the documented function and
552
+ the one being referenced . The description must also end with a dot.
553
553
554
- Note that in "Returns" and "Yields", the description is located in the
555
- following line than the type. But in this section it is located in the same
556
- line, with a colon in between. If the description does not fit in the same
557
- line, it can continue in the next ones, but it has to be indented in them .
554
+ Note that in "Returns" and "Yields", the description is located on the line
555
+ after the type. In this section, however, it is located on the same
556
+ line, with a colon in between. If the description does not fit on the same
557
+ line, it can continue onto other lines which must be further indented .
558
558
559
559
For example:
560
560
@@ -587,7 +587,7 @@ Section 6: Notes
587
587
~~~~~~~~~~~~~~~~
588
588
589
589
This is an optional section used for notes about the implementation of the
590
- algorithm. Or to document technical aspects of the function behavior.
590
+ algorithm, or to document technical aspects of the function behavior.
591
591
592
592
Feel free to skip it, unless you are familiar with the implementation of the
593
593
algorithm, or you discover some counter-intuitive behavior while writing the
@@ -600,15 +600,15 @@ This section follows the same format as the extended summary section.
600
600
Section 7: Examples
601
601
~~~~~~~~~~~~~~~~~~~
602
602
603
- This is one of the most important sections of a docstring, even if it is
604
- placed in the last position. As often, people understand concepts better
605
- with examples, than with accurate explanations.
603
+ This is one of the most important sections of a docstring, despite being
604
+ placed in the last position, as often people understand concepts better
605
+ by example than through accurate explanations.
606
606
607
607
Examples in docstrings, besides illustrating the usage of the function or
608
- method, must be valid Python code, that in a deterministic way returns the
609
- presented output , and that can be copied and run by users.
608
+ method, must be valid Python code, that returns the given output in a
609
+ deterministic way , and that can be copied and run by users.
610
610
611
- They are presented as a session in the Python terminal. `>>> ` is used to
611
+ Examples are presented as a session in the Python terminal. `>>> ` is used to
612
612
present code. `... ` is used for code continuing from the previous line.
613
613
Output is presented immediately after the last line of code generating the
614
614
output (no blank lines in between). Comments describing the examples can
@@ -636,7 +636,7 @@ A simple example could be:
636
636
Return the first elements of the Series.
637
637
638
638
This function is mainly useful to preview the values of the
639
- Series without displaying the whole of it.
639
+ Series without displaying all of it.
640
640
641
641
Parameters
642
642
----------
0 commit comments