Skip to content

Commit

Permalink
Add pre-commit only for codespell
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Aug 30, 2024
1 parent 3ac5cf0 commit 69feb1c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/nikola.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ jobs:
- name: Check valid checksums
shell: bash
run: python3 check_checksums.py
- name: Look for typos with codespell
shell: bash
run: |
pip install --user codespell[toml]
codespell --ignore-words-list=gameboy,ist,mata,nd,openend,theses --quiet=3 --skip="./archive/*,*.html,*.js"
- name: Build docs
shell: bash
run: |
Expand All @@ -37,3 +32,12 @@ jobs:
# reuse the venv
venv_nikola/bin/python -m pip install ghp-import
venv_nikola/bin/ghp-import -m"Automatic push by ghp-import" -f -p -r origin -b gh-pages --cname=pypy.org public
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Learn more about this config here: https://pre-commit.com/

# To enable these pre-commit hooks run:
# `pipx install pre-commit` or `brew install pre-commit`
# Then in the project root directory run `pre-commit install`

# default_language_version:
# python: python3
repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["--toml=pyproject.toml"]
additional_dependencies:
- tomli
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ all: build

venv_nikola/bin/nikola: ## create a virtualenv to build the website
> @virtualenv -ppython3 ./venv_nikola
> @venv_nikola/bin/python -mpip install nikola==8.2.2 markdown==3.3 jinja2 aiohttp watchdog ruamel.yaml feedparser codespell
> @venv_nikola/bin/python -mpip install nikola==8.2.2 markdown==3.3 jinja2 aiohttp watchdog ruamel.yaml feedparser codespell tomli
> @venv_nikola/bin/nikola plugin -i sidebar
> @venv_nikola/bin/nikola plugin -i localsearch

Expand All @@ -25,7 +25,7 @@ plugins/import_blogger: venv_nikola/bin/nikola

codespell: venv_nikola/bin/nikola ## check and fix typos
# If codespell is not found, rerun `make venv_nikola/bin/nikola`
> venv_nikola/bin/codespell --ignore-words-list=gameboy,ist,mata,nd,openend,theses --quiet=3 --skip="./venv_nikola/*,./archive/*,*.html,*.js,./public" --write-changes
> venv_nikola/bin/codespell --toml=pyproject.toml --write-changes

build: codespell ## build the website if needed, the result is in ./public
> venv_nikola/bin/nikola build
Expand Down Expand Up @@ -60,4 +60,3 @@ help: ## Show this help.
> @echo "\nHelp for building the website, based on nikola"
> @echo "Possible commands are:"
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/ \1: \2/'

2 changes: 1 addition & 1 deletion plugins/static_comments/static_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _scan_comments(self, path, file, owner):
# make sure this is a comment to "file"
if not filename[1:].startswith(post_base + '-comment'):
continue
# There is both a *.mata and a *.html. Send only the base of
# There is both a *.meta and a *.html. Send only the base of
# the *.meta for parsing
parts = filename.rsplit('.', 1)
if parts[1] != 'meta':
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.codespell]
ignore-words-list = "gameboy,ist,nd,openend,theses"
quiet-level = 3
skip = "*.html,*.js,./.*,./archive/*,./venv_nikola,archive/*"

0 comments on commit 69feb1c

Please sign in to comment.