Skip to content

Commit d3d332d

Browse files
committed
Rewrite doc and steal astral style
1 parent b4d682e commit d3d332d

File tree

7 files changed

+364
-32
lines changed

7 files changed

+364
-32
lines changed

docs/index.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
11
# Switchbox Copier Template
22

3-
A standalone Copier template with native conditional files/dirs. Supports Python with optional data science tools, package publishing, GitHub Actions, devcontainers, and AWS CLI.
3+
This is a modern [copier](https://copier.readthedocs.io/en/stable/) template you can use to create python and R data science projects, using modern tools, including [devcontainers](https://containers.dev/).
4+
5+
It supports the following features:
6+
7+
### Python data science
8+
- PyData packages: [polars](https://pola.rs/), [seaborn](https://seaborn.pydata.org/)
9+
- [Quarto](https://quarto.org/) notebooks
10+
- [uv](https://docs.astral.sh/uv/) for dependency management
11+
- [ruff](https://docs.astral.sh/ruff/) for code linting and formatting
12+
- [ty](https://docs.astral.sh/ty/) for type checking
13+
14+
### R data science
15+
- Tidyverse packages: [dplyr](https://dplyr.tidyverse.org/), [ggplot2](https://ggplot2.tidyverse.org/), etc.
16+
- [Quarto](https://quarto.org/) notebooks
17+
- [pak](TK) for dependency management
18+
- [air](https://posit-dev.github.io/air/) for code formatting
19+
- [radian](https://github.com/randy3k/radian) for R console
20+
- Fast install of binary packages via [P3M](https://packagemanager.posit.co/__docs__/admin/serving-binaries.html)
21+
22+
### Python packages
23+
- Modern python tooling: uv, ruff, ty, pytest, tox
24+
- [hatchling](https://pypi.org/project/hatchling/) for package building
25+
- [twine][https://twine.readthedocs.io/en/stable/] for package publishing
26+
- MkDocs documentation with Material theme
27+
28+
All project types include:
29+
- [just](https://just.systems/man/en/) for task automation and project management
30+
- [devcontainers](https://containers.dev/) for consistent development environments in VSCode, Cursor, Positron, and other IDEs
31+
- [prek](https://prek.j178.dev/) for fast pre-commit hooks that automate code quality checks
32+
- AWS integration (Optional): ([aws cli](https://aws.amazon.com/cli/), [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) for Python)
33+
- GitHub Actions Workflows (Optional): to run code quality checks and tests via CI/CD
34+
435

536
## Quickstart
637

38+
First, make sure you have copier installed. We recommend doing this with uv or pipx:
39+
740
```bash
8-
pipx install copier
9-
copier copy https://github.com/switchbox-data/switchbox-copier-template my-project
41+
uv tool install copier # or: pipx install copier
1042
```
1143

12-
## Why Copier
44+
On your local machine, navigate to the directory in which you want to create your project, and run the following command:
45+
46+
```bash
47+
copier copy https://github.com/switchbox-data/switchbox-copier-template <my-project>
48+
```
49+
50+
Where `<my-project>` is the name you want to give your project. This will be used as the directory name, and as the name of your repo if you use GitHub.
51+
52+
Follow the prompts to configure your project. Once completed, a new directory containing your project will be created. Then navigate into your newly created project directory and follow the instructions in the `README.md` to complete the setup of your project.
53+
54+
## Acknowledgements
1355

14-
- Native conditional paths; no post-gen cleanup hooks
15-
- Simple upgrades via `copier update`
56+
This project is inspired by the [cookiecutter-uv](https://fpgmaas.github.io/cookiecutter-uv/) package.

docs/options.md

Whitespace-only changes.

docs/promp_arguments.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Prompt Arguments
2+
3+
When running the `copier copy` command, you'll be prompted with several questions to configure your project. Here's what each option does:
4+
5+
---
6+
7+
**author**
8+
9+
Your full name. This will be used in documentation, license files, and package metadata.
10+
11+
**email**
12+
13+
Your email address. Used for package metadata and contact information.
14+
15+
**author_github_handle**
16+
17+
Your GitHub username or organization. This is used to set up repository URLs and documentation links.
18+
19+
**project_description**
20+
21+
A short description of your project. This appears in README files, package metadata, and documentation.
22+
23+
**project_features**
24+
25+
This is a **multiselect** option where you can choose one or more project types:
26+
27+
- `python_data_science`: Sets up a Python data science environment with:
28+
- Polars, PyArrow, Seaborn, NumPy for data analysis
29+
- Quarto notebooks for reproducible research
30+
- Modern Python tooling (uv, ruff, ty)
31+
32+
33+
- `r_data_science`: Sets up an R data science environment with:
34+
- Tidyverse libraries (ggplot2, dplyr, etc.)
35+
- Quarto notebooks
36+
- Modern R tooling (pak, air, radian)
37+
- Fast package installation via P3M
38+
39+
- `python_package`: Creates a Python package with:
40+
- Build tools (hatchling)
41+
- Testing framework (pytest, tox)
42+
- Documentation (MkDocs with Material theme)
43+
- Publishing workflow (PyPI)
44+
45+
You can select multiple features! Here are some common combinations:
46+
47+
*Python data science project*:
48+
```yaml
49+
project_features: ["python_data_science"]
50+
```
51+
52+
*R data science project*:
53+
```yaml
54+
project_features: ["r_data_science"]
55+
```
56+
57+
*Polyglot data science project*:
58+
```yaml
59+
project_features: ["python_data_science", "r_data_science"]
60+
```
61+
62+
*Python package for distribution*:
63+
```yaml
64+
project_features: ["python_package"]
65+
```
66+
67+
*Hybrid python project (data science + package)*:
68+
```yaml
69+
project_features: ["python_data_science", "python_package"]
70+
```
71+
72+
73+
**use_github**
74+
75+
`true` or `false`. When enabled, this adds:
76+
- GitHub Actions workflows for CI/CD
77+
- Issue and pull request templates
78+
- Automated testing and deployment
79+
- Documentation publishing to GitHub Pages
80+
81+
**open_source_license**
82+
83+
Choose a license for your project. Options:
84+
- `MIT license` - Permissive, widely used
85+
- `BSD license` - Similar to MIT, with additional attribution requirements
86+
- `ISC license` - Very permissive, minimal text
87+
- `Apache Software License 2.0` - Includes patent protection
88+
- `GNU General Public License v3` - Copyleft, requires derivative works to be open source
89+
- `Not open source` - No license file generated
90+
91+
**aws**
92+
93+
`true` or `false`. When enabled, includes:
94+
- AWS CLI configuration
95+
- Boto3 for Python projects
96+
- AWS-related development tools and examples
97+
98+
---
99+
100+
## Computed Variables
101+
102+
The template automatically computes several values based on your choices:
103+
104+
**project_name**: Automatically set to the directory name you specify when running copier
105+
106+
**project_slug**: Automatically generated from project_name by converting to lowercase and replacing hyphens with underscores. This is used for:
107+
- Python package names
108+
- Import statements: `from project_slug import module`
109+
- Directory structures
110+

docs/stylesheets/extra.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
:root {
2+
--black: #222022;
3+
--grey: #353038;
4+
--white: #ffffff;
5+
--nebula: #d7ff64;
6+
--flare: #6340ac;
7+
--rock: #78876e;
8+
--galaxy: #261230;
9+
--space: #30173d;
10+
--comet: #6f5d6f;
11+
--cosmic: #de5fe9;
12+
--sun: #ffac2f;
13+
--electron: #46ebe1;
14+
--aurora: #46eb74;
15+
--constellation: #5f6de9;
16+
--neutron: #cff3cf;
17+
--proton: #f6afbc;
18+
--nebula: #cdcbfb;
19+
--supernova: #f1aff6;
20+
--starlight: #f4f4f1;
21+
--lunar: #fbf2fc;
22+
--asteroid: #e3cee3;
23+
--crater: #f0dfdf;
24+
}
25+
26+
[data-md-color-scheme="astral-light"] {
27+
--md-default-bg-color--dark: var(--black);
28+
--md-primary-fg-color: var(--galaxy);
29+
--md-typeset-a-color: var(--flare);
30+
--md-accent-fg-color: var(--cosmic);
31+
}
32+
33+
[data-md-color-scheme="astral-dark"] {
34+
--md-default-bg-color: var(--black);
35+
--md-default-fg-color: var(--white);
36+
--md-default-fg-color--light: var(--white);
37+
--md-default-fg-color--lighter: var(--white);
38+
--md-primary-fg-color: var(--space);
39+
--md-primary-bg-color: var(--white);
40+
--md-accent-fg-color: var(--cosmic);
41+
42+
--md-typeset-color: var(--white);
43+
--md-typeset-a-color: var(--nebula);
44+
--md-typeset-mark-color: var(--sun);
45+
46+
--md-code-fg-color: var(--white);
47+
--md-code-bg-color: var(--grey);
48+
49+
--md-code-hl-comment-color: var(--asteroid);
50+
--md-code-hl-punctuation-color: var(--asteroid);
51+
--md-code-hl-generic-color: var(--supernova);
52+
--md-code-hl-variable-color: var(--starlight);
53+
--md-code-hl-string-color: var(--nebula);
54+
--md-code-hl-keyword-color: var(--supernova);
55+
--md-code-hl-operator-color: var(--supernova);
56+
--md-code-hl-number-color: var(--electron);
57+
--md-code-hl-special-color: var(--electron);
58+
--md-code-hl-function-color: var(--neutron);
59+
--md-code-hl-constant-color: var(--nebula);
60+
--md-code-hl-name-color: var(--md-code-fg-color);
61+
62+
--md-typeset-del-color: hsla(6, 90%, 60%, 0.15);
63+
--md-typeset-ins-color: hsla(150, 90%, 44%, 0.15);
64+
65+
--md-typeset-table-color: hsla(0, 0%, 100%, 0.12);
66+
--md-typeset-table-color--light: hsla(0, 0%, 100%, 0.035);
67+
}

docs/tutorial.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Tutorial
2+
3+
This page contains a complete tutorial on how to create your project.
4+
5+
## Step 1: Install copier
6+
To start, we will need to install `copier`.
7+
8+
We recommend doing so with `uv`. If you don't have `uv`, installation instructions can be found
9+
[here](https://docs.astral.sh/uv/#getting-started). For MacOS or Linux;
10+
11+
```bash
12+
curl -LsSf https://astral.sh/uv/install.sh | sh
13+
```
14+
15+
Then you can use `uv` to install `copier`:
16+
17+
```bash
18+
uv tool install copier
19+
```
20+
21+
Alternatively, once you have `uv` installed, you can use `uvx` to use `copier` without actually installing it:
22+
23+
```bash
24+
uvx copier copy ...
25+
```
26+
## Step 2: Generate your project
27+
28+
On your local machine, navigate to the directory in which you want to
29+
create your project, and run the following command:
30+
31+
```bash
32+
copier copy --trust https://github.com/switchbox-data/data-science-project.git <project-name>
33+
```
34+
35+
For an explanation of the prompt arguments, see
36+
[Prompt Arguments](../prompt_arguments).
37+
38+
Follow the prompts to configure your project. Once completed, a new directory containing your project will be created. A git repo will automatically be created, and the generated files will be committed.
39+
40+
## Step 3: Set up your Github repository
41+
42+
Create an empty [new repository](https://github.com/new) on Github. Give
43+
it a name that matches `<project-name>` above. The name should contain alphanumeric characters and optionally `-`.
44+
45+
DO NOT check any boxes under the option `Initialize this repository
46+
with`.
47+
48+
## Step 4: Upload your project to Github
49+
50+
Run the following commands, replacing `<project-name>` with the name
51+
that you also gave the Github repository and `<github_author_handle>` with the Github username or organization where you made your repo.
52+
53+
```bash
54+
cd <project_name>
55+
git remote add origin [email protected]:<github_author_handle>/<project_name>.git
56+
git push -u origin main
57+
```
58+
59+
### Step 5: Set Up Your Development Environment
60+
61+
Initially, the CI/CD pipeline will fail for two reasons:
62+
63+
- The project does not yet contain a `uv.lock` file
64+
- There are a few formatting issues in the project
65+
66+
To fix that, we first install the environment and the pre-commit hooks with:
67+
68+
```bash
69+
just install
70+
```
71+
72+
This will generate the `uv.lock` file
73+
74+
### Step 6: Run the pre-commit hooks
75+
76+
Now, to resolve the formatting issues, let's run the pre-commit hooks:
77+
78+
```bash
79+
uv run pre-commit run -a
80+
```
81+
82+
### 7. Commit the changes
83+
84+
Now we commit the changes made by the two steps above to the repository:
85+
86+
```bash
87+
git add .
88+
git commit -m 'Fix formatting issues'
89+
git push origin main
90+
```

docs/usage.md

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

0 commit comments

Comments
 (0)