Skip to content

Commit b6bf9a3

Browse files
Fix markdown formatting (#61)
* Fix markdown formatting; add markdown pre-commit/CI checks * Update pre-commit hook versions to latest
1 parent 16e1429 commit b6bf9a3

File tree

9 files changed

+105
-30
lines changed

9 files changed

+105
-30
lines changed

{{cookiecutter.repository_name}}/.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Fixes # .
22

3-
## Checklist
3+
# Checklist
44

55
Any checks which are not relevant to the PR can be pre-checked by the PR creator.
66
All others should be checked by the reviewer(s).

{{cookiecutter.repository_name}}/.github/workflows/docs.yml

+17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@ on:
1515

1616

1717
jobs:
18+
docs-lint:
19+
if: github.ref != 'refs/heads/main'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: markdown-link-check
24+
uses: gaurav-nelson/github-action-markdown-link-check@v1
25+
with:
26+
config-file: linkcheck.json
27+
- if: github.event.repository.private
28+
uses: pre-commit/[email protected]
29+
extra_args: markdownlint
30+
- if: github.event.repository.private
31+
uses: pre-commit/[email protected]
32+
extra_args: codespell
33+
1834
docs-test:
35+
needs: [docs-lint]
1936
if: github.ref != 'refs/heads/main'
2037
uses: arup-group/actions-city-modelling-lab/.github/workflows/docs-deploy.yml@main
2138
with:

{{cookiecutter.repository_name}}/.pre-commit-config.yaml

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,37 @@ default_language_version:
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.5.0
6+
rev: v5.0.0
77
hooks:
88
- id: check-added-large-files
99
args: ["--maxkb=1000"]
1010

1111
- repo: https://github.com/astral-sh/ruff-pre-commit # https://beta.ruff.rs/docs/usage/#github-action
12-
rev: v0.6.8
12+
rev: v0.9.2
1313
hooks:
1414
- id: ruff
1515
args: [ --fix, --exit-non-zero-on-fix ]
1616
- id: ruff-format
1717

18+
- repo: https://github.com/markdownlint/markdownlint
19+
rev: v0.12.0
20+
hooks:
21+
- id: markdownlint
22+
name: Markdownlint
23+
description: Run markdownlint on your Markdown files
24+
entry: mdl
25+
language: ruby
26+
files: \.(md|mdown|markdown)$
27+
args: [-r, "~MD013,~MD046"]
28+
29+
- repo: https://github.com/codespell-project/codespell
30+
rev: v2.4.0
31+
hooks:
32+
- id: codespell
33+
# required for config to be managed in pyproject.toml
34+
additional_dependencies:
35+
- tomli
36+
1837
- repo: local
1938
hooks:
2039
# Prevent committing .rej files

{{cookiecutter.repository_name}}/CONTRIBUTING.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You can open an issue on GitHub to report bugs or request new {{ cookiecutter.re
2323
Follow these links to submit your issue:
2424

2525
- [Report bugs or other problems while running {{ cookiecutter.repository_name }}](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/issues/new?template=BUG-REPORT.yml).
26-
If reporting an error, please include a full traceback in your issue.
26+
If reporting an error, please include a full traceback in your issue.
2727

2828
- [Request features that {{ cookiecutter.repository_name }} does not already include](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/issues/new?template=FEATURE-REQUEST.yml).
2929

@@ -46,11 +46,11 @@ To contribute changes:
4646
1. Commit your changes to the feature branch (you should have `pre-commit` installed to ensure your code is correctly formatted when you commit changes).
4747
1. Push the branch to GitHub (`git push origin new-fix-or-feature`).
4848
1. On GitHub, create a new [pull request](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/pull/new/main) from the feature branch.
49-
5049
{%- if cookiecutter.create_author_file == "y" %}
51-
When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!
5250

51+
When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!
5352
{%- endif %}
53+
5454
### Pull requests
5555

5656
Before submitting a pull request, check whether you have:
@@ -65,10 +65,12 @@ When opening a pull request, please provide a clear summary of your changes!
6565

6666
Please try to write clear commit messages. One-line messages are fine for small changes, but bigger changes should look like this:
6767

68-
A brief summary of the commit (max 50 characters)
68+
```text
69+
A brief summary of the commit (max 50 characters)
6970
70-
A paragraph or bullet-point list describing what changed and its impact,
71-
covering as many lines as needed.
71+
A paragraph or bullet-point list describing what changed and its impact,
72+
covering as many lines as needed.
73+
```
7274

7375
### Code conventions
7476

{{cookiecutter.repository_name}}/README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
# {{ cookiecutter.project_title }} ({{ cookiecutter.module_name }})
66

7-
{% if cookiecutter.project_visibility == 'internal' %}<!--- --8<-- [end:docs] -->{% endif -%}
7+
{% if cookiecutter.project_visibility == 'internal' -%}
8+
<!--- --8<-- [end:docs] -->
89

10+
{% endif -%}
911
[![Daily CI Build](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/actions/workflows/daily-scheduled-ci.yml/badge.svg)](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/actions/workflows/daily-scheduled-ci.yml)
1012
[![Documentation](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/actions/workflows/pages/pages-build-deployment/badge.svg?branch=gh-pages)](https://{{ cookiecutter.repository_owner }}.github.io/{{ cookiecutter.repository_name }})
1113

12-
{% if cookiecutter.project_visibility == 'public' %}<!--- --8<-- [end:docs] -->{% endif -%}
14+
{% if cookiecutter.project_visibility == 'public' -%}
15+
<!--- --8<-- [end:docs] -->
1316

17+
{% endif -%}
1418
## Documentation
1519

1620
For more detailed instructions, see our [documentation](https://{{ cookiecutter.repository_owner }}.github.io/{{ cookiecutter.repository_name }}/latest).
@@ -25,10 +29,11 @@ To install {{ cookiecutter.module_name }}
2529
Arup users on Windows can install `miniforge` from the Arup software shop by downloading "VS Code for Python" and then access `conda` from the VSCode integrated terminal.
2630

2731
### As a user
32+
2833
<!--- --8<-- [start:docs-install-user] -->
2934

3035
``` shell
31-
{% if cookiecutter.upload_conda_package == "y" %}
36+
{% if cookiecutter.upload_conda_package == "y" -%}
3237
conda create -n {{ cookiecutter.repository_name }} -c conda-forge -c {{ cookiecutter.conda_channel }} {{ cookiecutter.package_name }}
3338
conda activate {{ cookiecutter.repository_name }}
3439
{% elif cookiecutter.upload_pip_package == "y" %}
@@ -47,18 +52,23 @@ conda activate {{ cookiecutter.repository_name }}
4752
pip install --no-deps -e .
4853
{%- endif %}
4954
```
55+
5056
<!--- --8<-- [end:docs-install-user] -->
5157
5258
### As a developer
59+
5360
<!--- --8<-- [start:docs-install-dev] -->
61+
5462
``` shell
5563
git clone [email protected]:{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}.git
5664
cd {{ cookiecutter.repository_name }}
5765
conda create -n {{ cookiecutter.repository_name }} -c conda-forge --file requirements/base.txt --file requirements/dev.txt
5866
conda activate {{ cookiecutter.repository_name }}
5967
pip install --no-deps -e .
6068
```
69+
6170
<!--- --8<-- [end:docs-install-dev] -->
71+
6272
For more detailed instructions, see our [documentation](https://{{ cookiecutter.repository_owner }}.github.io/{{ cookiecutter.repository_name }}/latest/installation/).
6373
6474
## Contributing
@@ -69,8 +79,8 @@ Before making contributions to the {{ cookiecutter.module_name }} source code, s
6979
If you plan to make changes to the code then please make regular use of the following tools to verify the codebase while you work:
7080
7181
- `pre-commit`: run `pre-commit install` in your command line to load inbuilt checks that will run every time you commit your changes.
72-
The checks are: 1. check no large files have been staged, 2. lint python files for major errors, 3. format python files to conform with the [pep8 standard](https://peps.python.org/pep-0008/).
73-
You can also run these checks yourself at any time to ensure staged changes are clean by simple calling `pre-commit`.
82+
The checks are: 1. check no large files have been staged, 2. lint python files for major errors, 3. format python files to conform with the [pep8 standard](https://peps.python.org/pep-0008/).
83+
You can also run these checks yourself at any time to ensure staged changes are clean by simple calling `pre-commit`.
7484
- `pytest` - run the unit test suite and check test coverage.
7585
- `pytest -p memray -m "high_mem" --no-cov` (not available on Windows) - after installing memray (`conda install memray pytest-memray`), test that memory and time performance does not exceed benchmarks.
7686

{{cookiecutter.repository_name}}/docs/contributing.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To find beginner-friendly existing bugs and feature requests you may like to sta
3131
To create a development environment for {{ cookiecutter.module_name }}, with all libraries required for development and quality assurance installed, it is easiest to install {{ cookiecutter.package_name }} using the [conda](https://docs.conda.io/en/latest/) package manager, as follows:
3232

3333
1. Install conda with the [miniforge](https://github.com/conda-forge/miniforge?tab=readme-ov-file#download) executable for your operating system.
34-
Arup users on Windows can install `miniforge` from the Arup software shop by downloading "VS Code for Python".
34+
Arup users on Windows can install `miniforge` from the Arup software shop by downloading "VS Code for Python".
3535
1. Open the command line (or the VSCode "integrated terminal" in Windows).
3636
1. Download (a.k.a., clone) the {{ cookiecutter.repository_name }} repository: `git clone [email protected]:{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}.git`
3737
1. Change into the `{{ cookiecutter.repository_name }}` directory: `cd {{ cookiecutter.repository_name }}`
@@ -52,11 +52,11 @@ Either way, you should add your environment as a jupyter kernel, so the example
5252
If you plan to make changes to the code then please make regular use of the following tools to verify the codebase while you work:
5353

5454
- `pre-commit`: run `pre-commit install` in your command line to load inbuilt checks that will run every time you commit your changes.
55-
The checks are: 1. check no large files have been staged, 2. lint python files for major errors, 3. format python files to conform with the [PEP8 standard](https://peps.python.org/pep-0008/).
56-
You can also run these checks yourself at any time to ensure staged changes are clean by calling `pre-commit`.
55+
The checks are: 1. check no large files have been staged, 2. lint python files for major errors, 3. format python files to conform with the [PEP8 standard](https://peps.python.org/pep-0008/).
56+
You can also run these checks yourself at any time to ensure staged changes are clean by calling `pre-commit`.
5757
- `pytest` - run the unit test suite and check test coverage.
5858

59-
{%- if cookiecutter.create_jupyter_notebook_directory|lower == "y" %}
59+
{% if cookiecutter.create_jupyter_notebook_directory|lower == "y" -%}
6060
!!! note
6161

6262
If you already have an environment called `{{ cookiecutter.repository_name }}` on your system (e.g., for a stable installation of the package), you will need to [chose a different environment name][choosing-a-different-environment-name].
@@ -67,9 +67,9 @@ You can also run these checks yourself at any time to ensure staged changes are
6767

6868
The following options allow you to strip down the test suite to the bare essentials:
6969

70-
{%- if cookiecutter.create_jupyter_notebook_directory|lower == "y" %}
70+
{% if cookiecutter.create_jupyter_notebook_directory|lower == "y" -%}
7171
1. The test suite includes unit tests and integration tests (in the form of jupyter notebooks found in the `examples` directory).
72-
The integration tests can be slow, so if you want to avoid them during development, you should run `pytest tests/`.
72+
The integration tests can be slow, so if you want to avoid them during development, you should run `pytest tests/`.
7373
{%- endif %}
7474
1. You can avoid generating coverage reports, by adding the `--no-cov` argument: `pytest --no-cov`.
7575

@@ -84,9 +84,9 @@ The integration tests can be slow, so if you want to avoid them during developme
8484
If you are running on a UNIX device (i.e., **not*- on Windows), you can test whether any changes you have made adversely impact memory and time performance as follows:
8585

8686
1. Install [memray](https://bloomberg.github.io/memray/index.html) in your `{{ cookiecutter.repository_name }}` conda environment: `conda install memray pytest-memray`.
87-
2. Run the memory profiling integration test: `pytest -p memray -m "high_mem" --no-cov`.
88-
3. Optionally, to visualise the memory allocation, run `pytest -p memray -m "high_mem" --no-cov --memray-bin-path=[my_path] --memray-bin-prefix=[my_prefix]` - where you must define `[my_path]` and `[my_prefix]` - followed by `memray flamegraph [my_path]/[my_prefix]-tests-test_100_memory_profiling.py-test_mem.bin`.
89-
You will then find the HTML report at `[my_path]/memray-flamegraph-[my_prefix]-tests-test_100_memory_profiling.py-test_mem.html`.
87+
1. Run the memory profiling integration test: `pytest -p memray -m "high_mem" --no-cov`.
88+
1. Optionally, to visualise the memory allocation, run `pytest -p memray -m "high_mem" --no-cov --memray-bin-path=[my_path] --memray-bin-prefix=[my_prefix]` - where you must define `[my_path]` and `[my_prefix]` - followed by `memray flamegraph [my_path]/[my_prefix]-tests-test_100_memory_profiling.py-test_mem.bin`.
89+
You will then find the HTML report at `[my_path]/memray-flamegraph-[my_prefix]-tests-test_100_memory_profiling.py-test_mem.html`.
9090

9191
All together:
9292

@@ -114,8 +114,8 @@ Here are some use-cases that you may come across in which you are considering up
114114

115115
Add a Markdown file to the top-level in `docs`, e.g. `docs/my-page.md`.
116116
Then, add a reference to that file within the `nav` key in `mkdocs.yml`, e.g.:
117-
```yaml
118117

118+
```yaml
119119
nav:
120120
- Home: index.md
121121
- Installation: installation.md
@@ -125,11 +125,14 @@ Here are some use-cases that you may come across in which you are considering up
125125

126126
You can also just rely on your document header to define the name in the navigation:
127127
`my-page.md`
128+
128129
```md
129130
# My Page
130131
...
131132
```
133+
132134
`mkdocs.yml`
135+
133136
```yaml
134137
nav:
135138
...
@@ -195,7 +198,7 @@ It uses [Pa11y](https://pa11y.org/) to test each page, providing a report where
195198
If you find that your documentation has issues, here are some possible ways to resolve them:
196199

197200
- Many issues come from the translation of markdown files to HTML.
198-
If these issues are blockers, you should raise them in the upstream [MkDocs-Material](https://github.com/squidfunk/mkdocs-material/issues) repository.
201+
If these issues are blockers, you should raise them in the upstream [MkDocs-Material](https://github.com/squidfunk/mkdocs-material/issues) repository.
199202
- If issues are not blockers (e.g. an unlabelled hyperlink that is not available to any user, irrespective of their accessibility constraints), then you can add them to the `.pallyci` configuration file [`ignore` list](https://github.com/pa11y/pa11y?tab=readme-ov-file#ignore-array) or [`hideElements` string](https://github.com/pa11y/pa11y?tab=readme-ov-file#hideelements-string).
200203
- If you can solve the issue by updating the documentation configuration (e.g. colour scheme contrast levels, font sizes), then you can test using Pa11y locally before you push online as follows (A local [Node.js installation](https://nodejs.org/en/download/package-manager) is required):
201204

@@ -207,7 +210,7 @@ If these issues are blockers, you should raise them in the upstream [MkDocs-Mate
207210

208211
The results will be printed to the console and will be available as a navigable set of HTML pages at `reports/pa11y/index.html`.
209212
- If you are still unsure what part of the documentation an issue is referring to since it referencing HTML classes/ids etc., rather than Markdown files, then we recommend using the inbuilt accessibility checkers available in most common browsers.
210-
First, serve your documentation locally, then use e.g., the [Mozilla Firefox accessibility inspector](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/) to check for issues.
213+
First, serve your documentation locally, then use e.g., the [Mozilla Firefox accessibility inspector](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/) to check for issues.
211214
{%- endif %}
212215

213216
## Updating the project when the template updates

{{cookiecutter.repository_name}}/docs/installation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Installation
33

4-
## Setting up a user environment
4+
## Installing a user environment
55

66
{% if cookiecutter.project_visibility == "internal" and (cookiecutter.upload_conda_package == "y" or cookiecutter.upload_pip_package == "y") -%}
77
!!! note
@@ -11,7 +11,7 @@
1111
As a `{{ cookiecutter.module_name }}` user, it is easiest to install using the [conda](https://docs.conda.io/en/latest/) package manager, as follows:
1212

1313
1. Install conda with the [miniforge](https://github.com/conda-forge/miniforge?tab=readme-ov-file#download) executable for your operating system.
14-
Arup users on Windows can install `miniforge` from the Arup software shop by downloading "VS Code for Python".
14+
Arup users on Windows can install `miniforge` from the Arup software shop by downloading "VS Code for Python".
1515
1. Open the command line (or the VSCode "integrated terminal" in Windows).
1616
{%- if cookiecutter.upload_conda_package == "y" %}
1717
1. Create the {{ cookiecutter.repository_name }} conda environment: `conda create -n {{ cookiecutter.repository_name }} -c conda-forge -c {{ cookiecutter.conda_channel }} {{ cookiecutter.package_name }}`
@@ -30,7 +30,7 @@ Arup users on Windows can install `miniforge` from the Arup software shop by dow
3030
1. Create the {{ cookiecutter.repository_name }} conda environment: `conda create -n {{ cookiecutter.repository_name }} -c conda-forge -c city-modelling-lab --file requirements/base.txt`
3131
1. Activate the {{ cookiecutter.repository_name }} conda environment: `conda activate {{ cookiecutter.repository_name }}`
3232
1. Install the {{ cookiecutter.package_name }} package into the environment, ignoring dependencies (we have dealt with those when creating the conda environment): `pip install --no-deps .`
33-
{% endif %}
33+
{%- endif %}
3434

3535
All together:
3636

@@ -71,7 +71,7 @@ ipython kernel install --user --name=[my-env-name]
7171
```
7272
{%- endif %}
7373

74-
## Setting up a development environment
74+
## Installing a development environment
7575

7676
The install instructions are slightly different to create a development environment compared to a user environment:
7777

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^https://github.com/arup-group"
5+
},
6+
{
7+
"pattern": "^https://arup.sharepoint.com"
8+
},
9+
{
10+
"pattern": "^https://arup-my.sharepoint.com"
11+
},
12+
{
13+
"pattern": "^https://aws.arup.com"
14+
},
15+
]
16+
17+
}

{{cookiecutter.repository_name}}/pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ convention = "google"
113113
max-doc-length = 200
114114
ignore-overlong-task-comments = true
115115

116+
[tool.codespell]
117+
skip = "tests/*.py,AUTHORS.md"
118+
count = ""
119+
quiet-level = 3
120+
# Uncomment and add words that are false flags as a comma delimited string
121+
# ignore-words-list = ""
122+
116123
[tool.setuptools.packages.find]
117124
include = ["{{ cookiecutter.module_name }}*"]
118125
where = ["src"]

0 commit comments

Comments
 (0)