Skip to content

Commit 0a02186

Browse files
committed
Fix: add tutorial and coc text and general cleanup
1 parent 217dfc3 commit 0a02186

7 files changed

+130
-39
lines changed

documentation/contributing-file.md renamed to documentation/contributing-license-coc.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ by the Open Software Initiative (OSI). OSI's website has a
8181

8282
If you choose your license through GitHub, you can also automatically get a copy of the license file to add to your repository.
8383

84-
## Code of conducT
85-
86-
contributors convenant...
84+
## The CODE_OF_CONDUCT.md file
85+
Your package should have a CODE_OF_CONDUCT.md file located
86+
the root of the repository. If you are not comfortable creating
87+
your own code of conduct text, we encourage you to adopt the
88+
code of conduct language used in the [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
89+
[Many other communities](https://www.contributor-covenant.org/adopters/) have adopted this code of conduct as
90+
their own including the [Fatiando](https://github.com/fatiando/community/blob/main/CODE_OF_CONDUCT.md) scientific geoscience community.
8791

8892
<!--
8993
pyOpenSci packages must:

documentation/index.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Documentation for your Open Source Python Package - An Overview
22

3+
```{important}
4+
## Quick Takeaways: Documentation must haves
5+
6+
Your package should at a minimum have:
7+
* README.MD file
8+
* CONTRIBUTING.md file
9+
* CODE_OF_CONDUCT.md
10+
* LICENSE.txt
11+
* User-facing documentation website with tutorials
12+
* API documentation (often found in the user facing documentation website)
13+
14+
The pages in this section of our guide provide you with more
15+
detail about creating each of the above elements. We also suggest
16+
tools that will help you build your documentation.
17+
```
318

419
## Documentation is critical to the success of your Python open source package
520

@@ -17,22 +32,20 @@ In the pyOpenSci open peer review process we look for several files and elements
1732
when evaluating package documentation, including:
1833

1934
1. [A clear and to the point **README.md** file](readme-file-best-practices)
20-
1. **User oriented package documentation** that helps users understand how to install, use and cite your package.
35+
1. [**User focused package documentation**](package-documentation-best-practices) that helps users understand how to install, use and cite your package. Documentation is most often contained in a stand-alone website.
2136
1. **Tutorials and quick start code examples** that help a user get started using your package.
22-
1. **Package API documentation.** Package API documentation refers to documentation for each class, function, method and user-facing attribute (*available for a user to see*) in your package. This means 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 showing 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-
1. 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-
1. A **CODE_OF_CONDUCT.md** file.
25-
1. **LICENSE.txt file & Citation instructions:** A license file and instructions for citing your package.
26-
27-
37+
1. **Package API documentation.** Package API documentation refers to documentation for each class, function, method and user-facing attribute (*available for a user to see*) in your package. This means 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.
38+
1. A [**CONTRIBUTING.md** file](contributing-license-coc) 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.
39+
1. A [**CODE_OF_CONDUCT.md**](contributing-license-coc.html#the-code-of-conduct-md-file) file. This file sets up the guidelines for how your community interacts. It ideally ensures that everyone feels safe and can report inappropriate behavior if need be. <!--<not sure why header targets aren't working here with sphinx they work online> -->
40+
1. [**LICENSE.txt file & Citation instructions:**](contributing-license-coc.html#your-repository-should-have-a-license-md-file) A license file declaring the OSI-approved license that you select and instructions for citing your package.
2841

2942
```{figure} ../images/moving-pandas-python-package-github-main-repo.png
3043
---
3144
name: directive-fig
3245
width: 80%
3346
alt: Image showing the files in the Moving Pandas GitHub repository.
3447
---
35-
An example GitHub repository with all of the major files in it including CONTRIBUTING.md, README.md, CODE_OF_CONDUCT.md and a LICENSE.txt file. *(screen shot taken Nov 23 2022)*
48+
An example from the MovingPandas GitHub repository with all of the major files in it including CONTRIBUTING.md, README.md, CODE_OF_CONDUCT.md and a LICENSE.txt file. *(screen shot taken Nov 23 2022)*
3649
```
3750

3851
The above files are evaluated on many online platforms that track package health.
@@ -44,7 +57,7 @@ has in their GitHub repository.
4457
name: directive-fig
4558
width: 80%
4659
---
47-
GitHub community health looks for a readme file among other elements when it evaluates the community level health of your repository. This example is from the [moving pandas GitHub repo](https://github.com/anitagraser/movingpandas/community) *(screen shot taken Nov 23 2022)*
60+
GitHub community health looks for a readme file among other elements when it evaluates the community level health of your repository. This example is from the [MovingPandas GitHub repo](https://github.com/anitagraser/movingpandas/community) *(screen shot taken Nov 23 2022)*
4861
```
4962

5063
SNYK is another well-known company that keeps tabs on package health.
@@ -63,7 +76,7 @@ Screenshot showing [SNYK](https://snyk.io/advisor/python/movingpandas) package h
6376
## What's next in this Python package documentation section?
6477

6578
The rest of the pages in this section will walk you through best practices for setting up
66-
documentation for your Python package.
79+
documentation for your Python package. We will also suggest tools that you can use to build your user-facing documentation website.
6780

6881

6982
<!-- # TODO LINK TO CI BUILD examples FOR Documentation - we have plenty in our repos already for folks to look at. -->

documentation/package-documentation-best-practices.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Best practices for writing user-facing documentation for your Python package
22

3+
```{important}
4+
## Quick takeaways: best practices
5+
6+
Your package:
7+
* Should have a documentation website
8+
* All of its functions and classes (the API) documented
9+
* Your package should use numpy-style docstrings
10+
* Your documentation landing page should direct users to 4 core sections: get started, documentation content, about and community.
11+
* Documentation should include short quick-start tutorials
12+
```
13+
314
In addition to a well designed [README.md file](readme-file-best-practices),
415
and a [CONTRIBUTING.md file](contributing-file),
516
there are several core components of Python package documentation,
617
including:
718

819
* **User-facing documentation website:** 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+
* Your user facing documentation should also include [short tutorials that show a user how to quickly get started using your package](python-package-documentation-tools.html#create-python-package-tutorials-that-both-help-users-and-test-your-package-s-code). If you use a tool such as sphinx-gallery or nbsphinx that runs the code in your tutorials, then these tutorials can also become an important part of your package's test suite.
921
* **API documentation:** The API refers to the functions and classes in a
1022
package that makes up the user interface. API documentation is generated from [docstrings](https://pandas.pydata.org/docs/development/contributing_docstring.html) found in your
1123
code. Ideally you have docstrings for all user-facing functions, methods and classes in
@@ -53,11 +65,20 @@ Below is an example of doing this using `myst` syntax.
5365
````
5466
`````
5567

56-
## API's and Docstrings
68+
## Create tutorials in your documentation
69+
Your package should have tutorials that make it easy for a user
70+
to get started using your package. Ideally, those tutorials
71+
also can be run from start to finish providing a second set of
72+
checks (on top of your test suite) to your package's code base.
5773

58-
### What is an API?
74+
In the [documentation tools page](python-package-documentation-tools) we talk about two sphinx extensions (sphinx gallery and nbsphinx)
75+
that allow you to create reproducible tutorials that are run
76+
when your sphinx documentation builds.
5977

60-
API standards for **A**pplied **P**rogramming **I**nterface. When
78+
## Documenting the code in your package's API using docstrings
79+
80+
### What is an API?
81+
API stands for **A**pplied **P**rogramming **I**nterface. When
6182
discussed in the context of a (Python) package, the API refers to
6283
the interface and tools that you, as a package user, use in a package.
6384

documentation/python-package-documentation-tools.md

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ important points page -->
1010
* Use Sphinx to build your documentation
1111
* Publish your documentation on ReadTheDocs (or GitHub pages if you are more advanced and also prefer to maintain your website locally)
1212
* Use `myST` syntax to write your documentation
13-
* Use sphinx gallery to write tutorials using .py files that automagically have downloadable .py and jupyter notebook files. Use nbsphinx if you prefer writing tutorials in jupyter notebook format and don't need a grid formatted gallery.
13+
* Use sphinx gallery to write tutorials using .py files that automagically have downloadable .py and jupyter notebook files. Use nbsphinx if you prefer writing tutorials in jupyter notebook format and don't need a grid formatted gallery. *Both of these tools will run your tutorials from beginning to end providing an addition layer of testing to your package!*
1414
1515
```
1616

1717
In addition to your:
18-
* [README.md file](readme-file-best-practices.md),
19-
* [CONTRIBUTING.md and development guides and LICENSE file](contributing-file.md),
18+
* [README.md file](readme-file-best-practices),
19+
* [CONTRIBUTING.md and development guides and LICENSE file](contributing-license-coc),
2020

2121
you should also have user-facing documentation for your Python
2222
package. Most often, user-facing documentation is contained on a hosted
@@ -30,9 +30,9 @@ Here, we focus on tools and infrastructure that you can use.
3030
[Click here if you want to learn more about documentation best practices](package-documentation-best-practices.md).
3131

3232
```{note}
33-
Examples of documentation that we love:
33+
Examples of documentation websites that we love:
3434
35-
* [geopandas](https://geopandas.org/en/stable/)
35+
* [GeoPandas](https://geopandas.org/en/stable/)
3636
* [View rst to create landing page](https://raw.githubusercontent.com/geopandas/geopandas/main/doc/source/index.rst)
3737
* [verde](https://www.fatiando.org/verde/latest/)
3838
* [View verde landing page code - rst file.](https://github.com/fatiando/verde/blob/main/doc/index.rst)
@@ -107,7 +107,7 @@ If you are on the fence about myST vs rst, you might find that **myST** is easie
107107
for more people to contribute to.
108108
```
109109

110-
## Sphinx extensions to support python package tutorials
110+
## Create python package tutorials that both help users and test your package's code
111111

112112
Adding well constructed tutorials to your package will make it easier for someone
113113
new to begin using your package.
@@ -135,12 +135,34 @@ your documentation, the gallery extension:
135135
1. Creates a rendered **.html** page with the code elements and code outputs in a user-friendly tutorial gallery.
136136
1. Creates a gallery landing page with visual thumbnails for each tutorial that you create
137137

138-
<!-- TODO: Add thumbnails out tutorial outputs -->
138+
139+
```{figure} ../images/sphinx-gallery-overview.png
140+
---
141+
name: directive-fig
142+
width: 80%
143+
alt: Image showing the gallery output provided by sphinx-gallery where each tutorial is in a grid and the tutorial thumbnails are created from a graphic in the tutorial.
144+
---
145+
`sphinx-gallery` makes it easy to create a user-friendly tutorial gallery.
146+
Each tutorial has a download link where the user can download a **.py** file or a Jupyter Notebook. And it renders the tutorials in a user-friendly grid.
147+
```
148+
149+
Below you can see what a tutorial looks like created with sphinx-gallery.
150+
151+
```{figure} ../images/sphinx-gallery-tutorial.png
152+
---
153+
name: directive-fig
154+
width: 80%
155+
alt: Image showing ta single tutorial from sphinx gallery. The tutorial shows a simple matplotlib created plot and associated code.
156+
---
157+
`sphinx-gallery` tutorials by default include download links for both the
158+
python script (**.py** file) and a Jupyter notebook (**.ipynb** file) at the bottom.
159+
```
139160

140161
### Sphinx Gallery benefits
141162
* easy-to-download notebook and .py outputs for each tutorials
142163
* .py files are easy to work with in the GitHub pull request environment.
143-
* Nice gridded gallery output
164+
* Nice gridded gallery output
165+
* Build execution time data per tutorial [Example](https://sphinx-gallery.github.io/stable/auto_examples/sg_execution_times.html)
144166

145167
#### Sphinx gallery challenges
146168

@@ -157,13 +179,31 @@ These nuances can make it challenging for potential contributors to add
157179
tutorials to your package. This can also present maintenance challenge.
158180

159181
Add about the gallery setup -
182+
183+
```bash
184+
$ docs % make html
185+
186+
Sphinx-Gallery successfully executed 2 out of 2 files
187+
```
188+
File directory structure:
189+
160190
```bash
161191
tutorials/
162192
index.rst # landing page for your gallery
163-
tutorial.py # a tutorial
164-
plot_tutorial.py # a tutorial that produces a plot output
165-
tutorial_outputs/
166-
add fils here...
193+
plot_tutorial.py # a tutorial
194+
plot_tutorial-2.py # a tutorial that produces a plot output
195+
_build/
196+
build_examples/ # This is where the downloadable tutorial files live
197+
plot_sample-1.ipynb
198+
plot_sample-1.py
199+
...
200+
html/
201+
built_examples/ # You can specify this dir name in gallery settings
202+
index.html
203+
plot_sample-1.html
204+
plot_sample.html
205+
sg_execution_times.html # in case you want to see build times for each tutorial
206+
167207
```
168208

169209
### [nbsphinx - tutorials using Jupyter Notebooks](https://nbsphinx.readthedocs.io/en/latest/)
@@ -193,8 +233,19 @@ tutorials/
193233
index.md # Landing page for your gallery
194234
tutorial.ipynb # A tutorial in a jupyter notebook
195235
another_tutorial.ipynb
196-
tutorial_outputs/
197-
add fils here...
198-
```
236+
# This shows you what the build directory looks like when you build with sphinx-build
237+
_build/
238+
html/
239+
# Notice that nbsphinx runs each notebook and produces an
240+
# html file with all of the outputs of your code
241+
# you can link to the notebook in your docs by modifying
242+
# the nbsphinx build - we will cover this in a separate tutorial series focused on python packaging!
243+
tutorials/
244+
index.html
245+
index.md
246+
plot_sample-2.html
247+
plot_sample-2.ipynb
248+
...
249+
```
199250

200251

images/sphinx-gallery-overview.png

245 KB
Loading

images/sphinx-gallery-tutorial.png

342 KB
Loading

index.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ Learn about our open peer review process
5252
✨ Documentation Criteria & Recommendations ✨
5353
^^^
5454

55-
Learn about the good, better and best practices
56-
associated with Python package documentation. Topics
57-
covered include: README files, tutorials and full docs.
55+
Learn more about the best practices for Python package
56+
documentation and also some of the tools for creating
57+
documentation that are
58+
commonly used in the scientific Python community.
5859
:::
5960

6061
:::{grid-item-card}
@@ -64,8 +65,9 @@ covered include: README files, tutorials and full docs.
6465

6566
✨ Package Structure & Code ✨
6667
^^^
67-
<!--
68-
Get a basic overview of our open peer review process for Python scientific open source software. -->
68+
Under Construction - Coming Spring 2023!
69+
Learn more about standards for packaging structure and
70+
builds in the scientific Python community.
6971
:::
7072

7173
:::{grid-item-card}
@@ -112,11 +114,11 @@ to see here, [we invite you to open an issue on GitHub that details any changes
112114
:caption: Documentation
113115
114116
Documentation Overview <documentation/index>
115-
Package Documentation Best Practices <documentation/package-documentation-best-practices>
116-
Package Documentation Tools <documentation/python-package-documentation-tools>
117+
Best Practices for Docs <documentation/package-documentation-best-practices>
118+
Tools to Build Your Docs <documentation/python-package-documentation-tools>
117119
Host & Help People Find Your Docs <documentation/website-hosting-optimizing-your-docs>
118120
The README File <documentation/readme-file-best-practices.md>
119-
Contributing & License files <documentation/contributing-file>
121+
Contributing & License files <documentation/contributing-license-coc>
120122
```
121123

122124
```{toctree}

0 commit comments

Comments
 (0)