Skip to content

Commit bdb4ad5

Browse files
authored
setup mkdocs (#10)
1 parent e7edde1 commit bdb4ad5

File tree

11 files changed

+775
-118
lines changed

11 files changed

+775
-118
lines changed

.github/workflows/docs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
enable-cache: true
29+
30+
- name: Set up Python
31+
run: uv python install 3.12
32+
33+
- name: Install dependencies
34+
run: make install
35+
36+
- name: Build documentation
37+
run: make docs
38+
39+
- name: Setup Pages
40+
uses: actions/configure-pages@v4
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: site
46+
47+
deploy:
48+
environment:
49+
name: github-pages
50+
url: ${{ steps.deployment.outputs.page_url }}
51+
runs-on: ubuntu-latest
52+
needs: build
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: verify fix lint format type-check install test
1+
.PHONY: verify fix lint format type-check install test docs docs-serve
22

33
# Verify - check everything without making changes
44
verify: lint format-check type-check
@@ -23,8 +23,15 @@ type-check:
2323

2424
# Install dependencies
2525
install:
26-
uv sync --group dev
26+
uv sync --all-groups
2727

2828
# Run tests
2929
test:
3030
uv run pytest tests/ -v
31+
32+
# Documentation
33+
docs:
34+
uv run --group docs mkdocs build
35+
36+
docs-serve:
37+
uv run --group docs mkdocs serve

README.md

Lines changed: 3 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Copier-Astral](static/copier-astral.png)
1+
![Copier-Astral](docs/static/copier-astral.png)
22

33
---
44

@@ -40,121 +40,9 @@ copier copy --trust /path/to/copier-astral my-project
4040

4141
> **Note:** The `--trust` flag is required because this template uses custom Jinja2 extensions for features like auto-detecting git user info and generating slugified package names. These extensions are safe to use but Copier warns about them by default.
4242
43-
## Getting Started with Your Generated Project
43+
## Documentation
4444

45-
### 1. Initialize the repository and install dependencies
46-
47-
```bash
48-
cd my-project
49-
git init -b main
50-
make install
51-
```
52-
53-
### 2. Run the pre-commit hooks
54-
55-
If you enabled pre-commit, install the hooks and run them to resolve any initial formatting issues:
56-
57-
```bash
58-
pre-commit install
59-
uv run pre-commit run -a
60-
```
61-
62-
### 3. Verify everything works
63-
64-
```bash
65-
make verify
66-
make test
67-
```
68-
69-
### 4. Create your GitHub repository and push
70-
71-
```bash
72-
git add .
73-
git commit -m "init: generate project from copier-astral"
74-
git remote add origin git@github.com:YOUR_USERNAME/my-project.git
75-
git push -u origin main
76-
```
77-
78-
> **Important:** If you enabled docs during setup, you must manually enable GitHub Pages in your repository. Go to **Settings → Pages → Source** and select **GitHub Actions**. Without this, the docs workflow will fail.
79-
80-
### 5. Set up external services (optional)
81-
82-
- **Codecov**: Add your `CODECOV_TOKEN` as a [repository secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository)
83-
- **PyPI**: Add your `PYPI_TOKEN` as a repository secret. See the [PyPI docs](https://pypi.org/help/#apitoken) for creating a token
84-
85-
## Development Commands
86-
87-
All commands are available via `make`:
88-
89-
| Command | Description |
90-
|---------|-------------|
91-
| `make install` | Install all dependencies |
92-
| `make verify` | Run all checks (lint, format, type-check) |
93-
| `make fix` | Auto-fix lint and format issues |
94-
| `make test` | Run tests |
95-
| `make test-cov` | Run tests with coverage |
96-
| `make test-matrix` | Run tests across all Python versions |
97-
| `make test-matrix-cov` | Run tests with coverage across all versions |
98-
| `make docs` | Build documentation |
99-
| `make docs-serve` | Serve documentation locally |
100-
101-
## Releasing a New Version
102-
103-
1. Create a new version tag:
104-
105-
```bash
106-
git tag v0.1.0
107-
git push --tags
108-
```
109-
110-
2. The `release.yml` workflow will automatically:
111-
- Build the distribution
112-
- Publish to PyPI (if configured)
113-
- Create a GitHub release with changelog
114-
115-
## Generated Project Structure
116-
117-
```
118-
my-project/
119-
├── src/
120-
│ └── my_project/
121-
│ ├── __init__.py
122-
│ ├── py.typed
123-
│ └── cli.py # If CLI enabled
124-
├── tests/
125-
│ ├── __init__.py
126-
│ ├── conftest.py
127-
│ └── test_my_project.py
128-
├── docs/ # If docs enabled
129-
│ ├── index.md
130-
│ ├── api.md
131-
│ └── contributing.md
132-
├── .github/
133-
│ └── workflows/ # If GitHub Actions enabled
134-
│ ├── ci.yml
135-
│ ├── release.yml
136-
│ └── docs.yml
137-
├── Makefile # Development commands
138-
├── pyproject.toml # Single source of truth
139-
├── mkdocs.yml # If docs enabled
140-
├── cliff.toml # Changelog config
141-
├── .pre-commit-config.yaml # If pre-commit enabled
142-
├── Dockerfile # If Docker enabled
143-
├── .dockerignore # If Docker enabled
144-
├── README.md
145-
├── CHANGELOG.md
146-
├── LICENSE
147-
└── .gitignore
148-
```
149-
150-
## Updating Existing Projects
151-
152-
Copier supports updating projects to newer template versions:
153-
154-
```bash
155-
cd my-project
156-
copier update --trust
157-
```
45+
For the full user guide, template options, and contributing instructions, see the [documentation site](https://YOUR_USERNAME.github.io/copier-astral/).
15846

15947
## License
16048

docs/contributing.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributing
2+
3+
## Development Setup
4+
5+
Clone the repository and install dependencies:
6+
7+
```bash
8+
git clone https://github.com/YOUR_USERNAME/copier-astral.git
9+
cd copier-astral
10+
make install
11+
```
12+
13+
## Running Tests
14+
15+
The template includes a test suite that generates a project from the template and verifies it:
16+
17+
```bash
18+
make test
19+
```
20+
21+
To run linting and type checks:
22+
23+
```bash
24+
make verify
25+
```
26+
27+
Auto-fix lint and format issues:
28+
29+
```bash
30+
make fix
31+
```
32+
33+
## Building the Documentation
34+
35+
```bash
36+
make docs-serve
37+
```
38+
39+
This serves the docs locally at `http://127.0.0.1:8000/`.
40+
41+
## Modifying the Template
42+
43+
Template files live in the `template/` directory. Copier uses [Jinja2](https://jinja.palletsprojects.com/) for templating.
44+
45+
Key files:
46+
47+
- `copier.yml` — Template prompts and configuration
48+
- `extensions.py` — Custom Jinja2 extensions (slugify, git config, etc.)
49+
- `template/` — The generated project skeleton
50+
51+
### Conditional files
52+
53+
Files or directories can be conditionally included using Jinja2 expressions in the filename:
54+
55+
```
56+
template/{% if include_docs %}mkdocs.yml{% endif %}.jinja
57+
template/{% if include_docker %}Dockerfile{% endif %}.jinja
58+
```
59+
60+
### Testing your changes
61+
62+
After modifying the template, run the test suite to make sure generated projects are still valid:
63+
64+
```bash
65+
make test
66+
```
67+
68+
You can also generate a test project manually:
69+
70+
```bash
71+
copier copy --trust . /tmp/test-project
72+
cd /tmp/test-project
73+
make install
74+
make verify
75+
make test
76+
```

0 commit comments

Comments
 (0)