Skip to content

Commit 1587d0e

Browse files
authored
Fix: pin to pydata_sphinx & fix package cards 14.4
Fix: a few fixes to support the new theme and also updated cards also updates some of the deprecated items in the theme.
2 parents d2867e6 + db095ab commit 1587d0e

File tree

7 files changed

+94
-100
lines changed

7 files changed

+94
-100
lines changed

conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"sphinx.ext.todo",
3838
"sphinx_sitemap",
3939
"sphinxext.opengraph",
40+
"sphinx_favicon",
4041
]
4142

4243
# colon fence for card support in md
@@ -46,16 +47,14 @@
4647
]
4748
myst_heading_anchors = 3
4849

50+
# Sphinx_favicon is used now in favor of built in support
51+
# https://pypi.org/project/sphinx-favicon/
52+
favicons = [
53+
{"href": "https://www.pyopensci.org/images/favicon.ico"},
54+
]
4955

5056
# Link to our repo for easy PR/ editing
5157
html_theme_options = {
52-
"favicons": [
53-
{
54-
"rel": "icon",
55-
"sizes": "16x16",
56-
"href": "https://www.pyopensci.org/images/favicon.ico",
57-
},
58-
],
5958
"announcement": "<p><a href='https://www.pyopensci.org/about-peer-review/index.html'>We run peer review of scientific Python software. Learn more.</a></p>",
6059
#"navbar_center": ["nav"], this can be a way to override the default navigation structure
6160
"external_links": [
@@ -93,7 +92,8 @@
9392
# "navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
9493
"github_url": "https://github.com/pyopensci/python-package-guide",
9594

96-
"footer_items": ["copyright"],
95+
"footer_start": ["copyright"],
96+
"footer_end": [],
9797
}
9898

9999
html_context = {

documentation/index.md

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

3-
```{toctree}
3+
:::{toctree}
44
:hidden:
55
:caption: Intro
66

77
Documentation Overview <self>
8-
```
8+
:::
99

1010
```{toctree}
1111
:hidden:
@@ -24,9 +24,7 @@ Create Package Tutorials <write-user-documentation/create-package-tutorials.md>
2424
:maxdepth: 2
2525
2626
Intro <repository-files/intro.md>
27-
2827
Contributing File <repository-files/contributing-file.md>
29-
3028
Development Guide <repository-files/development-guide.md>
3129
```
3230

@@ -63,32 +61,6 @@ requirements. Our requirements are focused on the
6361
documentation content of your package.
6462
```
6563

66-
<!-- ```{toctree}
67-
:hidden:
68-
69-
Best Practices for Docs <package-documentation-best-practices>
70-
Tools to Build Your Docs <python-package-documentation-tools>
71-
Host & Help People Find Your Docs <website-hosting-optimizing-your-docs>
72-
The README File <readme-file-best-practices.md>
73-
Contributing & License files <contributing-license-coc>
74-
``` -->
75-
<!--
76-
```{important}
77-
## Quick Takeaways: Documentation must haves
78-
79-
Your package should at a minimum have:
80-
* README.MD file
81-
* CONTRIBUTING.md file
82-
* CODE_OF_CONDUCT.md
83-
* LICENSE.txt
84-
* User-facing documentation website with tutorials
85-
* API documentation (often found in the user-facing documentation website)
86-
87-
The pages in this section of our guide provide you with more
88-
detail about creating each of the above elements. We also suggest
89-
tools that will help you build your documentation.
90-
``` -->
91-
9264
## Documentation is critical for your Python package's success
9365

9466
Documentation is as important to the success of your Python open source package
@@ -154,25 +126,13 @@ found in our peer review check list (see link below).
154126
In this guide, we discuss each required element, and also discuss other elements
155127
that you should consider in your package's documentation in more detail.
156128

157-
<!-- TODO: EIC checks are missing: code of conduct -->
158129

159130
```{button-link} https://www.pyopensci.org/software-peer-review/how-to/editor-in-chief-guide.html#editor-checklist-template
160131
:color: primary
161132
:class: sd-rounded-pill float-left
162133
View pyOpenSci peer review check list
163134
```
164135

165-
<!--
166-
1. Individual files in your GitHub (or GitLab) repository including:
167-
* [A clear and to the point **README.md** file](readme-file-best-practices) that includes information about how to cite your package.
168-
* 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.
169-
* 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.
170-
* [**A LICENSE.txt file**](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.
171-
* We also suggest (but don't require) that you include a development guide that details the infrastructure used in your package. Sometimes this file is included in the user-facing documentation website (discussed below).
172-
1. [**User focused package documentation**](package-documentation-best-practices) that helps users understand how to install, setup and use your package. Documentation is most often contained in a stand-alone website. The user-focused documentation should include:
173-
* **Tutorials and quick start code examples** that help a user get started using your package.
174-
* **Documentation for user-facing functions, objects and methods in your package (the API).** 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.
175-
-->
176136

177137
```{figure} ../images/moving-pandas-python-package-github-main-repo.png
178138
---
@@ -190,18 +150,11 @@ you through best practices for setting up
190150
documentation for your Python package. We will also suggest
191151
tools that you can use to build your user-facing documentation website.
192152

193-
<!--
194-
Commenting this out for now - it will be moved to another section
153+
:::{todo}
195154

196-
## Other recommendations
197-
### Python version support
155+
Python version support
198156
You should always be explicit about which versions of Python your package supports.
199157
Keeping compatibility with old Python versions can be difficult as functionality changes.
200158
A good rule of thumb is that the package should support, at least,
201159
the latest three Python versions (e.g., 3.8, 3.7, 3.6).
202-
203-
### Code Style
204-
pyOpenSci encourages authors to consult [PEP 8](https://www.python.org/dev/peps/pep-0008/) for information on how to style your code.
205-
206-
### Linting
207-
An automatic linter (e.g. flake8) can help ensure your code is clean and free of syntax errors. These can be integrated with your CI. -->
160+
:::

index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ process. To ensure our guidebook is both beginner-friendly and accurate, we enco
167167
```{button-link} https://github.com/pyOpenSci/python-package-guide#contributors-
168168
:color: primary
169169
:class: sd-rounded-pill float-left
170+
170171
View guidebook contributors
171172
172173
```
@@ -217,7 +218,5 @@ Packaging <package-structure-code/intro>
217218
:caption: Testing
218219
219220
Tests <tests/index>
220-
Write tests <tests/write-tests>
221-
Types of tests <tests/test-types>
222221
223222
```

package-structure-code/intro.md

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,87 @@ there are some great modern packaging tools that ensure that you're following
99
best practices. Here, we review tool features and suggest tools that might be
1010
best fitted for your workflow.
1111

12-
::::{grid} 1 1 2 2
12+
:::::{grid} 1 1 2 2
1313
:class-container: text-center
1414
:gutter: 3
1515

16-
:::{grid-item-card}
16+
::::{grid-item}
17+
:::{card} ✨ 1. Package file structure ✨
1718
:link: python-package-structure
1819
:link-type: doc
1920

20-
✨ 1. Package file structure ✨
21-
^^^
2221
src layout, flat layout and where should tests folders live? No matter what your level of packaging knowledge is, this page will help you decide upon a package structure that follows modern python best practices.
2322
:::
23+
::::
2424

25-
:::{grid-item-card}
25+
::::{grid-item}
26+
:::{card} ✨ 2. Learn about building your package ✨
2627
:link: python-package-structure
2728
:link-type: doc
2829

29-
✨ 2. Learn about building your package ✨
30-
^^^
31-
Publishing a Python package is a great way to share your code with scientists to support open science workflow. In order to publish a package, you will need to first build it. The act of "building" refers to the process of placing your package code and
32-
metadata into a format that can be published on PyPI. Once published on PyPI, your users can easily install it locally using pip. Learn more about building a Python package here.
30+
To publish your Python package on PyPI, you will need to first build it. The act
31+
of "building" refers to the process of placing your package code and
32+
metadata into a format that can be published on PyPI. Learn more about building
33+
your Python package.
3334
:::
35+
::::
3436

35-
:::{grid-item-card}
36-
:link: python-package-build-tools
37+
38+
::::{grid-item}
39+
:::{card} ✨ 4. Add metadata ✨
40+
:link: pyproject-toml-python-package-metadata
3741
:link-type: doc
3842

39-
✨ 3. What Python package tool should you use? ✨
40-
^^^
43+
Learn how to add project metadata to your Python package to support both
44+
filtering on PyPI and also the metadata that a package installer needs to
45+
build and install your package.
46+
:::
47+
::::
48+
49+
::::{grid-item}
50+
:::{card} ✨ 3. What Python package tool should you use? ✨
51+
:link: python-package-build-tools
52+
:link-type: doc
4153

4254
Learn more about the suite of packaging tools out there.
4355
And learn which tool might be best for you.
4456
:::
57+
::::
4558

46-
:::{grid-item-card}
59+
::::{grid-item}
60+
:::{card} ✨ 4. Publish to PyPI and Conda ✨
4761
:link: python-package-build-tools
4862
:link-type: doc
4963

50-
✨ 4. Publish your package to PyPI and Conda ✨
51-
^^^
52-
If you have a pure python package, it's a straight forward
64+
If you have a pure Python package, it's a straight forward
5365
process to publish to both PyPI and then a Conda channel such as
5466
conda-forge. Learn more here.
5567
:::
68+
::::
5669

57-
:::{grid-item-card}
70+
::::{grid-item}
71+
:::{card} ✨ 5. Setup package versioning ✨
5872
:link: python-package-versions
5973
:link-type: doc
6074

61-
✨ 5. Setup package versioning ✨
62-
^^^
6375
Semver (numeric versioning) and Calver (versioning using the date) are 2
6476
common ways to version a package. Which one should you pick? Learn more here.
6577
:::
78+
::::
6679

67-
:::{grid-item-card}
80+
::::{grid-item}
81+
:::{card} ✨ 6. Code style & linters ✨
6882
:link: code-style-linting-format
6983
:link-type: doc
7084

71-
✨ 6. Code style & linters ✨
72-
^^^
7385
Black, blue, flake8, Ruff - which tools can help you ensure your
74-
package follows best practices for code format? Learn more about the options and why this is important here.
86+
package follows best practices for code format? Learn more about the options
87+
and why this is important here.
7588
:::
7689
::::
7790

91+
:::::
92+
7893
:::{figure-md} packaging-tools-decision-tree
7994

8095
<img src="../images/python-package-tools-decision-tree.png" alt="Figure showing a decision tree with the various packaging tool front-end and back-end options." width="700px">
@@ -83,13 +98,13 @@ Diagram showing the various front-end build tools that you can select from.
8398
See the packaging tools page to learn more about each tool.
8499
:::
85100

86-
```{note}
101+
:::{note}
87102
If you are considering submitting a package for peer review, have a look
88103
at the bare-minimum [editor checks](https://www.pyopensci.org/software-peer-review/how-to/editor-in-chief-guide.html#editor-checklist-template)
89104
that pyOpenSci performs before a review begins. These checks are useful
90105
to explore for both authors planning to submit a package to us for review
91106
and for anyone who is just getting started with creating a Python package.
92-
```
107+
:::
93108

94109
## What you will learn here
95110

@@ -111,8 +126,6 @@ In this section of our Python packaging guide, we:
111126

112127
## Guidelines for pyOpenSci's packaging recommendations
113128

114-
<!-- Might belong on the LANDING page for this entire guide?-->
115-
116129
The flexibility of the Python programming language lends itself to a diverse
117130
range of tool options for creating a Python package. Python is so flexible that
118131
it is one of the few languages that can be used to wrap around other languages.
@@ -135,7 +148,7 @@ Python package. In this guide, we suggest packaging approaches and tools based o
135148
Here, we also try to align our suggestions with the most current, accepted
136149
[Python community](https://packaging.python.org/en/latest/) and [scientific community](https://scientific-python.org/specs/).
137150

138-
```{admonition} Suggestions in this guide are not pyOpenSci review requirements
151+
:::{admonition} Suggestions in this guide are not pyOpenSci review requirements
139152
:class: important
140153

141154
The suggestions for package layout in this section are made with the
@@ -145,9 +158,9 @@ package to be reviewed and accepted into our pyOpenSci open source ecosystem.
145158
Please check out our [package scope page](https://www.pyopensci.org/software-peer-review/about/package-scope.html)
146159
and [review requirements in our author guide](https://www.pyopensci.org/software-peer-review/how-to/author-guide.html#)
147160
if you are looking for pyOpenSci's Python package review requirements!
148-
```
161+
:::
149162

150-
```{toctree}
163+
:::{toctree}
151164
:hidden:
152165
:caption: Package structure & code style
153166

@@ -159,14 +172,14 @@ Build Your Package <python-package-distribution-files-sdist-wheel>
159172
Declare dependencies <declare-dependencies>
160173
Package Build Tools <python-package-build-tools>
161174
Complex Builds <complex-python-package-builds>
162-
```
175+
:::
163176

164-
```{toctree}
177+
:::{toctree}
165178
:hidden:
166179
:caption: Publishing a package
167180

168181
Publish with Conda / PyPI <publish-python-package-pypi-conda>
169182
Package versions <python-package-versions>
170183
Code style <code-style-linting-format>
171184

172-
```
185+
:::

package-structure-code/pyproject-toml-python-package-metadata.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ what's missing
1919
5. There is no specific order for tables in the `pyproject.toml` file. However fields need to be placed within the correct table sections. For example `requires =` always need to be associated with the **[build-system]** table.
2020
6. **python-requires**: is important to have in your `pyproject.toml` file as it helps pip install your package.
2121

22-
<!-- Commenting this out given the lessons aren't online yet
23-
we can add this back once tutorials are published
2422
:::
2523

24+
25+
:::::{todo}
26+
27+
when these are published, remove this todo
28+
2629
::::{grid} 2
2730

2831
:::{grid-item}
@@ -51,7 +54,8 @@ Click here if need help migrating from setup.py/setup.cfg to pyproject.toml
5154
```
5255

5356
:::
54-
:::: -->
57+
::::
58+
:::::
5559

5660
## About the pyproject.toml file
5761

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
[project]
2+
name = "python-package-guide"
3+
4+
[project.optional.dependencies]
5+
dev = [
6+
"pydata-sphinx-theme==0.15.1",
7+
"myst-nb",
8+
"sphinx",
9+
"sphinx-autobuild",
10+
"sphinx-copybutton",
11+
"sphinx-design",
12+
"sphinx-favicon",
13+
# XML feed for analytics
14+
"sphinx-sitemap",
15+
# Support for social / adds meta tags
16+
"sphinxext-opengraph",
17+
"sphinx-inline-tabs",
18+
# for project cards
19+
"matplotlib"
20+
]
21+
22+
123
# https://github.com/codespell-project/codespell#usage
224
[tool.codespell]
325
ignore-words = "codespell-ignore.txt"

0 commit comments

Comments
 (0)