Skip to content

Commit 57a8c8e

Browse files
committed
Fix: Review edits from @lwasser and @arianesasso
1 parent ce6c074 commit 57a8c8e

File tree

2 files changed

+72
-53
lines changed

2 files changed

+72
-53
lines changed

documentation/index.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
Documentation is as important to the success of your Python open source package
77
as the code itself. Quality code is of course valuable as it gets the tasks
88
that your package seeks to achieve, done. However, if users don't understand
9-
how to use the tools in your package, then they won't use your tool.
9+
how to use your package in their workflows, then they won't use it.
1010

1111
Further, if you wish to build a base of contributors to your package, having
1212
explicit information about how to contribute is critical.
1313

1414
## Documentation elements that pyOpenSci looks for when reviewing a Python package
1515

16-
17-
In the pyOpenSci peer review process we look for several things when evaluating
18-
package documentation including:
16+
In the pyOpenSci open peer review process we look for several files and elements
17+
when evaluating package documentation, including:
1918

2019
1. [A clear and to the point **README.md** file](readme-files)
2120
2. **User oriented package documentation** that helps users understand how to install, use and cite your package.
22-
3. **Package API documentation.** Package API documentation refers to documentation for each class, function, method and attribute that is user facing in your package. This mean means that your package methods and classes have docstrings that are formatted with explanations of each variable and better yet quick vignettes that demonstrate how to use the function or class). If you don't know what API documentation means this section is for you!
21+
3. **Package API documentation.** Package API documentation refers to documentation for each class, function, method and attribute that is user-facing (*available for a user to see*) in your package. This mean that your package methods and classes should have [thoughtful docstrings](https://pandas.pydata.org/docs/development/contributing_docstring.html) that describe both the purpose of the code element and each input and output. To help your users better understand how to use your package, you can include short code examples that demonstrate how to use the function or class in each docstring. If you don't know what API documentation means this section of the pyOpenSci Python packaging guide is for you!
2322
4. A **CONTRIBUTING.md** file that outlines how others can contribute to your package. This file should also link to your development guide and code of conduct. A well-crafted contributing guide will make it much easier for the community to contribute to your project.
2423
5. A **CODE_OF_CONDUCT.md** file.
25-
5. **License & Citation:** A license file and instructions for citing your package.
24+
5. **LICENSE.txt file & Citation instructions:** A license file and instructions for citing your package.
2625

2726

2827

documentation/package-documentation-sphinx.md

Lines changed: 67 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,73 @@
11
# Python Package Documentation
22

3-
In addition to a well designed [README FILE](create-readme-files)
4-
there are several core components of Python package documentation
3+
4+
```{note}
5+
Examples of documentation that we love:
6+
7+
* [geopandas](https://geopandas.org/en/stable/)
8+
* [View rst to create landing page](https://raw.githubusercontent.com/geopandas/geopandas/main/doc/source/index.rst)
9+
* [verde](https://www.fatiando.org/verde/latest/)
10+
* [View verde landing page code - rst file.](https://github.com/fatiando/verde/blob/main/doc/index.rst)
11+
* [Here is our documentation if you want to see a myST example of a landing page.](https://github.com/pyOpenSci/python-package-guide/blob/main/index.md)
12+
```
13+
14+
In addition to a well designed [README FILE](readme-file-best-practices), and a
15+
[contributing file](contributing-file),
16+
there are several core components of Python package documentation,
517
including:
618

7-
* **User-facing documentation:** This refers to easy-to-read documentation that a user will review. This documentation should help users install and use your package.
8-
* **API documentation:** this is documentation contained within the docstrings of all user-facing functions, methods and classes in your package.
19+
* **User-facing documentation:** This refers to easy-to-read documentation that helps a user work with your package. This documentation should help users both install and use the functionality of your package.
20+
* **API documentation:** API documentation is generated from [docstrings](https://pandas.pydata.org/docs/development/contributing_docstring.html) found in your code. Ideally you have docstrings for all user-facing functions, methods and classes in your Python package.
921

1022
## User-facing documentation for your Python package:
1123

12-
User-facing documentation is often an easy to navigate website written with
13-
user friendly, less technical language. User facing documentation should be:
24+
User-facing documentation should be published on a easy-to-navigate website. All language should be written with non-developer users in mind. This means
25+
using language that is less technical.
26+
27+
A few tips to make sure your documentation is accessible include:
1428

15-
* easy to read (consider writing for a 12th grade audience)
16-
* contain tutorials or vignettes that support getting started using your package
29+
* Whenever possible, define technical terms and jargon.
30+
* Consider writing writing instructions for a 12th grade level reader.
31+
* Include step by step code examples, tutorials or vignettes that support getting started using your package.
1732

18-
### What tools to use in building your documentation: sphinx
33+
### What tools to use to build your documentation: sphinx
1934

20-
Most python packages maintainers use [sphinx](https://www.sphinx-doc.org/) to build their documentation.
21-
Sphinx has documentation themes that give your docuemntation a clean online look that are easy to apply to your
22-
package's documentation.
35+
Most python packages use [sphinx](https://www.sphinx-doc.org/) to build their documentation.
36+
Sphinx has documentation themes that are easy to apply and help you quickly and easily build an easy-to navigate website.
2337

24-
While you are free to use whatever theme works for you,
25-
the most common modern templates that we see in the scientific
26-
community currently and recommend are:
38+
Sphinx also offers extensions that support:
39+
40+
* [automatically documenting your API using docstrings in your code](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html)
41+
* [running and testing code examples in your docstrings (doctest)](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html)
42+
43+
While you are free to use whatever sphinx theme you prefer,
44+
the most common modern templates that recommend for the Python scientific
45+
community are:
2746

2847
* [pydata-sphinx-theme](https://pydata-sphinx-theme.readthedocs.io/)
2948
* [sphinx-book-theme](https://sphinx-book-theme.readthedocs.io/)
3049
* [furo](https://pradyunsg.me/furo/quickstart/)
3150

32-
Both of the above themes support [myst](https://myst-parser.readthedocs.io/) which allows you to build your package
33-
documentation in `markdown` rather than `.rst`.
34-
35-
Sphinx also offers extensions that support things like:
36-
37-
* [automatically documenting your API using docstrings in your code](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html)
38-
* [running and testing code examples in your docstrings (doctest)](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html)
51+
All of the above themes support [myst](https://myst-parser.readthedocs.io/)
52+
which allows you to build your package documentation in using `markdown`
53+
rather than `.rst`. More on that below.
3954

4055
```{tip}
4156
This book is created using sphinx and the `furo` theme.
42-
4357
```
4458

45-
### How to host your documentation
46-
47-
We suggest that you setup a website to host your documentation. There are two ways
48-
to do this:
49-
50-
1. You can host your documentation yourself using gh-pages or another online hosting service.
51-
2. You can host your documentation using ReadTheDocs.
52-
53-
If you don't want to maintain a documentation website for your Python package, we
54-
suggest using the [READTHEDOCS platform](https://www.readthedocs.org) which
55-
allows you to easily host your documentation and track versions of your docs
56-
as you release updates.
57-
5859
### myST vs rst syntax to create your docs
5960
There are two commonly used syntaxes for creating docs:
6061

6162
1. [myST:](https://myst-parser.readthedocs.io/en/latest/intro.html) myST is a fusion of markdown and rST. It is a nice option if you are more comfortable writing markdown. But more flexible than markdown.
6263
2. [rST:](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) this is the native syntax that sphinx supports.
6364

65+
Markdown is often a preferred syntax to use because:
66+
67+
* It is often thought to be simpler and thus easier to learn;
68+
* Most of your core python package text files, such as your README.md file, are already in `.md` format
69+
* `GitHub` and `Jupyter Notebooks` support this default text file format.
70+
6471
There is no wrong or right when choosing a syntax to write your documentation.
6572
Choose whichever syntax works best for you and your community!
6673

@@ -69,6 +76,20 @@ If you are on the fence about myST vs rst, you might find that *myST* is easier
6976
for more people to contribute to.
7077
```
7178

79+
### How to host your Python package documentation
80+
81+
We suggest that you setup a website to host your documentation. There are two
82+
ways to do quickly create a documentation website:
83+
84+
1. You can host your documentation yourself using [GitHub Pages](https://pages.github.com/) or another online hosting service.
85+
2. You can host your documentation using [Read the Docs](https://readthedocs.org/).
86+
87+
If you don't want to maintain a documentation website for your Python package,
88+
we suggest using Read the Docs. Read the Docs allows you to:
89+
90+
* quickly launch a website using the documentation found in your GitHub repository.
91+
* track versions of your documentation as you release updates
92+
7293

7394

7495
## Documentation landing page best practices
@@ -93,8 +114,6 @@ Below is an example of doing this using `myst` syntax.
93114
````
94115
`````
95116

96-
97-
98117
## Python package API documentation
99118

100119
API documentation refers to explanation about the function, inputs and outputs
@@ -105,6 +124,16 @@ in python requires that you use a docstring for each class, function or method t
105124
* Explains what every input and output variable's (type) is (ie. `string`, `int`, `np.array`)
106125
* Explains the expected output `return` of the object, method or function.
107126

127+
### Python docstring format best-practices
128+
129+
There are several Python docstring formats that you can chose to use when documenting
130+
your package. We suggest using [numpy-style docstrings](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard).
131+
132+
```{tip}
133+
If you are using `numpy-style` docstrings, be sure to include the sphinx napoleon
134+
extension in your documentation `conf.py` file. This extension allows sphinx
135+
to properly read and format numpy-style docstrings.
136+
```
108137

109138
### Docstring examples Better and Best
110139

@@ -168,12 +197,3 @@ def extent_to_json(ext_obj):
168197
```
169198

170199

171-
```{note}
172-
Examples of documentation that we love:
173-
174-
* [geopandas](https://geopandas.org/en/stable/)
175-
* [View rst to create landing page](https://raw.githubusercontent.com/geopandas/geopandas/main/doc/source/index.rst)
176-
* [verde](https://www.fatiando.org/verde/latest/)
177-
* [View verde landing page code - rst file.](https://github.com/fatiando/verde/blob/main/doc/index.rst)
178-
* [Here is our documentation if you want to see a myST example of a landing page.](https://github.com/pyOpenSci/python-package-guide/blob/main/index.md)
179-
```

0 commit comments

Comments
 (0)