Skip to content

Commit 07d9093

Browse files
authored
Added contributing guide for template (#31)
2 parents 24504e7 + 8f2134e commit 07d9093

30 files changed

Lines changed: 281 additions & 491 deletions

.github/CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contribute to the template
2+
Contributions and issues are most welcome! All issues and pull requests are handled through [GitHub](https://github.com/DiamondLightSource/python-copier-template/issues). Also, please check for any existing issues before filing a new one. If you have a great idea but it involves big changes, please file a ticket before making a pull request! We want to make sure you don't spend your time coding something that might not fit the scope of the project.
3+
4+
## Issue or Discussion?
5+
6+
Github also offers [discussions](https://github.com/DiamondLightSource/python-copier-template/discussions) as a place to ask questions and share ideas. If your issue is open ended and it is not obvious when it can be "closed", please raise it as a discussion instead.
7+
8+
## Getting changes into the template
9+
10+
This template is a place to pull together agreed best practices from various sources. As such, it is difficult to demonstrate a change without seeing it in action in another repo. Please link to a repo that has the desired behaviour when proposing changes to the template.
11+
12+
## Checking your changes before making a PR
13+
14+
The template has some tests that generating from scratch and updating the [example](https://github.com/DiamondLightSource/python-copier-template-example) produce the same result, but it is difficult to that things like CI and docs are still generated correctly. You can ease this process by:
15+
16+
- Making your changes on a branch of <https://github.com/DiamondLightSource/python-copier-template>
17+
- Running `copier update --vcs-ref=<branch_name>` in the repo where you would like to demonstrate the behaviour
18+
- Linking to that demonstration repo in the PR
19+
20+
## Developer Information
21+
22+
It is recommended that developers use a [vscode devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). This repository contains configuration to set up a containerized development environment that suits its own needs.
23+
24+
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the [How-to guides](https://diamondlightsource.github.io/python-copier-template/main/how-to.html)

.github/CONTRIBUTING.rst

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

docs/explanations/decisions/0003-docs-structure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _documentation structure:
1+
.. _documentation-structure:
22

33
3. Standard documentation structure
44
===================================

docs/explanations/skeleton.rst

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

docs/explanations/structure.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Template Project Structure
2+
3+
The template has the following folders at the root level.
4+
5+
## src
6+
7+
This folder contains the source code for the project. Typically this contains a single folder with the package name for the project and the folder contains python modules files.
8+
9+
See [](src) for details.
10+
11+
## tests
12+
13+
This folder holds all of the tests that will be run by pytest, both locally and in CI.
14+
15+
See [](using-pytest)
16+
17+
## docs
18+
19+
This folder contains the source for sphinx documentation.
20+
21+
See [](documentation-structure) for details.
22+
23+
## .github
24+
25+
Configuration for the Continuous Integration Workflow on github
26+
27+
## VSCode specific folders
28+
29+
### .devcontainer
30+
31+
Configuration for running the developer container for this project in VSCode.
32+
33+
### .vscode
34+
35+
VSCode settings for this project:
36+
37+
- enable static analysis in the editor
38+
- enables python debugging.

docs/explanations/structure.rst

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

docs/explanations/why-use-skeleton.rst

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Why Use a Copier Template?
2+
3+
Many projects start from some kind of template. These define some basic structure, customized with project specific variables, that developers can add their code into. One example of this is [cookiecutter](https://cookiecutter.readthedocs.io).
4+
5+
The problem with this approach is that it is difficult to apply changes to the template into projects that have been cut from it. Individual changes have to be copy/pasted into the code, leading to partially applied fixes and missed updates.
6+
7+
A previous attempt, [python3-pip-skeleton](https://github.com/DiamondLightSource/python3-pip-skeleton), took a different approach, being a repo that can be forked and updates merged into projects tracking it. This was initially encouraging, but led to downstream confusion on who had actually contributed to the repository, as well as messy merges when text that contained the project name (like documentation) was changed upstream.
8+
9+
This template now makes use of [copier](https://copier.readthedocs.io/) which gives the best of both worlds, a templating engine to expand the template, then an update mechanism to apply diffs of the updated template to the project.

docs/how-to.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Practical step-by-step guides for the more experienced user.
66
:maxdepth: 1
77
:glob:
88
9+
how-to/dev-install
910
how-to/*
1011
```

docs/how-to/build-docs.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build the docs using sphinx
2+
3+
You can build the [sphinx](https://www.sphinx-doc.org) based docs from the project directory by running:
4+
5+
```
6+
$ tox -e docs
7+
```
8+
9+
This will build the static docs on the `docs` directory, which includes API docs that pull in docstrings from the code.
10+
11+
:::{seealso}
12+
[](documentation_standards)
13+
:::
14+
15+
The docs will be built into the `build/html` directory, and can be opened locally with a web browse:
16+
17+
```
18+
$ firefox build/html/index.html
19+
```
20+
21+
## Autobuild
22+
23+
You can also run an autobuild process, which will watch your `docs` directory for changes and rebuild whenever it sees changes, reloading any browsers watching the pages:
24+
25+
```
26+
$ tox -e docs autobuild
27+
```
28+
29+
You can view the pages at localhost:
30+
31+
```
32+
$ firefox http://localhost:8000
33+
```
34+
35+
If you are making changes to source code too, you can tell it to watch changes in this directory too:
36+
37+
```
38+
$ tox -e docs autobuild -- --watch src
39+
```

0 commit comments

Comments
 (0)