Skip to content

Commit 13b1ad0

Browse files
martonvagolwjohnst86pre-commit-ci[bot]
authored
docs: 📝 add website files (#115)
# Description This PR updates the website of the non-template project to match what was done in `template-data-package`. This PR needs an in-depth review. ## Checklist - [x] Added or updated tests - [x] Updated documentation - [ ] Ran `just run-all` -- will fail --------- Co-authored-by: Luke W. Johnston <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9411f99 commit 13b1ad0

File tree

11 files changed

+410
-30
lines changed

11 files changed

+410
-30
lines changed

404.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "You’ve entered the garden of missing pages"
3+
---
4+
5+
Let's get you back to greener grounds.
6+
7+
👉 Go to [homepage](/index.qmd).
8+
9+
![](/_extensions/seedcase-project/seedcase-theme/images/404.svg){fig-alt="An illustration of the number 404 surrounded by trees and mountains"}
10+
11+
## Illustration by [Storyset](https://storyset.com/web) {.appendix}

CHANGELOG.md

Whitespace-only changes.

CITATION.cff

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
title: "Template Python Package: An opinionated setup for making Python packages"
2+
abstract: "A template for making a Git repository that follows strongly opinionated practices for building and managing Python packages."
3+
authors:
4+
- family-names: Johnston
5+
given-names: Luke William
6+
orcid: "https://orcid.org/0000-0003-4169-2616"
7+
affiliation: "Steno Diabetes Center Aarhus"
8+
- family-names: Brødbæk
9+
given-names: Signe Kirk
10+
affiliation: "Steno Diabetes Center Aarhus"
11+
orcid: "https://orcid.org/0009-0000-2208-7088"
12+
- family-names: Beicher
13+
given-names: Kristiane
14+
affiliation: "Steno Diabetes Center Aarhus"
15+
orcid: "https://orcid.org/0000-0001-7556-9566"
16+
- family-names: Vago
17+
given-names: Marton
18+
affiliation: "Steno Diabetes Center Aarhus"
19+
cff-version: 1.2.0
20+
# doi:
21+
# date:
22+
keywords:
23+
- "copier template"
24+
- "template"
25+
- "template repository"
26+
- "template project"
27+
- "template python package"
28+
license: MIT
29+
message: "If you use this software, please cite it using these metadata."
30+
repository-code: "https://github.com/seedcase-project/template-python-package"
31+
url: "https://template-python-package.seedcase-project.org"

CONTRIBUTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Contributing
2+
3+
## Issues and bugs :bug:
4+
5+
The easiest way to contribute is to report issues or bugs that you might
6+
find while using `template-python-package`. You can do this by creating a
7+
[new](https://github.com/seedcase-project/template-python-package/issues/new/choose)
8+
issue on our GitHub repository.
9+
10+
## Adding or modifying content :pencil2:
11+
12+
If you would like to contribute content, please check out our
13+
[guidebook](https://guidebook.seedcase-project.org/) for more specific
14+
details on how we work and develop. It is a regularly evolving document,
15+
so is at various states of completion.
16+
17+
To contribute to `template-python-package`, you first need to install
18+
[uv](https://docs.astral.sh/uv/) and
19+
[justfile](https://just.systems/man/en/packages.html). We use uv and
20+
justfile to manage our project, such as to run checks and test the
21+
template. Both the uv and justfile websites have a more detailed guide
22+
on using uv, but below are some simple instructions to get you started.
23+
24+
It's easiest to install uv and justfile using
25+
[pipx](https://pypa.github.io/pipx/), so install that first. Then,
26+
install uv and justfile by running:
27+
28+
``` bash
29+
pipx install uv rust-just
30+
```
31+
32+
We keep all our development workflows in the `justfile`, so you can
33+
explore it to see what commands are available. To see a list of commands
34+
available, run:
35+
36+
``` bash
37+
just
38+
```
39+
40+
As you contribute, make sure your changes will pass our tests by opening
41+
a terminal so that the working directory is the root of this project
42+
(`template-python-package/`) and running:
43+
44+
``` bash
45+
just run-all
46+
```
47+
48+
When testing the template, copier can only use content kept in the Git
49+
history. Meaning that if you make changes to the template and try to
50+
test it, it won't be able to test those changes. You have to commit the
51+
changes first in order for copier to use them.
52+
53+
When committing changes, please try to follow [Conventional
54+
Commits](https://decisions.seedcase-project.org/why-conventional-commits)
55+
as Git messages. Using this convention allows us to be able to
56+
automatically create a release based on the commit message by using
57+
[Commitizen](https://decisions.seedcase-project.org/why-semantic-release-with-commitizen).
58+
If you don't use Conventional Commits when making a commit, we will
59+
revise the pull request title to follow that format, as we use [squash
60+
merges](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/squashing-commits/about-squash-merges)
61+
when merging pull requests, so all other commits in the pull request
62+
will be squashed into one commit.

_metadata.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Metadata for the website
2+
gh:
3+
org: "seedcase-project"
4+
repo: "template-python-package"

_quarto.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
project:
22
type: seedcase-theme
3-
# Delete auto-generated files from `quartodoc`
4-
post-render: rm docs/reference/*.qmd
53
render:
6-
- "docs/*"
4+
# Don't render anything in the template directory.
5+
- "!template/"
6+
- "docs/"
77
- "index.qmd"
8+
- "404.qmd"
9+
- "CONTRIBUTING.md"
810

911
website:
10-
title: "Seedcase NAME"
11-
site-url: "https://NAME.seedcase-project.org/"
12-
repo-url: "https://github.com/seedcase-project/REPO"
12+
title: "Template Python Package"
13+
site-url: "https://template-python-package.seedcase-project.org"
14+
repo-url: "https://github.com/seedcase-project/template-python-package"
1315
page-navigation: true
1416
navbar:
17+
logo: _extensions/seedcase-project/seedcase-theme/logos/seedcase-logo.svg
18+
logo-alt: "Seedcase Project logo: Main page"
1519
pinned: true
16-
title: false
17-
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-seedcase-NAME.svg"
18-
logo-alt: "Seedcase NAME logo: Main page"
1920
left:
21+
- text: "Overview"
22+
menu:
23+
- text: "Welcome"
24+
href: index.qmd
25+
- text: "Releases"
26+
href: docs/releases.qmd
27+
- text: "Contributing"
28+
href: CONTRIBUTING.md
2029
- text: "Guide"
21-
href: docs/guide/index.qmd
22-
- text: "Design"
23-
href: docs/design/index.qmd
30+
href: docs/guide.qmd
2431
tools:
2532
- icon: github
26-
href: "https://github.com/seedcase-project/REPO"
33+
href: "https://github.com/seedcase-project/template-python-package"
2734
aria-label: "GitHub icon: Source code"
2835
- icon: house
2936
href: https://seedcase-project.org
3037
aria-label: "House icon: Seedcase Project home page"
31-
sidebar:
32-
- id: design
33-
pinned: true
34-
style: "floating"
35-
contents:
36-
- text: "Design"
37-
href: docs/design/index.qmd
38-
- id: guide
39-
contents:
40-
- section: "Guide"
41-
href: docs/guide/index.qmd
4238

43-
# format:
44-
# seedcase-theme-html:
45-
# include-before-body:
46-
# - "includes/site-counter.html"
39+
format:
40+
seedcase-theme-html:
41+
theme:
42+
- brand
43+
include-before-body:
44+
- "docs/includes/site-counter.html"
4745

4846
editor:
4947
markdown:
5048
wrap: 72
5149
canonical: true
50+
51+
execute:
52+
echo: false

docs/guide.qmd

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
title: "Guide"
3+
---
4+
5+
This guide gives an overview of how to use this template for creating a
6+
new Python package. It includes instructions for using the template and
7+
post-creation tasks.
8+
9+
## Installing
10+
11+
In order to use this template, you need to install a few programs:
12+
13+
- [Python](https://www.python.org/): Required by the template tool
14+
itself (copier) and for installing and using many of the tools in
15+
this template.
16+
- [Git](https://git-scm.com/): For version control and setting up Git
17+
to track the newly created package.
18+
- [copier](https://copier.readthedocs.io/en/stable/#quick-start): A
19+
template tool for making new projects in a standardised and
20+
structured way.
21+
- [uv](https://docs.astral.sh/uv/): A tool for managing Python
22+
environments and running commands. Some post-copy steps of this
23+
template use uv.
24+
- [just](https://just.systems/man/en/): A build management tool that
25+
helps with running common build and check tasks.
26+
27+
You will need to install Python and Git yourself, but the other tools
28+
can be installed using
29+
[`pipx`](https://pipxproject.github.io/pipx/)---which we strongly
30+
recommend---with the following command:
31+
32+
``` bash
33+
pipx install copier uv rust-just
34+
```
35+
36+
## Creating a new Python package
37+
38+
You can use this template to create a new Python package with a standard
39+
set of files and folders, as well as all the features and configurations
40+
to make it easier to build your package more smoothly and effectively.
41+
First, open a Terminal and move into the directory where you want to
42+
create the new Python package. Then run the following command:
43+
44+
``` bash
45+
# Copy into the current directory, which is the "."
46+
uvx copier copy --trust gh:seedcase-project/template-python-package .
47+
```
48+
49+
::: callout-caution
50+
This template runs some post-copy commands using your terminal. In order
51+
to run them, you need to use the `--trust` option. Review the
52+
[`copier.yml`](https://github.com/seedcase-project/template-python-package/blob/main/copier.yaml)
53+
file, under the `_tasks` key to see what commands will be run after
54+
copying the template, so you can know and trust what the commands are
55+
doing. Unfortunately, this template can't be used without the `--trust`
56+
option.
57+
:::
58+
59+
## Applying the template to an existing Python package
60+
61+
If you want to use this template on an existing Python package, you can
62+
use the `copy` command of `copier` just like above to apply the template
63+
to the existing package. This will add all the template's files and
64+
configurations to the existing package.
65+
66+
``` bash
67+
uvx copier copy --trust gh:seedcase-project/template-python-package .
68+
```
69+
70+
It will go through a series of prompts, as in the case of creating a new
71+
Python package, including asking if you want to overwrite existing
72+
files.
73+
74+
::: callout-note
75+
To use the `copy` command, the Python package needs to be tracked by Git
76+
and in a clean state (no changes).
77+
:::
78+
79+
## Applying the latest template changes
80+
81+
There are two ways to update an existing Python package with the latest
82+
changes from the template: `update` and `recopy`.
83+
84+
Use `update` to apply template updates to your project without
85+
overwriting local changes. `update` will compare the version of the
86+
template you used when you first copied the template with the current
87+
version of the template, and then apply the changes that are different.
88+
This also means it won't overwrite any changes you made to files in your
89+
current Python package, for example, if you deleted a file that was in
90+
the template, it won't be copied back.
91+
92+
Use `recopy` if you want to reapply the template from scratch, which
93+
will overwrite any changes you made to the files that were copied from
94+
the template. This is useful if you want to reset the Python package to
95+
the state of the template. For example, if you deleted a file but want
96+
it back from the template or are simply curious to see if there are any
97+
new changes that you might want to use.
98+
99+
In both cases, the commands are very similar and also use many of the
100+
same options as the `copy` command. If you want to use the same answers
101+
as given when you first copied the template, you can use the
102+
`--defaults` option. Then it will only prompt you for the questions that
103+
have changed since the last time you copied the template.
104+
105+
``` bash
106+
uvx copier update --trust --defaults
107+
# Or
108+
uvx copier recopy --trust --defaults
109+
```
110+
111+
As with the `copy` command, the Python package needs to be tracked by
112+
Git and must be in a clean state (no changes) for the `update` and
113+
`recopy` commands to work.
114+
115+
## Post-creation setup
116+
117+
These steps are mainly for us in the Seedcase Project to set up the
118+
repository with the settings we use, but you can follow them if you want
119+
to set up your Python package in a similar way. They are also included
120+
in a message after you've copied the template.
121+
122+
After copying the template, while in the directory of the new Python
123+
package, run the following:
124+
125+
``` bash
126+
just install-precommit
127+
```
128+
129+
This sets up the pre-commit hooks to run standard checks on your
130+
repository whenever you commit files to the history.
131+
132+
If you are using the template to create a Python package for the Seedcase
133+
Project, run:
134+
135+
``` bash
136+
just update-quarto-theme
137+
```
138+
139+
This adds the `seedcase-theme` Quarto theme to the website, which
140+
provides a consistent look and feel across all Seedcase Project
141+
websites, including for Python package websites.
142+
It's called `update-quarto-theme` here since you can use this
143+
command to keep the theme updated.
144+
145+
Next, install [`spaid`](https://github.com/seedcase-project/spaid) and
146+
use the following commands to run the next setup steps:
147+
148+
``` bash
149+
spaid_gh_create_repo_from_local -h
150+
spaid_gh_set_repo_settings -h
151+
spaid_gh_ruleset_basic_protect_main -h
152+
```
153+
154+
Some configuration is needed after copying this template to a new
155+
repository, including configuration external to the repository. Some
156+
GitHub workflows require installing GitHub Apps, for greater security
157+
purposes and easier administration when managing multiple repositories.
158+
The [security
159+
section](https://guidebook.seedcase-project.org/operations/security#using-github-apps-to-generate-tokens)
160+
in our [Guidebook](https://guidebook.seedcase-project.org/) provides
161+
instructions on how to set up GitHub Apps, secrets, and variables.
162+
Ideally the secrets and variables should be set up in the organization
163+
settings. The specific workflows in this template that require this
164+
additional setup are:
165+
166+
- The workflow `.github/workflows/release-package.yml` requires the
167+
[auto-release-token](https://github.com/apps/auto-release-token)
168+
GitHub App as well as a creating a GitHub secret called
169+
`UPDATE_VERSION_TOKEN` and a variable called `UPDATE_VERSION_APP_ID`
170+
that has the App ID.
171+
- The workflow `.github/workflows/add-to-project.yml` requires the
172+
[add-to-board-token](https://github.com/apps/add-to-board-token)
173+
GitHub App, along with the `ADD_TO_BOARD_TOKEN` secret and the
174+
`ADD_TO_BOARD_APP_ID` variable of the GitHub App's ID.
175+
176+
If you use Netlify, you will also need to add a `NETLIFY_AUTH_TOKEN` secret
177+
of your Netlify Token.

docs/includes/_badges.qmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- [![DOI]()]() -->
2+
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-teal.json?raw=true)](https://github.com/copier-org/copier)
3+
[![GitHub License](https://img.shields.io/github/license/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/blob/main/LICENSE.md)
4+
[![GitHub Release](https://img.shields.io/github/v/release/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/releases/latest)
5+
[![Build website](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml/badge.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml)
6+
[![CodeQL](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/github-code-scanning/codeql)
7+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/{{< meta gh.org >}}/{{< meta gh.repo >}}/main.svg)](https://results.pre-commit.ci/latest/github/{{< meta gh.org >}}/{{< meta gh.repo >}}/main)
8+
[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
9+
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)

docs/includes/site-counter.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- TODO: Set up GoatCounter -->
2+
<script data-goatcounter="https://seedcase-template-python-package.goatcounter.com/count" async
3+
src="//gc.zgo.at/count.js"></script>

0 commit comments

Comments
 (0)