The skeleton of a Sphinx extention ready to be shipped in the sphinxcontrib organisation. It contains:
pre-commithooks (prettier, ruff, black)noxsessions (doc, pytest, mypy)- A test structure carefully designed for
Sphinxextentions based on thesphinxpytest fixture and pytest-regressions - a documentation structure based on Sphinx using the pydata-sphinx-theme
- a complete github folder (README, LICENSE, etc...)
- github actions (test, coverage, mypy, lint, release)
- ready to publish on pipy
- ready to document on readthedocs
- ready to report on codecov
- easy contribution using GitHub codespaces.
The package end result is demonstrated in the sphinxcontrib-skeleton repository.
Define an extension name. It can be anything with any normal character (w+) like "Extension Skeleton".
Init an empty github repository with the slug name of your extention. A slug should only use lower case characters and replace all spaces with
-like "extention-skeleton". To match the name of the package, the repository should be prefixed with "sphinxcontrib-" like "sphinxcontrib-extention-skeleton".Enable the repository on codecov and add a
CODECOV_TOKENgithub action env variable. With the generated token from codecov.Start a new readthedocs project hooked to the repository. in the admin tick the "build on PR" option.
In your local computer start the project by running the following code. Set the same names as in the github repository.
Note
You will need to install 2 extra python libs if it's not already done,
copierandjinja2-time.pip install copier jinja2-timecopier copy --trust gh:sphinx-contrib/copier-sphinxcontrib sphinxcontrib-<extention-skeleton>Go to the folder and init the git project:
cd sphinxcontrib-<extention-skeleton> git init
Run
noxtests to see if everything is working. This command will run the 4 nox sessions (lint, tests, mypy, docs)noxInstall pre-commits:
pre-commit installPush to distant repository following Github instructions
git add . git commit -m "build: initial commit" git remote add origin git@github.com:<username>/sphinxcontrib-<extention-skeleton>.git git branch -M main git push -u origin main
Once you are ready to make a release (or a pre-release to lock the name), Create a new project on pipy by running the first push yourself using version number
0.0.0:python -m build twine upload dist/**
Modify the lib as you see fit
Update version with commitizen tools:
cz bumpAdd a token to a new github action env variable
PYPI_PASSWORDfrom your pypi profile. limit the scope to this repository only.Start a new release in github and let actions do the rest
The generated package will automatically detect new releases of the template and create update PR. follow the instructions in the issue to update your project.