@@ -13,20 +13,20 @@ and released in the next version.
1313
1414There is a script in pandas that validates whether a docstring follows the
1515technical parts of the pandas docstring convention. To run the script,
16- execute in your terminal:
16+ execute in your terminal: ::
1717
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>
2020
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 ` `.
2323
2424The output of the script will show the final docstring. In many cases just a
2525verbatim copy, but in some cases the docstring is implemented as a template,
2626and reused by more than one method or function, and this is useful to see
2727the final result.
2828
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
3030errors, where the docstring does not respect the convention. For example, a
3131missing dot at the end of a sentence, a blank line where it should not be, etc.
3232
@@ -38,29 +38,31 @@ If you are changing a docstring in a cython file (with ``.pyx`` extension),
3838you need to rebuild the pandas C extensions to be able to see the resulting
3939changes in the docstring and to validate the docstring with the command
4040above.
41- To recompile pandas, run:
4241
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
4546
46472. Visual validation of the docstring
4748-------------------------------------
4849
4950The 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
5152not validate for typos, unclear sentences, or other mistakes. To validate
5253them, as well as the visualization of your docstring in the pandas website
5354you need to generate the html version of the page you worked on.
5455
55- To build the documentation run:
56+ To build the documentation run: ::
5657
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>
5960
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
6162section.
6263
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 ``
6466that can be opened with your web browser.
6567
66683. 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
7779into git.
7880
7981Before 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: ::
8183
82- | `` git branch``
84+ git branch
8385
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
8587into a situation where you need to undo your history in git, which is not
8688straightforward.
8789
88- Then, follow the next steps :
90+ Then, get the latest upstream changes and commit your changes on top: : :
8991
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>"
9496
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
98100docstring of DataFrame.head()").
99101
1001025. Push your changes to pandas
@@ -104,27 +106,29 @@ Once you committed your changes locally, you need to make them available to
104106pandas maintainers, so they can add them to the main pandas repository.
105107
106108The first step is to push your local changes to your own fork, so they are
107- available online:
109+ available online: ::
108110
109- | `` git push -u origin <your-branch-name>``
111+ git push -u origin <your-branch-name>
110112
111113Then, visit https://github.com/pandas-dev/pandas in your browser, and click
112114on the "Compare & pull request" button in the yellow box above the repository
113115files.
114116
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
123127
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 ::
125130
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
128132
129133If the command does not return any warning, mark that checkbox with an X (do
130134not leave spaces inside the brackets, use `[X] `). If it returns a warning,
@@ -146,10 +150,10 @@ contributors.
146150
147151For comments in your review, you can make new changes in your local branch for
148152that 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: : :
151155
152- | `` git push``
156+ git push
153157
154158from your local branch, and the changes will be pushed to your remote branch.
155159
@@ -165,5 +169,5 @@ the same pull request. While in the first contributions is normal to feel
165169frustrated for getting feedback requesting changes, it is actually because of
166170reviews that the open source software quality is very high. And also, it is
167171probably 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
169173feedback in other contributors pull requests too.
0 commit comments