Skip to content

Documentation: Implement automatic spelling check #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_build/
wordlist.dic
101 changes: 95 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,108 @@ SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
SPELLING_CONFIG = spellingcheck.yaml

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo ""
@echo "Additional spelling targets:"
@echo " install-spelling-deps Install pyspelling and aspell dependencies"
@echo " run Build docs and run pyspelling"
@echo " spelling Run pyspelling on existing build"

.PHONY: help Makefile
.PHONY: help Makefile install-spelling-deps spelling run

# Check if required dependencies are installed, install if missing
check-spelling-deps:
@echo "Checking for required spelling dependencies..."
@if ! command -v aspell >/dev/null 2>&1; then \
echo "aspell is not installed. Installing dependencies..."; \
$(MAKE) install-spelling-deps; \
elif ! python3 -c "import pyspelling" 2>/dev/null; then \
echo "pyspelling is not installed. Installing dependencies..."; \
$(MAKE) install-spelling-deps; \
else \
echo "All spelling dependencies are installed."; \
fi

# Install spelling dependencies
install-spelling-deps:
@echo "Installing spelling dependencies..."
@echo "Detecting operating system..."
@if command -v apt-get >/dev/null 2>&1; then \
echo "Detected Debian/Ubuntu system"; \
echo "Installing aspell and aspell-en..."; \
sudo apt-get update && sudo apt-get install -y aspell aspell-en; \
elif command -v yum >/dev/null 2>&1; then \
echo "Detected RHEL/CentOS system"; \
echo "Installing aspell and aspell-en..."; \
sudo yum install -y aspell aspell-en; \
elif command -v dnf >/dev/null 2>&1; then \
echo "Detected Fedora system"; \
echo "Installing aspell and aspell-en..."; \
sudo dnf install -y aspell aspell-en; \
elif command -v pacman >/dev/null 2>&1; then \
echo "Detected Arch Linux system"; \
echo "Installing aspell and aspell-en..."; \
sudo pacman -S --noconfirm aspell aspell-en; \
elif [ "$$(uname)" = "Darwin" ]; then \
echo "Detected macOS system"; \
if command -v brew >/dev/null 2>&1; then \
echo "Found Homebrew, installing aspell..."; \
brew install aspell; \
elif command -v port >/dev/null 2>&1; then \
echo "Found MacPorts, installing aspell..."; \
sudo port install aspell aspell-dict-en; \
else \
echo "Neither Homebrew nor MacPorts found."; \
echo "Please install aspell manually:"; \
echo " - Install Homebrew: https://brew.sh"; \
echo " - Then run: brew install aspell"; \
echo " - Or install MacPorts: https://www.macports.org"; \
echo " - Then run: sudo port install aspell aspell-dict-en"; \
exit 1; \
fi \
else \
echo "Could not detect package manager."; \
echo "Please manually install aspell and aspell-en for your system."; \
echo "Common package names: aspell, aspell-en"; \
exit 1; \
fi
@echo "Installing pyspelling via pip..."
@python3 -m pip install pyspelling
@echo "Spelling dependencies installed successfully!"
@echo "You can now run 'make run' to build docs and check spelling."

# Check dependencies, install if needed, build HTML documentation, run pyspelling, then serve
run: check-spelling-deps
@echo "Building HTML documentation..."
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Running spelling check..."
@if [ ! -f "$(SPELLING_CONFIG)" ]; then \
echo "Error: Spelling config file '$(SPELLING_CONFIG)' not found."; \
exit 1; \
fi
pyspelling -c $(SPELLING_CONFIG)
@echo "Press Ctrl+C to stop the server"
sphinx-autobuild -b html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Run pyspelling on existing build
spelling: check-spelling-deps
@echo "Running pyspelling with config: $(SPELLING_CONFIG)"
@if [ ! -f "$(SPELLING_CONFIG)" ]; then \
echo "Error: Spelling config file '$(SPELLING_CONFIG)' not found."; \
exit 1; \
fi
@if [ ! -d "$(BUILDDIR)/html" ]; then \
echo "Error: HTML build directory '$(BUILDDIR)/html' not found."; \
echo "Please run 'make html' first to build the documentation."; \
exit 1; \
fi
pyspelling -c $(SPELLING_CONFIG) -j 8

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Start a local development server to automatically rebuild and serve the HTML documentation
# whenever changes are made to the source files.
run:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
12 changes: 3 additions & 9 deletions docs/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Propose changes

The following steps provide an overview of the process involved in proposing changes to Django OTP WebAuthn:

1. Create an issue in the repository to outline the proposed changes.
1. Create an issue in the `repository <https://github.com/Stormbase/django-otp-webauthn>`_ to outline the proposed changes.

2. Fork the `repository <https://github.com/Stormbase/django-otp-webauthn>`_ and create a new branch for the changes.
2. Fork the repository and create a new branch for the changes.

3. :ref:`set-up-django-otp-webauthn`.

Expand Down Expand Up @@ -236,13 +236,7 @@ To build the documentation on your local machine, follow these steps:

cd docs

3. Build the documentation:

.. code-block:: console

make html

4. Serve and watch for changes:
3. Build and serve the documentation, then watch for changes :

.. code-block:: console

Expand Down
29 changes: 29 additions & 0 deletions docs/spellingcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
matrix:
- name: HTML files
aspell:
lang: en
d: en_US
encoding: utf-8
dictionary:
wordlists:
- wordlist.txt
output: wordlist.dic
sources:
- _build/html/**/*.html|!_build/html/index.html|!_build/html/contributing/style_guide.html|!_build/html/glossary.html|!_build/html/genindex.html|!_build/html/search.html
pipeline:
- pyspelling.filters.html:
comments: false
attributes:
- title
- alt
ignores:
- code
- pre
- spellexception
- link
- title
- div.relatedlinks
- strong.command
- div.visually-hidden
- img
- a.p-navigation__link
50 changes: 50 additions & 0 deletions docs/wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
AbstractWebAuthnAttestation
AbstractWebAuthnCredential
auth
authenticator
authenticator's
authenticators
authenticatorSelection
backends
backticks
BeginCredentialAuthenticationView
BeginCredentialRegistrationView
biometric
biometrics
Caddy
CompleteCredentialAuthenticationView
CompleteCredentialRegistrationView
cryptographic
django
Frontend
frontend
Furo
gettext
github
http
htmlcov
HTTPS
js
JSON
localhost
OneToOneField
OTP
OTPMiddleware
otp
passwordless
pradyunsg
pre
PyPI
py
Quickstart
reStructuredText
residentKey
Stormbase
subclasses
subclassing
untrusted
WebAuthn
webauthn
WebAuthnCredential
WebAuthnUserHandle
YubiKey
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ docs = [
"sphinx_design==0.6.1",
"sphinx-copybutton==0.5.2",
"sphinx-autobuild==2024.10.3",
"pyspelling==2.10",
]

[project.urls]
Expand Down Expand Up @@ -110,7 +111,7 @@ include = [

[tool.hatch.envs.default]
dependencies = [
"django-otp-webauthn[testing]",
"django-otp-webauthn[testing,docs]",
]

[tool.hatch.envs.hatch-static-analysis]
Expand Down