Skip to content

Commit 8870c58

Browse files
authored
Add pre-commit support, and fix end of line and file issues (#120)
1 parent 89ed034 commit 8870c58

File tree

25 files changed

+88
-47
lines changed

25 files changed

+88
-47
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,3 @@ WhitespaceSensitiveMacros:
209209
- PP_STRINGIZE
210210
- STRINGIZE
211211
...
212-

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
working-directory: /tmp/digests
136136
run: |
137137
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
138-
$(printf '${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}@sha256:%s ' *)
138+
$(printf '${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}@sha256:%s ' *)
139139
140140
- name: Inspect image
141141
run: |

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- uses: actions/checkout@v3
3434
with:
3535
submodules: 'true'
36-
36+
3737
- name: Export docs
3838
continue-on-error: false
3939
shell: bash
@@ -43,7 +43,7 @@ jobs:
4343
cd .build
4444
cmake -DDOCS=True ..
4545
cmake --build . --target export_docs
46-
46+
4747
- name: Setup Pages
4848
uses: actions/configure-pages@v4
4949

@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
path: ./.build/docs
5454
name: docs-develop
55-
55+
5656
- name: Deploy to GitHub Pages
5757
id: deployment
5858
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ result
66
.clangd
77
.cache/
88
.devcontainer/
9+
.venv/
910
.vscode/
1011
*.iws
1112
*.swp

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# .pre-commit-config.yaml
2+
# ========================
3+
#
4+
# pre-commit clean
5+
# pre-commit install
6+
# pre-commit install-hooks
7+
#
8+
# precommit hooks installation
9+
#
10+
# - pre-commit autoupdate
11+
#
12+
# - pre-commit run black
13+
#
14+
# continuous integration
15+
# ======================
16+
#
17+
# - pre-commit run --all-files
18+
#
19+
# See https://pre-commit.com for more information
20+
# See https://pre-commit.com/hooks.html for more hooks
21+
repos:
22+
- repo: https://github.com/pre-commit/pre-commit-hooks
23+
rev: v4.5.0
24+
hooks:
25+
- id: end-of-file-fixer
26+
- id: trailing-whitespace
27+
- repo: https://github.com/pre-commit/mirrors-clang-format
28+
rev: v18.1.8
29+
hooks:
30+
- id: clang-format
31+
types_or: [c++, c]

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ The maintainers are unable to guarantee that no significant refactoring will eve
4949
[similar-work]: https://www.doc.ic.ac.uk/~dorchard/publ/haskell14-effects.pdf
5050
[ripple]: https://ripple.com/
5151

52+
## Pre-commit
53+
This repository supports [pre-commit](https://pre-commit.com/) to install git commit hooks which will run checks on the repository (currently just clang-format). Pre-commit will install git commit hooks locally so that they run on each commit. To set up locally you configure a virtual environment, install the requirements and run pre-commit install.
54+
55+
```
56+
# Set up a virtual environment to install pre-commit
57+
python3 -m venv .venv
58+
source ./.venv/bin/activate
59+
pip install pre-commit
60+
# Now install the pre-commit hooks locally
61+
pre-commit install
62+
```
63+
64+
You can run the check manually as follows:
65+
```
66+
# Source the virtual environment to access pre-commit
67+
source ./.venv/bin/activate
68+
# Run pre-commit on local files.
69+
pre-commit run --all-files
70+
```
5271

5372
## License
5473
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flibfn%2Ffunctional.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Flibfn%2Ffunctional?ref=badge_large)

cmake/Docs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ znai_export_docs(
2323
${CMAKE_BINARY_DIR}/docs
2424
COMMENT "Export final documentation"
2525
)
26-
26+
2727
add_dependencies(export_docs docs)

docs/choice.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ title: fn::choice
1212

1313
## Return value {style: "api"}
1414
TODO
15-

docs/choice/and_then.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ A monadic type of the same kind.
2323
## Examples {style: "api"}
2424

2525
:include-template: templates/snippet.md {
26-
path: "examples/simple.cpp",
26+
path: "examples/simple.cpp",
2727
surroundedBy: ["// example-choice-parse", "// example-choice-checks"]
2828
}

docs/choice/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@ Some text explaining this section...
2424
Some text explaining this section...
2525

2626
:include-doxygen-member: fn::choice< Ts... >::value { signatureOnly: false, includeAllMatches: true }
27-
28-

0 commit comments

Comments
 (0)