Skip to content

Commit 34ced3b

Browse files
committed
Fix: Major reorganization following comments from @sneakers-the-rat
1 parent 5e12cba commit 34ced3b

21 files changed

+618
-548
lines changed

ci-and-testing/intro.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CI and Testing
2+
3+
coming soon

conf.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,25 @@
4040
]
4141

4242
# colon fence for card support in md
43-
myst_enable_extensions = ["colon_fence"]
44-
43+
myst_enable_extensions = [
44+
"colon_fence",
45+
"deflist",
46+
]
47+
#myst_heading_anchors = 3
4548

4649
# Link to our repo for easy PR/ editing
4750
html_theme_options = {
48-
"repository_url": "https://github.com/pyopensci/python-package-guide",
49-
"use_repository_button": True,
51+
"source_repository": "https://github.com/pyopensci/python-package-guide",
52+
"source_branch": "main",
53+
"source_directory": ".",
54+
# "repository_url": "https://github.com/pyopensci/python-package-guide",
55+
# "use_repository_button": True,
5056
#"google_analytics_id": "UA-141260825-1",
5157
#"show_toc_level": 1,
5258
#"toc_title": "On this page",
53-
"external_links": [
54-
{"pyOpenSci Website": "link-one-name", "url": "https://www.pyopensci.org"}
55-
],
59+
# "external_links": [
60+
# {"pyOpenSci Website": "link-one-name", "url": "https://www.pyopensci.org"}
61+
# ],
5662
"announcement": "🚧 UNDER CONSTRUCTION: this guide is under heavy construction right now. 🚧"
5763
}
5864

documentation/contributing-license-coc.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

