Skip to content

Commit 9388b7f

Browse files
justinludwiglarsoner
authored andcommitted
STY: Reword first lines of example.py docstrings (#246)
* STY: Reword first lines of example.py docstrings Running doc/example.py through [pydocstyle](http://www.pydocstyle.org/) using the "numpy" conventions turns up the following violations for the module docstring: * D205: 1 blank line required between summary line and description (found 0) * D400: First line should end with a period (not 'd') * D404: First word of the docstring should not be `This` * D415: First line should end with a period, question mark, or exclamation point (not 'd') And the following violation for the `foo()` function docstring: * D401: First line should be in imperative mood; try rephrasing (found 'A') This change slightly rewords the first line of both docstrings to better model how docstrings should begin: 1. It reformats the module docstring to place the first sentence on its own line, and remove the superflous "This is the" introduction. 2. It rewords the `foo()` function docstring to rephrase the first line as a command (following the PEP 257 convention). After this change, pydocstyle finds no violations. * BLD: run pydocstyle on example.py in travis
1 parent d5323ae commit 9388b7f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cache:
1616
before_install:
1717
- sudo apt-get install texlive texlive-latex-extra latexmk dvipng
1818
- pip install --upgrade pip setuptools # Upgrade pip and setuptools to get ones with `wheel` support
19-
- pip install pytest pytest-cov numpy matplotlib sphinx${SPHINX_SPEC} codecov
19+
- pip install pytest pytest-cov pydocstyle numpy matplotlib sphinx${SPHINX_SPEC} codecov
2020
script:
2121
- |
2222
python setup.py sdist
@@ -28,6 +28,7 @@ script:
2828
- echo '! python -m numpydoc numpydoc.tests.test_main._invalid_docstring' | bash
2929
- python -m numpydoc --validate numpydoc.tests.test_main._capture_stdout
3030
- echo '! python -m numpydoc --validate numpydoc.tests.test_main._docstring_with_errors' | bash
31+
- pydocstyle --convention numpy ../doc/example.py
3132
# Build documentation
3233
- |
3334
cd ../doc

doc/example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
"""This is the docstring for the example.py module. Modules names should
2-
have short, all-lowercase names. The module name may have underscores if
3-
this improves readability.
1+
"""Docstring for the example.py module.
2+
3+
Modules names should have short, all-lowercase names. The module name may
4+
have underscores if this improves readability.
45
56
Every module should have a docstring at the very top of the file. The
67
module's docstring may extend over multiple lines. If your docstring does
@@ -35,7 +36,7 @@
3536

3637

3738
def foo(var1, var2, long_var_name='hi'):
38-
r"""A one-line summary that does not use variable names.
39+
r"""Summarize the function in one line.
3940
4041
Several sentences providing an extended description. Refer to
4142
variables using back-ticks, e.g. `var`.

0 commit comments

Comments
 (0)