Skip to content

Commit 6ed3407

Browse files
committed
add pre-commit section to readme
Signed-off-by: Stephen L Arnold <[email protected]>
1 parent 041b0a8 commit 6ed3407

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

README.rst

+53-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Contents after a fresh clone::
4747
│   ├── EU_SUM.rst # source code for the document/template
4848
│   ├── Makefile
4949
│   ├── images # graphics sources for document build
50-
│   │   ├── ACME_Logo.png
51-
│   │   └── ACME_Logo.svg
50+
│   │   ├── acme.png
51+
│   │   └── acme.svg
5252
│   └── styles # old/new format style sheets
5353
│   ├── rst2pdf.style
5454
│   └── sum.yaml
@@ -139,6 +139,57 @@ guidance on submitting pull requests.
139139

140140
.. _CONTRIBUTING: https://github.com/VCTLabs/software_user_manual_template/blob/master/CONTRIBUTING.rst
141141

142+
Pre-commit
143+
----------
144+
145+
This repo is pre-commit_ enabled for python/rst source and file-type
146+
linting. The checks run automatically on commit and will fail the commit
147+
(if not clean) and perform simple file corrections. For example, if the
148+
mypy check fails on commit, you must first fix any fatal errors for the
149+
commit to succeed. That said, pre-commit does nothing if you don't install
150+
it first (both the program itself and the hooks in your local repository
151+
copy).
152+
153+
You will need to install pre-commit before contributing any changes;
154+
installing it using your system's package manager is recommended,
155+
otherwise install with pip into your local user environment using
156+
something like::
157+
158+
$ sudo emerge pre-commit --or--
159+
$ pip install pre-commit
160+
161+
then install the hooks into the repo you just created from the template::
162+
163+
$ cd your_new_sum_repo/
164+
$ pre-commit install
165+
166+
It's usually a good idea to update the hooks to the latest version::
167+
168+
$ pre-commit autoupdate
169+
170+
Most (but not all) of the pre-commit checks will make corrections for you,
171+
however, some will only report errors, so these you will need to correct
172+
manually.
173+
174+
Automatic-fix checks include black, isort, autoflake, and miscellaneous
175+
file fixers. If any of these fail, you can review the changes with
176+
``git diff`` and just add them to your commit and continue.
177+
178+
If any of the mypy or rst source checks fail, you will get a report, but
179+
then you must fix any errors before you can continue adding/committing.
180+
181+
To see a "replay" of any ``rst`` check errors, run::
182+
183+
$ pre-commit run rst-backticks -a
184+
$ pre-commit run rst-directive-colons -a
185+
$ pre-commit run rst-inline-touching-normal -a
186+
187+
To run all ``pre-commit`` checks manually, try::
188+
189+
$ pre-commit run -a
190+
191+
.. _pre-commit: https://pre-commit.com/index.html
192+
142193

143194
License
144195
=======

0 commit comments

Comments
 (0)