Skip to content

Commit 34d85c7

Browse files
ucoderylwasser
authored andcommitted
some user-documentation improvements
1 parent 1460f1d commit 34d85c7

File tree

7 files changed

+49
-46
lines changed

7 files changed

+49
-46
lines changed

documentation/hosting-tools/myst-markdown-rst-doc-syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
There are three commonly used syntaxes for creating Python documentation:
44
1. [markdown](https://www.markdownguide.org/): Markdown is an easy-to-learn text
5-
syntax. It is the default syntax use in Jupyter Notebooks. There are tools that you can add to a Sphinx website that allow it to render markdown as html. However, using markdown to write documentation has limitations. For instance if you want to add references,
5+
syntax. It is the default syntax used in Jupyter Notebooks. There are tools that you can add to a Sphinx website that allow it to render markdown as html. However, using markdown to write documentation has limitations. For instance if you want to add references,
66
colored call out blocks and other custom elements to your documentation, you will
77
need to use either **myST** or **rST**.
88
1. [rST (ReStructured Text):](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html). **rST** is the native syntax that sphinx supports. rST was the default syntax used for documentation for many years. However, in recent years myST has risen to the top as a favorite for documentation given the flexibility that it allows.
@@ -14,7 +14,7 @@ While you can chose to use any of the syntaxes listed above, we suggest using
1414

1515
* It is a simpler syntax and thus easier to learn;
1616
* The above simplicity will make it easier for more people to contribute to your documentation.
17-
* Most of your corePythonpackage text files, such as your README.md file, are already in `.md` format
17+
* Most of your core Python package text files, such as your README.md file, are already in `.md` format
1818
* `GitHub` and `Jupyter Notebooks` support markdown thus it's more widely used in the scientific ecosystem.
1919

2020

documentation/hosting-tools/publish-documentation-online.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ However, you will need to do a bit more work to build and deploy your
3737
documentation if you use GitHub pages.
3838

3939
Read the Docs can be setup in your Read the Docs user account. The service
40-
and automates the entire process of building and deploying your documentation.
40+
automates the entire process of building and deploying your documentation.
4141

4242
If you don't want to maintain a documentation website for your Python package,
4343
we suggest using the Read the Docs website.

documentation/hosting-tools/website-hosting-optimizing-your-docs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ engines such as Google find your documentation.
88

99
```{important}
1010
11-
Google analytics [is not compliant with the European General Data Protection Regulation (GDPR)](https://matomo.org/blog/2022/05/google-analytics-4-gdpr/). While there are many components to this regulation, one of the core elements is that you have to let users know on your site that you are collecting data and they have to consent. WHile it is possible to add infrastructure around Google Analytics to make it close to following GDPR regulations, the community is slowly shifting away from Google using open tools such as [Plausible](https://plausible.io/), [Cloudflare Web Analytics](https://www.cloudflare.com/web-analytics/) and [Matomo](https://matomo.org) for web analytics.
11+
Google analytics [is not compliant with the European General Data Protection Regulation (GDPR)](https://matomo.org/blog/2022/05/google-analytics-4-gdpr/). While there are many components to this regulation, one of the core elements is that you have to let users know on your site that you are collecting data and they have to consent. While it is possible to add infrastructure around Google Analytics to make it close to following GDPR regulations, the community is slowly shifting away from Google using open tools such as [Plausible](https://plausible.io/), [Cloudflare Web Analytics](https://www.cloudflare.com/web-analytics/) and [Matomo](https://matomo.org) for web analytics.
1212
1313
pyOpenSci is currently looking into free options for open source
1414
developers.
@@ -35,7 +35,7 @@ more visible to others when they search.
3535

3636
This extension is lightweight.
3737

38-
It [requires that you to add it to your Sphinx `conf.py` extension list and site your documentation base url.](https://sphinx-sitemap.readthedocs.io/en/latest/getting-started.html).
38+
It [requires that you to add it to your Sphinx `conf.py` extension list and site your documentation base url](https://sphinx-sitemap.readthedocs.io/en/latest/getting-started.html).
3939

4040
### [sphinxext.opengraph](https://github.com/wpilibsuite/sphinxext-opengraph)
4141

documentation/repository-files/readme-file-best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ file.
116116
Include instructions for installing your package. If you have published
117117
the package on both PyPI and Anaconda Cloud be sure to include instructions for both.
118118

119-
### ✔️ Document any addition setup required
119+
### ✔️ Document any additional setup required
120120

121121
Add any additional setup required such as authentication tokens, to
122122
get started using your package. If setup is complex, consider linking to an

documentation/write-user-documentation/create-package-tutorials.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ may enjoy using Sphinx gallery. Sphinx gallery uses **.py** files with
3535
text and code sections that mimic the Jupyter Notebook format. When you build
3636
your documentation, the gallery extension:
3737

38-
1. Runs the code in each tutorial. Running your tutorial this acts as a check to ensure your package functions and classes (ie the API) are working as they should.
38+
1. Runs the code in each tutorial. Running your tutorial like this acts as a check to ensure your package's functions, classes, methods, and attributes (ie the API) are working as they should.
3939
1. Creates a downloadable Jupyter Notebook **.ipynb** file and a **.py** script for your tutorial that a user can quickly download and run.
4040
1. Creates a rendered **.html** page with the code elements and code outputs in a user-friendly tutorial gallery.
41-
1. Creates a gallery landing page with visual thumbnails for each tutorial that you create
41+
1. Creates a gallery landing page with visual thumbnails for each tutorial that you create.
4242

4343

4444
```{figure} /images/sphinx-gallery-overview.png
@@ -64,26 +64,26 @@ python script (**.py** file) and a Jupyter notebook (**.ipynb** file) at the bot
6464
```
6565

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

7272
#### Sphinx gallery challenges
7373

7474
The downsides of using Sphinx gallery include:
7575

7676
* the **.py** files can be finicky to configure, particularly if you have matplotlib plot outputs.
7777

78-
For example: To make allow for plots to render, you need to name each file with `plot_`
78+
For example: To allow for plots to render, you need to name each file with `plot_`
7979
at the beginning.
8080

8181
* Many users these days are used to working in Jupyter Notebooks. .py may be slightly less user friendly to work with
8282

8383
These nuances can make it challenging for potential contributors to add
8484
tutorials to your package. This can also present maintenance challenge.
8585

86-
Add about the gallery setup -
86+
Add about the gallery setup:
8787

8888
```bash
8989
$ docs % make html
@@ -129,7 +129,7 @@ width: 80%
129129
alt: Image showing the gallery output provided by nbsphinx using the sphinx-gallery front end interface.
130130
---
131131
`nbsphinx` can be combined with Sphinx gallery to create a gallery of tutorials.
132-
However, rather render the gallery as a grid, it lists all of the gallery
132+
However, rather than rendering the gallery as a grid, it lists all of the gallery
133133
elements in a single column.
134134
```
135135

documentation/write-user-documentation/document-your-code-api-docstrings.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
API stands for **A**pplied **P**rogramming **I**nterface. When
66
discussed in the context of a (Python) package, the API refers to
7-
the functions, methods and classes that a package maintainer creates for users.
7+
the functions, classes, methods, and attributes that a package maintainer creates for users.
88

99
A simple example of a package API element:
1010
For instance, a package might have a function called `add_numbers()`
1111
that adds up a bunch of numbers. To add up numbers, you as the user
1212
simply call `add_numbers(1,2,3)` and the package function calculates the value and returns `6`. By calling the `add_numbers` function, you are
1313
using the package's API.
1414

15-
Package APIs consist of functions and/or classes, methods and attributes that create a user interface (known as the API).
15+
Package APIs consist of functions, classes, methods and attributes that create a user interface.
1616

1717
## What is a docstring and how does it relate to documentation?
1818

@@ -21,11 +21,11 @@ that describes what the function does and its inputs and outputs. Python program
2121

2222
The docstring is thus important for:
2323

24-
- When you call `help()` in Python, for example, `help(add_numbers)`, the text of the function's docstring is printed. The docstring thus helps a user better understand how to applying the function more effectively to their workflow.
25-
- When you build your package's documentation, the docstrings can be also used to automagically create full API documentation that provides a clean view of all its functions, methods, attributes, and classes.
24+
- When you call `help()` in Python, for example, `help(add_numbers)` will show the text of the function's docstring. The docstring thus helps a user better understand how to applying the function more effectively to their workflow.
25+
- When you build your package's documentation, the docstrings can also be used to automagically create full API documentation that provides a clean view of all its functions, classes, methods, and attributes.
2626

2727
```{tip}
28-
Example API Documentation for all functions, methods, attributes and classes in a package.
28+
Example API Documentation for all functions, classes, methods, and attributes in a package.
2929
* [View example high level API documentation for the Verde package. This page lists every function and class in the package along with a brief explanation of what it does](https://www.fatiando.org/verde/latest/api/index.html)
3030
* [You can further dig down to see what a specific function does within the package by clicking on an API element](https://www.fatiando.org/verde/latest/api/generated/verde.grid_coordinates.html#verde.grid_coordinates)
3131
```
@@ -166,7 +166,7 @@ doctest adding another quality check to your package.
166166
<!-- This link isn't working no matter how i create the target. not sure
167167
why -->
168168

169-
Above, we provided some examples of good, better, best docstring formats. If you are using Sphinx to create your docs, you can add the [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) extension to your Sphinx build. Doctest provides an additional; check for docstrings with example code in them.
169+
Above, we provided some examples of good, better, best docstring formats. If you are using Sphinx to create your docs, you can add the [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) extension to your Sphinx build. Doctest provides an additional check for docstrings with example code in them.
170170
Doctest runs the example code in your docstring `Examples` checking
171171
that the expected output is correct. Similar to running
172172
tutorials in your documentation, `doctest` can be a useful step that
@@ -186,29 +186,30 @@ doctest will run the example below and test that if you provide
186186
`add_me` with the values 1 and 3 it will return 4.
187187

188188
```python
189-
def add_me(aNum, aNum2):
190-
"""A function that prints a number that it is provided.
189+
def add_me(num1, num2):
190+
"""A function that sums two numbers.
191191
192192
Parameters
193193
----------
194-
aNum : int
195-
An integer value to be printed
194+
num1 : int
195+
An integer value to be added
196+
num2 : int
197+
An integer value to be added
196198
197199
Returns
198200
-------
199-
Prints the integer that you provide the function.
201+
The integer sum of the provided numbers.
200202
201203
Examples
202204
--------
203-
Below you can see how the `print_me` function will print a number that
204-
you provide it.
205+
Below you can see how the `add_me` function will return a number.
205206
206-
>>> add_me(1+3)
207+
>>> add_me(1, 3)
207208
4
208209
209210
"""
210211

211-
return aNum + aNum2
212+
return num1 + num2
212213

213214

214215
```
@@ -219,13 +220,15 @@ In the example above, you saw the use of numpy-style docstrings to describe data
219220
that are passed into functions as parameters or
220221
into classes as attributes. In a numpy-style docstring you add those
221222
types in the Parameters section of the docstring. Below you can see that
222-
the parameter `aNum` should be a Python `int` (integer) value.
223+
the parameter `num1` and `num2` should both be a Python `int` (integer) value.
223224

224225
```python
225226
Parameters
226227
----------
227-
aNum : int
228-
An integer value to be printed
228+
num1 : int
229+
An integer value to be added
230+
num2 : int
231+
An integer value to be added
229232
```
230233

231234
Describing the expected data type that a function or method requires
@@ -238,16 +241,16 @@ to get to know your code base quickly.
238241
Type hints are added to the definition of your function. In the example below, the parameters aNum and aNum2 are defined as being type = int (integer).
239242

240243
```python
241-
def add_me(aNum: int, aNum2: int):
242-
"""A function that prints a number that it is provided.
244+
def add_me(num1: int, num2: int):
245+
"""A function that sums two numbers.
243246
```
244247
245248
You can further describe the expected function output using `->`. Below
246249
the output of the function is also an int.
247250
248251
```python
249-
def add_me(aNum: int, aNum2: int) -> int:
250-
"""A function that prints a number that it is provided.
252+
def add_me(num1: int, num2: int) -> int:
253+
"""A function that sums two numbers.
251254
```
252255

253256
### Why use type hints

documentation/write-user-documentation/get-started.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ Your package:
1414
## Core components of user-facing Python package documentation
1515
Below we break documentation into two broad types.
1616

17-
**User-facing documentation **refers to documentation that describes the way the
18-
tools within a package is broadly used in workflows. **API documentation, documentation of your functions, classes and methods in your code,** is written
19-
at a more granular level. It is documentation for each specific function, class,
20-
method or attribute that a user can use in the package. this is the documentation
21-
that a user sees when they type `help(function-name)`.
17+
**User-facing documentation** refers to documentation that describes the way the
18+
tools within a package are broadly used in workflows. **API documentation** refers
19+
to documentation of functions, classes, methods, and attributes in your code and
20+
is written at a more granular level. This documentation is what a user sees when
21+
they type `help(function-name)`.
2222

2323
Your user-facing documentation for your Python package should include several
2424
core components.
2525

2626
* **Documentation Website:** This refers to easy-to-read documentation that helps someone use your package. This documentation should help users both install and use your package.
27-
* **Short Tutorials:** Your user-facing documentation should also include [**short tutorials** that show case core features of your package](create-package-tutorials).
28-
* **Package Code / API documentation:** You package's functions, methods, attributes and classes (the API) should also be documented. API documentation can be generated from [docstrings](https://pandas.pydata.org/docs/development/contributing_docstring.html) found in your
29-
code. Ideally, you have docstrings for all user-facing functions, methods and classes in
27+
* **Short Tutorials:** Your user-facing documentation should also include [**short tutorials** that showcase core features of your package](create-package-tutorials).
28+
* **Package Code / API documentation:** You package's functions, classes, methods, and attributes (the API) should also be documented. API documentation can be generated from [docstrings](https://pandas.pydata.org/docs/development/contributing_docstring.html) found in your
29+
code. Ideally, you have docstrings for all user-facing functions, classes, and methods in
3030
your Python package. [We discuss code documentation and docstrings in greater detail here.](document-your-code-api-docstrings)
3131

3232
### Write usable documentation
@@ -46,13 +46,13 @@ to a broader audience:
4646
## Four elements of a good open source documentation landing page
4747

4848
To make it easy for users to find what they need quickly,
49-
consider adding quick links on your packages landing
49+
consider adding quick links on your package's landing
5050
page to the following elements:
5151

5252
* **Getting started:** This section should provide the user with a quick start for installing your package. A small example of how to use the package is good to have here as well. Or you can link to useful tutorials in the get started section.
5353
* **About:** Describe your project, stating its goals and its functionality.
5454
* **Community:** Instructions for how to help and/or get involved. This might include links to your issues (if that is where you let users ask questions) or the discussion part of your GitHub repo. This section might include a development guide for those who might contribute to your package.
55-
* **API Documentation:** This is the detailed project documentation. Here you store documentation for your package's api including all user-facing functions, methods classes. And any additional high level discussion that will help people use your package.
55+
* **API Documentation:** This is the detailed project documentation. Here you store documentation for your package's API including all user-facing functions, classes, methods, and attributes as well as any additional high level discussion that will help people use your package.
5656

5757

5858
```{figure} /images/geopandas-documentation-landing-page.png

0 commit comments

Comments
 (0)