documentation/hosting-tools/intro.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Tools to Build and Host your Documentation
2+
3+
The mmostsot common tool for building documentation in the Python
4+
ecosystem is Sphinx. However, some are using tools like
5+
mkdocs for documentation. In the end it is up to you to
6+
use the platform that you prefer for your documentation!
7+
8+
In this section, we introduce sphinx as a common tool to
9+
build documentation. We also talk about ways to publish your
10+
documentation online and Sphinx tools that might help you optimize
11+
your documentation website.
12+
13+
```{toctree}
14+
:maxdepth: 2
15+
16+
Sphinx Tools <python-package-documentation-tools.md>
17+
Publish Your Docs <publish-documentation-online.md>
18+
Website Hosting and Optimization <website-hosting-optimizing-your-docs.md>
19+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# How to publish your Python package documentation online
2+
3+
We suggest that you setup a hosting service for your Python package
4+
documentation. Two free and commonly used ways to
5+
quickly create a documentation website hosting environment are below.
6+
7+
1. You can host your documentation yourself using [GitHub Pages](https://pages.github.com/) or another online hosting service.
8+
1. You can host your documentation using [Read the Docs](https://readthedocs.org/).
9+
10+
If you don't want to maintain a documentation website for your Python package,
11+
we suggest using the Read the Docs website. Read the Docs allows you to:
12+
13+
* Quickly launch a website using the documentation found in your GitHub repository.
14+
* Track versions of your documentation as you release updates.
15+
* Provides support for Google analytics.
16+
* Allows you to turn on integration with pull requests where you can view documentation build progress (success vs failure).
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Python Package Documentation
2+
3+
<!-- TODO: make this into include files so we can have a summary
4+
important points page -->
5+
6+
```{important}
7+
8+
## Take Aways: Key Python Package Tools to Use
9+
10+
* Use Sphinx to build your documentation
11+
* Publish your documentation on ReadTheDocs (or GitHub pages if you are more advanced and also prefer to maintain your website locally)
12+
* 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. *Both of these tools will run your tutorials from beginning to end providing an addition layer of testing to your package!*
14+
* OPTIONAL: Use [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) to run the examples in your code's docstrings as a way to make sure that your code's functions and methods (the API) are running as you expect them to.
15+
```
16+
17+
In addition to your:
18+
* [README.md file](readme-file-best-practices),
19+
* [CONTRIBUTING.md and development guides and LICENSE file](contributing-license-coc),
20+
21+
you should also have user-facing documentation for your Python
22+
package. Most often, user-facing documentation is contained on a hosted
23+
website.
24+
25+
Below you will learn about the most common tools that
26+
are used to build scientific Python packaging documentation. You will also
27+
learn about hosting options for your documentation.
28+
29+
Here, we focus on tools and infrastructure that you can use.
30+
[Click here if you want to learn more about documentation best practices](package-documentation-best-practices.md).
31+
32+
```{note}
33+
Examples of documentation websites that we love:
34+
35+
* [GeoPandas](https://geopandas.org/en/stable/)
36+
* [View rst to create landing page](https://raw.githubusercontent.com/geopandas/geopandas/main/doc/source/index.rst)
37+
* [verde](https://www.fatiando.org/verde/latest/)
38+
* [View verde landing page code - rst file.](https://github.com/fatiando/verde/blob/main/doc/index.rst)
39+
* [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)
40+
```
41+
42+
43+
## Sphinx, the most common tool used in the scientific Python ecosystem
44+
45+
Most scientific Python packages use [sphinx](https://www.sphinx-doc.org/) to
46+
build their documentation. As such, we will focus on sphinx in this guide.
47+
48+
Sphinx is a [static-site generator](https://www.cloudflare.com/learning/performance/static-site-generator/). A static site generator is a tool that creates
49+
html for a website based upon a set of templates. Sphinx is written
50+
using Python tool which
51+
is why it's commonly used in the Python ecosystem.
52+
53+
```{tip}
54+
There are other static site generator tools that could be used to create user-facing documentation including
55+
[mkdocs](https://www.mkdocs.org/). We won't
56+
discuss others tools in this guide given sphinx is currently the most
57+
popular in the scientific Python ecosystem.
58+
59+
You are welcome to use whatever documentation tool that you prefer for your Python package development!
60+
```
61+
62+
### Sphinx sites can be optimized for documentation with extensions and themes
63+
64+
The functionality of sphinx can be extended using extensions and themes. A few
65+
examples include:
66+
67+
* You can apply documentation themes for quick generation of beautiful documentation.
68+
* You can [automatically create documentation for your package's functions and classes (that package's API) from docstrings in your code using the autodoc extension](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html)
69+
* You can [run and test code examples in your docstrings using the doctest extension](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html)
70+
* While sphinx natively supports the `rST` syntax. You can add custom syntax parsers to support easier-to-write syntax using tools such as [myst](https://myst-parser.readthedocs.io/).
71+
72+
You are free to use whatever sphinx theme that you prefer. However, the most
73+
common sphinx themes that we recommend for the Python scientific
74+
community include:
75+
76+
* [pydata-sphinx-theme](https://pydata-sphinx-theme.readthedocs.io/)
77+
* [sphinx-book-theme](https://sphinx-book-theme.readthedocs.io/)
78+
* [furo](https://pradyunsg.me/furo/quickstart/)
79+
80+
81+
```{tip}
82+
This book is created using sphinx and the `furo` theme.
83+
```
84+
85+
## Documentation syntax: markdown vs. myST vs. rst syntax to create your docs
86+
87+
There are three commonly used syntaxes for creating Python documentation:
88+
1. [markdown](https://www.markdownguide.org/): Markdown is an easy-to-learn text
89+
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,
90+
colored call out blocks and other custom elements to your documentation, you will
91+
need to use either **myST** or **rST**.
92+
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 given the limitations of markdown. However, in recent years myST has risen to the top as a favorite for documentation given the flexibility that it allows.
93+
1. [myST:](https://myst-parser.readthedocs.io/en/latest/intro.html) myST is a combination of vanilla of `markdown` and `rST` syntax. It is a nice option if you are comfortable writing markdown. `myst` is preferred by many because it offers both the rich functionality
94+
of rST combined with a simple-to-write markdown syntax.
95+
96+
While you can chose to use any of the syntaxes listed above, we suggest using
97+
`myST` because:
98+
99+
* It is a simpler syntax and thus easier to learn;
100+
* The above simplicity will make it easier for more people to contribute to your documentation.
101+
* Most of your core python package text files, such as your README.md file, are already in `.md` format
102+
* `GitHub` and `Jupyter Notebooks` support markdown thus it's more widely used in the scientific ecosystem.
103+
104+
105+
```{tip}
106+
If you are on the fence about myST vs rst, you might find that **myST** is easier
107+
for more people to contribute to.
108+
```
109+

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
1-
# Hosting your Python package documentation and optimizing online content
2-
3-
## How to host your Python package documentation
4-
5-
We suggest that you setup a hosting service for your Python package
6-
documentation. Two free and commonly used ways to
7-
quickly create a documentation website hosting environment are below.
8-
9-
1. You can host your documentation yourself using [GitHub Pages](https://pages.github.com/) or another online hosting service.
10-
1. You can host your documentation using [Read the Docs](https://readthedocs.org/).
11-
12-
If you don't want to maintain a documentation website for your Python package,
13-
we suggest using the Read the Docs website. Read the Docs allows you to:
14-
15-
* Quickly launch a website using the documentation found in your GitHub repository.
16-
* Track versions of your documentation as you release updates.
17-
* Provides support for Google analytics.
18-
* Allows you to turn on integration with pull requests where you can view documentation build progress (success vs failure).
19-
20-
21-
22-
## Optimizing your documentation so search engines (and other users) find it
1+
# Optimizing your documentation so search engines (and other users) find it
232

243
If you are interested in more people finding your package, you may want to
254
add some core sphinx extensions (and theme settings) that will help search
265
engines such as Google find your documentation.
276

28-
297
### Google Analytics
308
Some of the [sphinx themes such as the `pydata-sphinx-theme` and
319
sphinx-book-theme have built in support for google analytics](https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/analytics.html#google-analytics). However, if the theme that you chose does not offer

documentation/index.md

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

3+
<!-- ```{toctree}
4+
:hidden:
5+
6+
Best Practices for Docs <package-documentation-best-practices>
7+
Tools to Build Your Docs <python-package-documentation-tools>
8+
Host & Help People Find Your Docs <website-hosting-optimizing-your-docs>
9+
The README File <readme-file-best-practices.md>
10+
Contributing & License files <contributing-license-coc>
11+
``` -->
12+
313
```{important}
414
## Quick Takeaways: Documentation must haves
515

0 commit comments

Comments
 (0)