Development
Setup and tests
git clone https://github.com/ts-shape/ts-shape.git
cd ts-shape
pip install -e ".[dev]" # editable install with all extras except postgres, and the dev tools
pytest
Lint and type check
black --check src tests examples scripts # formatting
ruff check src tests examples scripts # linting
mypy # type checking (configured in pyproject.toml)
pre-commit install # optional: black and ruff on every commit
The [dev] extra pins black, ruff and mypy; CI installs it, and the
pre-commit hook revs match the same versions. All three block CI. mypy checks src/ts_shape with
disallow_untyped_defs, disallow_incomplete_defs, warn_return_any and
warn_unused_ignores and no exempt modules, so every function needs full
annotations. pandas results are typed Any; where a function returns one
under a narrower declared type, annotate a local (out: np.ndarray = ...) or
use typing.cast with a comment saying why. Converting with float() or
int() changes the returned scalar type.
Docs
The site is built with Docusaurus (Node 20 or
later) from the Markdown under docs/; the project lives in website/.
scripts/gen_ref_pages.py renders the API reference
(docs/reference/ts_shape/) from the docstrings with griffe2md and writes
docs/changelog.md and docs/license.md from CHANGES.txt and
LICENSE.txt. Those files are generated and git-ignored; run the script
again after changing a docstring.
pip install -e ".[docs]"
python scripts/gen_ref_pages.py
cd website
npm ci
npm start # live preview on http://localhost:3000/ts-shape/
npm run build # what CI runs; fails on broken links and anchors
cd ..
pytest tests/docs # code blocks bind against real signatures
Pages are plain Markdown (CommonMark, not MDX). Admonitions use
:::note ... :::. The navigation is website/sidebars.ts; a new page
must be added there.
- Diagrams: a
```mermaidfence renders as a diagram (flowcharts withflowchart TBstay readable; wideLRcharts get scaled down). - Math:
$$...$$is KaTeX, inline or on its own lines. A single$is text, so"$input"needs no escaping. - Tags: every module and guide page lists its topics (what question it
answers:
oee,drift,traceability, ...) and the standards it implements (iso-22400,aiag, ...) in front matter, topics first:tags: [downtime, oee, iso-22400]. Every tag must be declared indocs/tags.yml, otherwise the build fails; a new page gets at least one topic./tags/lists them, and each tag page links every page with it. - The build also writes
llms.txtandllms-full.txt(all pages as Markdown, for AI assistants) and a redirect from the old/reference/SUMMARY/URL.
Docs versions
The published site has one docs version per release line: the newest
release of each minor version (0.0, 0.1, ...) is a version, labelled with
its exact release (0.0.92). The newest release is served at the root,
older lines at /0.0/ with an "unmaintained" banner, and the unreleased
docs of main at /next/. A version dropdown in the navbar switches
between them.
Nothing is committed for this. The release workflow's docs job, after the
release tag is pushed, runs .github/scripts/docs_versions.py: for each
selected tag it checks the tag out in a temporary worktree, renders that
tag's API reference with the tag's own scripts/gen_ref_pages.py, and lets
docusaurus docs:version copy the docs into website/versioned_docs/.
Versions start with the first release that ships this script. Pull-request
CI and npm start build the unversioned site.
To build the versioned site locally (needs the release tags,
git fetch --tags):
python scripts/gen_ref_pages.py
cd website && npm ci && cd ..
python .github/scripts/docs_versions.py
cd website && npm run build && npm run serve
The snapshot files (website/versioned_docs/, website/versioned_sidebars/,
website/versions.json, website/versions-meta.json) are git-ignored;
delete them to go back to the unversioned site.
Build
python -m build
twine check --strict dist/*
The version comes from the git tags (setuptools-scm): a checkout 13 commits
after 0.0.62 builds 0.0.63.dev13. Releases are published by CI; do not
upload by hand.
Releases
Two GitHub Actions workflows:
.github/workflows/ci.ymlruns on every pull request commit (once; there is no separate push trigger) and can be started by hand. It lints (black, ruff, mypy), generates the API reference and builds the Docusaurus site (broken links fail), runs the tests on Python 3.13 to 3.15 and once with every core dependency pinned to its declared minimum (min-deps), and builds the package (twine check --strict, no0.0.0version, the wheel imports). A non-blockingscanjob runsscripts/scan_deprecations.sh(tests with DeprecationWarning as an error, mypy[deprecated], pip-audit, outdated packages) and uploads the reports..github/workflows/release.ymlruns on every push tomain:- it runs the full CI workflow;
- it decides the version (
.github/scripts/next_version.py); - it builds and checks the sdist and wheel with that version;
- it publishes them to PyPI;
- only then it pushes the
X.Y.Ztag and creates the GitHub release; - it builds the docs and deploys them to GitHub Pages.
Every merge to main is a release, a patch release by default. To choose
another version, add a trailer to the message of any commit since the last
release (the most recent trailer wins):
Release-Bump: minor # patch | minor | major | none (no release)
Release-As: 0.1.0 # an exact version, higher than the last release
A manual run of the Release workflow (Actions, Release Pipeline, Run workflow) takes the same choice as inputs.
One-time repository settings: set the PYPI_API_TOKEN secret (or configure
PyPI Trusted Publishing for release.yml and drop the token). The workflows
declare their token permissions per job, so the repository default
(Settings, Actions, General, Workflow permissions) can stay read-only.
Dependencies
Dependencies are declared only in pyproject.toml: the core ones under
[project].dependencies (with minimum versions; CI tests those floors in the
min-deps job) and the optional ones as extras. There are no requirements
files; Renovate updates pyproject.toml, the pre-commit hooks and the
GitHub Actions directly.