You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/index.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,22 @@
6
6
Documentation is as important to the success of your Python open source package
7
7
as the code itself. Quality code is of course valuable as it gets the tasks
8
8
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.
10
10
11
11
Further, if you wish to build a base of contributors to your package, having
12
12
explicit information about how to contribute is critical.
13
13
14
14
## Documentation elements that pyOpenSci looks for when reviewing a Python package
15
15
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:
19
18
20
19
1.[A clear and to the point **README.md** file](readme-files)
21
20
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 userfacing 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!
23
22
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.
24
23
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.
* [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,
5
17
including:
6
18
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.
9
21
10
22
## User-facing documentation for your Python package:
11
23
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:
14
28
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.
17
32
18
-
### What tools to use in building your documentation: sphinx
33
+
### What tools to use to build your documentation: sphinx
19
34
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.
23
37
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
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.
39
54
40
55
```{tip}
41
56
This book is created using sphinx and the `furo` theme.
42
-
43
57
```
44
58
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
-
58
59
### myST vs rst syntax to create your docs
59
60
There are two commonly used syntaxes for creating docs:
60
61
61
62
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.
62
63
2.[rST:](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) this is the native syntax that sphinx supports.
63
64
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
+
64
71
There is no wrong or right when choosing a syntax to write your documentation.
65
72
Choose whichever syntax works best for you and your community!
66
73
@@ -69,6 +76,20 @@ If you are on the fence about myST vs rst, you might find that *myST* is easier
69
76
for more people to contribute to.
70
77
```
71
78
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
+
72
93
73
94
74
95
## Documentation landing page best practices
@@ -93,8 +114,6 @@ Below is an example of doing this using `myst` syntax.
93
114
````
94
115
`````
95
116
96
-
97
-
98
117
## Python package API documentation
99
118
100
119
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
105
124
* Explains what every input and output variable's (type) is (ie. `string`, `int`, `np.array`)
106
125
* Explains the expected output `return` of the object, method or function.
107
126
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
+
```
108
137
109
138
### Docstring examples Better and Best
110
139
@@ -168,12 +197,3 @@ def extent_to_json(ext_obj):
168
197
```
169
198
170
199
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)
* [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)
0 commit comments