Skip to content

Commit 8f2134e

Browse files
committed
Updated more docs
1 parent 03ffa4d commit 8f2134e

25 files changed

Lines changed: 254 additions & 482 deletions

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/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+
```

docs/how-to/build-docs.rst

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

docs/how-to/dev-install.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Setup Developer Environment
2+
3+
These instructions will take you through the minimal steps required to get a dev environment setup, so you can run the tests locally.
4+
5+
## Clone the repository
6+
7+
First clone the repository locally using [Git](https://git-scm.com/downloads). There is a link on the GitHub interface to allow you to do this. SSH is recommended if you have setup a key. Enter the directory that it is cloned into to continue.
8+
9+
## Install dependencies
10+
11+
You can choose to either develop on the host machine using a `venv` (which requires python 3.8 or later) or to run in a container under [VSCode](https://code.visualstudio.com/)
12+
13+
<!-- https://sphinx-design.readthedocs.io/en/latest/tabs.html# -->
14+
::::{tab-set}
15+
16+
:::{tab-item} Local virtualenv
17+
```
18+
python3 -m venv venv
19+
source venv/bin/activate
20+
pip install -c requirements/constraints.txt -e .[dev]
21+
```
22+
:::
23+
24+
:::{tab-item} VSCode devcontainer
25+
```
26+
code .
27+
# Click on 'Reopen in Container' when prompted
28+
# Open a new terminal
29+
:::
30+
31+
::::
32+
33+
## Build and test
34+
35+
Now you have a development environment you can run the tests in a terminal:
36+
37+
```
38+
tox -p
39+
```
40+
41+
This will run in parallel the following checks:
42+
43+
- [](./build-docs)
44+
- [](./run-tests)
45+
- [](./static-analysis)
46+
- [](./lint)

0 commit comments

Comments
 (0)