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/hosting-tools/myst-markdown-rst-doc-syntax.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
There are three commonly used syntaxes for creating Python documentation:
4
4
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,
6
6
colored call out blocks and other custom elements to your documentation, you will
7
7
need to use either **myST** or **rST**.
8
8
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
14
14
15
15
* It is a simpler syntax and thus easier to learn;
16
16
* 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
18
18
*`GitHub` and `Jupyter Notebooks` support markdown thus it's more widely used in the scientific ecosystem.
Copy file name to clipboardExpand all lines: documentation/hosting-tools/website-hosting-optimizing-your-docs.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ engines such as Google find your documentation.
8
8
9
9
```{important}
10
10
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.
12
12
13
13
pyOpenSci is currently looking into free options for open source
14
14
developers.
@@ -35,7 +35,7 @@ more visible to others when they search.
35
35
36
36
This extension is lightweight.
37
37
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).
Copy file name to clipboardExpand all lines: documentation/write-user-documentation/create-package-tutorials.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,10 +35,10 @@ may enjoy using Sphinx gallery. Sphinx gallery uses **.py** files with
35
35
text and code sections that mimic the Jupyter Notebook format. When you build
36
36
your documentation, the gallery extension:
37
37
38
-
1. Runs the code in each tutorial. Running your tutorial this acts as a check to ensure your package functionsand 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.
39
39
1. Creates a downloadable Jupyter Notebook **.ipynb** file and a **.py** script for your tutorial that a user can quickly download and run.
40
40
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.
42
42
43
43
44
44
```{figure} /images/sphinx-gallery-overview.png
@@ -64,26 +64,26 @@ python script (**.py** file) and a Jupyter notebook (**.ipynb** file) at the bot
64
64
```
65
65
66
66
### 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.
68
68
* .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)
71
71
72
72
#### Sphinx gallery challenges
73
73
74
74
The downsides of using Sphinx gallery include:
75
75
76
76
* the **.py** files can be finicky to configure, particularly if you have matplotlib plot outputs.
77
77
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_`
79
79
at the beginning.
80
80
81
81
* Many users these days are used to working in Jupyter Notebooks. .py may be slightly less user friendly to work with
82
82
83
83
These nuances can make it challenging for potential contributors to add
84
84
tutorials to your package. This can also present maintenance challenge.
85
85
86
-
Add about the gallery setup -
86
+
Add about the gallery setup:
87
87
88
88
```bash
89
89
$ docs % make html
@@ -129,7 +129,7 @@ width: 80%
129
129
alt: Image showing the gallery output provided by nbsphinx using the sphinx-gallery front end interface.
130
130
---
131
131
`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
Copy file name to clipboardExpand all lines: documentation/write-user-documentation/document-your-code-api-docstrings.md
+25-22Lines changed: 25 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@
4
4
5
5
API stands for **A**pplied **P**rogramming **I**nterface. When
6
6
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.
8
8
9
9
A simple example of a package API element:
10
10
For instance, a package might have a function called `add_numbers()`
11
11
that adds up a bunch of numbers. To add up numbers, you as the user
12
12
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
13
13
using the package's API.
14
14
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.
16
16
17
17
## What is a docstring and how does it relate to documentation?
18
18
@@ -21,11 +21,11 @@ that describes what the function does and its inputs and outputs. Python program
21
21
22
22
The docstring is thus important for:
23
23
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.
26
26
27
27
```{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.
29
29
* [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)
30
30
* [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)
31
31
```
@@ -166,7 +166,7 @@ doctest adding another quality check to your package.
166
166
<!-- This link isn't working no matter how i create the target. not sure
167
167
why -->
168
168
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.
170
170
Doctest runs the example code in your docstring `Examples` checking
171
171
that the expected output is correct. Similar to running
172
172
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
186
186
`add_me` with the values 1 and 3 it will return 4.
187
187
188
188
```python
189
-
defadd_me(aNum, aNum2):
190
-
"""A function that prints a number that it is provided.
189
+
defadd_me(num1, num2):
190
+
"""A function that sums two numbers.
191
191
192
192
Parameters
193
193
----------
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
196
198
197
199
Returns
198
200
-------
199
-
Prints the integer that you provide the function.
201
+
The integer sum of the provided numbers.
200
202
201
203
Examples
202
204
--------
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.
205
206
206
-
>>> add_me(1+3)
207
+
>>> add_me(1, 3)
207
208
4
208
209
209
210
"""
210
211
211
-
returnaNum+aNum2
212
+
returnnum1+num2
212
213
213
214
214
215
```
@@ -219,13 +220,15 @@ In the example above, you saw the use of numpy-style docstrings to describe data
219
220
that are passed into functions as parameters or
220
221
into classes as attributes. In a numpy-style docstring you add those
221
222
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.
223
224
224
225
```python
225
226
Parameters
226
227
----------
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
229
232
```
230
233
231
234
Describing the expected data type that a function or method requires
@@ -238,16 +241,16 @@ to get to know your code base quickly.
238
241
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).
239
242
240
243
```python
241
-
defadd_me(aNum: int, aNum2: int):
242
-
"""A function that prints a number that it is provided.
244
+
defadd_me(num1: int, num2: int):
245
+
"""A function that sums two numbers.
243
246
```
244
247
245
248
You can further describe the expected function output using `->`. Below
246
249
the output of the function is also an int.
247
250
248
251
```python
249
-
def add_me(aNum: int, aNum2: int) -> int:
250
-
"""A function that prints a number that it is provided.
Copy file name to clipboardExpand all lines: documentation/write-user-documentation/get-started.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,19 @@ Your package:
14
14
## Core components of user-facing Python package documentation
15
15
Below we break documentation into two broad types.
16
16
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)`.
22
22
23
23
Your user-facing documentation for your Python package should include several
24
24
core components.
25
25
26
26
***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
30
30
your Python package. [We discuss code documentation and docstrings in greater detail here.](document-your-code-api-docstrings)
31
31
32
32
### Write usable documentation
@@ -46,13 +46,13 @@ to a broader audience:
46
46
## Four elements of a good open source documentation landing page
47
47
48
48
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
50
50
page to the following elements:
51
51
52
52
***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.
53
53
***About:** Describe your project, stating its goals and its functionality.
54
54
***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.
0 commit comments