Skip to content

Commit f45f1a9

Browse files
Tyler-Bonnelllwasser
authored andcommitted
Fix a few typos and clean up punctuation
1 parent 2c16c62 commit f45f1a9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

documentation/write-user-documentation/document-your-code-api-docstrings.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ Package APIs consist of functions, classes, methods and attributes that create a
1616

1717
## What is a docstring and how does it relate to documentation?
1818

19-
In Python a docstring refers to text in a function, method or class
19+
In Python, a docstring refers to text in a function, method or class
2020
that describes what the function does and its inputs and outputs. Python programmers usually refer to the inputs to functions as ["parameters"](https://docs.python.org/3/glossary.html#term-parameter) or ["arguments"](https://docs.python.org/3/faq/programming.html#faq-argument-vs-parameter), and the outputs are often called "return values"
2121

2222
The docstring is thus important for:
2323

24-
- When you call `help()` in Python, for example, `help(add_numbers)` will show the text of the function's docstring. The docstring thus helps a user better understand how to applying the function more effectively to their workflow.
25-
- When you build your package's documentation, the docstrings can also be used to automagically create full API documentation that provides a clean view of all its functions, classes, methods, and attributes.
24+
- When you call `help()` in Python, for example, `help(add_numbers)` will show the text of the function's docstring. The docstring thus helps a user better understand how to apply the function more effectively to their workflow.
25+
- When you build your package's documentation, the docstrings can also be used to automatically create full API documentation that provides a clean view of all its functions, classes, methods, and attributes.
2626

2727
```{tip}
2828
Example API Documentation for all functions, classes, methods, and attributes in a package.
29-
* [View example high level API documentation for the Verde package. This page lists every function and class in the package along with a brief explanation of what it does](https://www.fatiando.org/verde/latest/api/index.html)
29+
* [View example high-level API documentation for the Verde package. This page lists every function and class in the package along with a brief explanation of what it does](https://www.fatiando.org/verde/latest/api/index.html)
3030
* [You can further dig down to see what a specific function does within the package by clicking on an API element](https://www.fatiando.org/verde/latest/api/generated/verde.grid_coordinates.html#verde.grid_coordinates)
3131
```
3232

@@ -39,14 +39,14 @@ In Python, this means that you need to add a docstring for
3939
every user-facing
4040
class, method, attribute and/or function in your package (_within reason_) that:
4141

42-
- Explains what the function, method, attribute or class does
42+
- Explains what the function, method, attribute, or class does
4343
- Defines the `type` inputs and outputs (ie. `string`, `int`, `np.array`)
4444
- Explains the expected output `return` of the object, method or function.
4545

4646
(numpy-docstring)=
4747
### Three Python docstring formats and why we like NumPy style
4848

49-
There are several Python docstring formats that you can chose to use when documenting
49+
There are several Python docstring formats that you can choose to use when documenting
5050
your package including:
5151

5252
- [NumPy-style](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard)
@@ -59,7 +59,7 @@ We suggest using [NumPy-style docstrings](https://numpydoc.readthedocs.io/en/lat
5959
Python documentation because:
6060

6161
- NumPy style docstrings are core to the scientific Python ecosystem and defined in the [NumPy style guide](https://numpydoc.readthedocs.io/en/latest/format.html). Thus you will find them widely used there.
62-
- The Numpy style docstring is simplified and thus easier-to-read both in the code and when calling `help()` in Python. In contrast, some feel that reST style docstrings is harder to quickly scan, and can take up more lines of code in modules.
62+
- The Numpy style docstring is simplified and thus easier to read both in the code and when calling `help()` in Python. In contrast, some feel that reST style docstrings are harder to quickly scan, and can take up more lines of code in modules.
6363

6464
```{tip}
6565
If you are using NumPy style docstrings, be sure to include the [sphinx napoleon
@@ -69,10 +69,10 @@ to properly read and format NumPy format docstrings.
6969

7070
### Docstring examples Better and Best
7171

72-
Below is a good example of a well documented function. Notice that this
72+
Below is a good example of a well-documented function. Notice that this
7373
function's docstring describes the function's inputs and the function's output
7474
(or return value). The initial description of the function is short (one line).
75-
Following that single line description there is a slightly longer description of
75+
Following that single-line description, there is a slightly longer description of
7676
what the function does (2 to 3 sentences). The return of the function is also
7777
specified.
7878

@@ -236,7 +236,7 @@ Describing the expected data type that a function or method requires
236236
helps users better understand how to call a function or method.
237237

238238
Type-hints add another layer of type documentation to your code. Type-hints
239-
make make it easier for new developers, your future self or contributors
239+
make it easier for new developers, your future self or contributors
240240
to get to know your code base quickly.
241241

242242
Type hints are added to the definition of your function. In the example below, the parameters aNum and aNum2 are defined as being type = int (integer).

0 commit comments

Comments
 (0)