@@ -13,20 +13,20 @@ and released in the next version.
13
13
14
14
There is a script in pandas that validates whether a docstring follows the
15
15
technical parts of the pandas docstring convention. To run the script,
16
- execute in your terminal:
16
+ execute in your terminal: ::
17
17
18
- | `` cd <pandas-dir>``
19
- | `` python scripts/validate_docstrings.py <your-function-or-method>``
18
+ cd <pandas-dir>
19
+ python scripts/validate_docstrings.py <your-function-or-method>
20
20
21
- where `<your-function-or-method> ` is for example `pandas.DataFrame.head `,
22
- `pandas.Series.tail ` or `pandas.to_datetime `.
21
+ where `` <your-function-or-method> `` is for example `` pandas.DataFrame.head ` `,
22
+ `` pandas.Series.tail `` or `` pandas.to_datetime ` `.
23
23
24
24
The output of the script will show the final docstring. In many cases just a
25
25
verbatim copy, but in some cases the docstring is implemented as a template,
26
26
and reused by more than one method or function, and this is useful to see
27
27
the final result.
28
28
29
- The output will also contain a list of issues with the docstring. Mainly style
29
+ The output will also highlight any issues with the docstring. Mainly style
30
30
errors, where the docstring does not respect the convention. For example, a
31
31
missing dot at the end of a sentence, a blank line where it should not be, etc.
32
32
@@ -38,29 +38,31 @@ If you are changing a docstring in a cython file (with ``.pyx`` extension),
38
38
you need to rebuild the pandas C extensions to be able to see the resulting
39
39
changes in the docstring and to validate the docstring with the command
40
40
above.
41
- To recompile pandas, run:
42
41
43
- | ``cd <pandas-dir>``
44
- | ``python setup.py build_ext --inplace``
42
+ To recompile pandas, run: ::
43
+
44
+ cd <pandas-dir>
45
+ python setup.py build_ext --inplace
45
46
46
47
2. Visual validation of the docstring
47
48
-------------------------------------
48
49
49
50
The previous script validates things like the names of the sections, or
50
- that there are dots, spaces, or blank lines in the right side. But does
51
+ that there are dots, spaces, or blank lines in the right place. It does
51
52
not validate for typos, unclear sentences, or other mistakes. To validate
52
53
them, as well as the visualization of your docstring in the pandas website
53
54
you need to generate the html version of the page you worked on.
54
55
55
- To build the documentation run:
56
+ To build the documentation run: ::
56
57
57
- | `` cd <pandas-dir>/doc``
58
- | `` python make.py html --single <your-function-or-method>``
58
+ cd <pandas-dir>/doc
59
+ python make.py html --single <your-function-or-method>
59
60
60
- where `<your-function-or-method> ` follows the format described in the previous
61
+ where `` <your-function-or-method> ` ` follows the format described in the previous
61
62
section.
62
63
63
- This will generate a file `<pandas-dir>/doc/build/html/generated_single/<your-function-or-method>.html `
64
+ This will generate a file
65
+ ``<pandas-dir>/doc/build/html/generated_single/<your-function-or-method>.html ``
64
66
that can be opened with your web browser.
65
67
66
68
3. Validate that the docstring is clear to others
@@ -77,24 +79,24 @@ Once all the validations are successful, you can proceed to commit the changes
77
79
into git.
78
80
79
81
Before committing your changes, make sure you are in the branch of the feature
80
- you are going to commit with:
82
+ you are going to commit with: ::
81
83
82
- | `` git branch``
84
+ git branch
83
85
84
- If the current branch is `master `, do not commit your changes, as you can get
86
+ If the current branch is `` master ` `, do not commit your changes, as you can get
85
87
into a situation where you need to undo your history in git, which is not
86
88
straightforward.
87
89
88
- Then, follow the next steps :
90
+ Then, get the latest upstream changes and commit your changes on top: : :
89
91
90
- | `` git fetch upstream``
91
- | `` git merge upstream/master``
92
- | `` git add <modified-file(s)>``
93
- | `` git commit -m "<commit-message>"``
92
+ git fetch upstream
93
+ git merge upstream/master
94
+ git add <modified-file(s)>
95
+ git commit -m "<commit-message>"
94
96
95
- where `<modified-file(s)> ` is the file where you made your changes (in rare
96
- cases it could be more than one file). And `<commit-message> ` is a short
97
- description of your changes, starting by "DOC:" (e.g. "DOC: Improved the
97
+ where `` <modified-file(s)> ` ` is the file where you made your changes (in rare
98
+ cases it could be more than one file). And `` <commit-message> ` ` is a short
99
+ description of your changes, starting by "DOC:" (e.g. "DOC: Improve the
98
100
docstring of DataFrame.head()").
99
101
100
102
5. Push your changes to pandas
@@ -104,27 +106,29 @@ Once you committed your changes locally, you need to make them available to
104
106
pandas maintainers, so they can add them to the main pandas repository.
105
107
106
108
The first step is to push your local changes to your own fork, so they are
107
- available online:
109
+ available online: ::
108
110
109
- | `` git push -u origin <your-branch-name>``
111
+ git push -u origin <your-branch-name>
110
112
111
113
Then, visit https://github.com/pandas-dev/pandas in your browser, and click
112
114
on the "Compare & pull request" button in the yellow box above the repository
113
115
files.
114
116
115
- If you have only one commit, the pull request will automatically use its
116
- comment as title. Otherwise, please name it following the same standard as
117
- described before (e.g. "DOC: Improved the docstring of DataFrame.head()").
118
- In the body of the description, there are some checkboxes. For the sprint,
119
- we do not have an issue for each docstring change, and as we are not changing
120
- code, we do not need to add/run tests or add a `whatsnew ` entry. So you can
121
- ignore these check boxes. Just verify that your changes respect the PEP-8
122
- style by running the command:
117
+ If you have only one commit, the pull request will automatically use its commit
118
+ message as title. Otherwise, please name it following the same standard as
119
+ described before (e.g. "DOC: Improve the docstring of DataFrame.head()"). In
120
+ the body of the description, there are some checkboxes. For the sprint, we do
121
+ not have an issue for each docstring change, and as we are not changing code,
122
+ we do not need to add/run tests or add a `whatsnew ` entry. So you can ignore
123
+ these check boxes. Just verify that your changes respect the PEP-8 style by
124
+ running the command: ::
125
+
126
+ git diff upstream/master -u -- "*.py" | flake8 --diff
123
127
124
- | ``git diff upstream/master -u -- "*.py" | flake8 --diff``
128
+ If you don't already have flake8 installed, you can install it in the Anaconda
129
+ Prompt it via ::
125
130
126
- If you don't already have flake8 installed, you can install it in the Anaconda Prompt it via
127
- | ``conda install flake8``
131
+ conda install flake8
128
132
129
133
If the command does not return any warning, mark that checkbox with an X (do
130
134
not leave spaces inside the brackets, use `[X] `). If it returns a warning,
@@ -146,10 +150,10 @@ contributors.
146
150
147
151
For comments in your review, you can make new changes in your local branch for
148
152
that pull request. And once you addressed all the comments, you can commit them
149
- and push again to your local branch. As you used the parameter `-u ` in your
150
- first push, you can simply run:
153
+ and push again to your local branch. As you used the parameter `` -u `` to set
154
+ the upstream branch in your first push, you can simply run: : :
151
155
152
- | `` git push``
156
+ git push
153
157
154
158
from your local branch, and the changes will be pushed to your remote branch.
155
159
@@ -165,5 +169,5 @@ the same pull request. While in the first contributions is normal to feel
165
169
frustrated for getting feedback requesting changes, it is actually because of
166
170
reviews that the open source software quality is very high. And also, it is
167
171
probably the part of contributing to open source projects in which you will
168
- learn more . So, be patient and enjoy. And feel free to provide constructive
172
+ learn the most . So, be patient and enjoy. And feel free to provide constructive
169
173
feedback in other contributors pull requests too.
0 commit comments