Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .claude/skills/tetrak-ocr-design/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ is what makes this easy to get wrong.
| `{{< tabs >}}{{< tab "macOS" >}}…{{< /tab >}}{{< /tabs >}}` | Tabbed content. The tab label is a **positional** argument |
| `{{< include "LICENSING.md" >}}` | Inlines a file from the repo — positional, repo-root relative |
| `{{< people >}}{{< person name="…" role="…" linkedin="handle" >}}…{{< /person >}}{{< /people >}}` | The about page's bios. `linkedin` is the **profile handle**, not the URL |
| `{{% generated %}}` | Marks a page as machine-written — used by the API reference |

Both `figure` and `lightbox` call `errorf` when the asset is missing, so a bad
path fails the build rather than shipping a broken image.
Expand Down Expand Up @@ -373,7 +372,7 @@ defect is reintroduced.
## Build-time over runtime

The site's priority is a fast page for the reader; a longer build is an
acceptable trade. The benchmark table, the search index, the API reference and
acceptable trade. The benchmark table, the search index, the band table and
every image are built. JavaScript is reserved for what genuinely needs the
browser: the search modal, the theme toggle, copy buttons, the lightbox.

Expand All @@ -384,6 +383,6 @@ All run from `site/`:
```bash
cd site
npm run lint # ESLint, Stylelint, markdownlint
npm run build # Hugo, after regenerating the API reference
npm run build # Hugo, after regenerating the diagrams and the band table
npx playwright test # starts its own server
```
20 changes: 10 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# NODE_VERSION 24
# PYTHON_VERSION 3.11
#
# `pip install -e .` is not optional: prebuild regenerates
# content/reference/api.md by importing the installed package, and that file is
# gitignored rather than committed. The core dependency set is deliberately
# `pip install -e .` is not optional: prebuild runs tools/generate_tuning_data.py,
# which imports tetrak_ocr.backends.tuning to publish the auto-configuration
# bands into site/data/tuning.toml. The core dependency set is deliberately
# light (Pillow, pytesseract, pdf2image, python-dotenv) -- the heavy OCR
# backends are extras and are not installed for a docs build.
name: Docs
Expand Down Expand Up @@ -86,18 +86,18 @@ jobs:
cache: npm
cache-dependency-path: site/package-lock.json

# The API reference is generated by importing the package and reading its
# docstrings, so the package has to be installed, not just the site deps.
# Without it the generator now exits 1 rather than publishing a page of
# "Not documented" placeholders behind a green build.
# The band table is generated by importing the package, so the package
# has to be installed, not just the site deps. Without it the generator
# exits 1 rather than publishing a page with no bands behind a green
# build.
- uses: actions/setup-python@v7
with:
python-version: "3.11"
cache: pip

- name: Install the package
# From the repository root: pyproject.toml is there, and the API
# reference is generated by importing the installed package.
# From the repository root: pyproject.toml is there, and the band
# table is generated by importing the installed package.
working-directory: .
run: pip install -e .

Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
- name: Diagrams are rendered and committed
run: node scripts/render-mermaid.mjs --check

# `npm run build` regenerates content/reference/api.md and then runs Hugo.
# `npm run build` regenerates the band table and then runs Hugo.
# Hugo comes from the hugo-extended npm package, so there is no separate
# install step and the version is pinned in package-lock.json.
#
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ node_modules/
.hugo_build.lock
hugo_stats.json

# Generated reference page. Rebuilt from docstrings before every build, so
# committing it would just be a second copy to go stale.
/site/content/reference/api.md
test-results/
playwright-report/

Expand All @@ -68,7 +65,7 @@ tools/.image-cache/

# Sphinx build output and autosummary-generated module stubs. Regenerated by
# sphinx-build on every build; committing them would be a second copy to go
# stale, same reasoning as /site/content/reference/api.md above.
# stale.
/docs/_build/
/docs/generated/

Expand Down
49 changes: 31 additions & 18 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

Guidance for Claude Code when working in this repository.

This file is orientation and conventions. The reference material — backend
behaviour, routing, benchmark results, method and its caveats — lives in
`site/content/` and is published to Cloudflare Pages at https://tetrak.dev/. When you
need the detail, read the
site page rather than expecting to find it here, and when you change behaviour,
update that page rather than restating it here. Anything documented in two
places will drift.
This file is orientation and conventions. The documentation lives in two
places, split by what each can keep honest. How to install and use the
package — the user guide, tutorials, and the CLI and API reference generated
from the code — is `docs/`, a Sphinx site published to GitHub Pages at each
release. The research — the corpus, what each engine was measured to do,
routing, benchmark results, method and its caveats — is `site/content/`, the
Hugo site at https://tetrak.dev/. When you need the detail, read the page
rather than expecting to find it here, and when you change behaviour, update
the page rather than restating it here. Anything documented in two places
will drift.

## What this repository is

Expand Down Expand Up @@ -69,7 +72,7 @@ EasyOCR, PaddleOCR and Marker download model weights on first use (~100 MB,
## Commands

Everything runs through the `tetrak-ocr` console script. See
[`site/content/reference/cli.md`](site/content/reference/cli.md) for the full surface.
[`docs/guide/command-line.md`](docs/guide/command-line.md) for the full surface.

```bash
tetrak-ocr backends # what is installed, and what each needs
Expand All @@ -84,7 +87,7 @@ ruff format src tests evaluation tools

cd site && npm run start # the site at :1313
cd site && npm run lint # eslint, stylelint, markdownlint; covers functions/ too
cd site && npm run build # regenerates the API reference, then Hugo
cd site && npm run build # regenerates the band table, then Hugo
cd site && npx playwright test # browser checks; starts its own server
python tools/generate_presentation.py # → collateral/*.pptx (gitignored), Tetrak-themed, from the benchmark
python tools/generate_expected.py # regenerate ground truth; needs an API key
Expand Down Expand Up @@ -279,7 +282,7 @@ help text and validation from that table. A writer takes
`(source, transcript, destination, **options)` and must tolerate options meant
for another format, because one dict is passed to all of them. Add an alias to
`_ALIASES` only for a spelling people will actually type. Document it in
[`site/content/reference/cli.md`](site/content/reference/cli.md).
[`docs/guide/command-line.md`](docs/guide/command-line.md).

**A telemetry event** — call `telemetry.record("<event>", **fields)` from
wherever the fact is known. The sink is process-global and a no-op when no run
Expand Down Expand Up @@ -364,9 +367,18 @@ the page showed after the first post-split chore merge. So a change under
To redeploy by hand, dispatch from `main` with the tag as an input
(`gh workflow run sphinx-docs.yml --ref main -f tag=5.14.1`): the
`github-pages` environment admits deployments from `main` only, so a dispatch
against the tag ref builds correctly and is then refused. It is scoped
strictly to the CLI and Python API reference; narrative content stays on the
Hugo site.
against the tag ref builds correctly and is then refused.

What goes where: `docs/` is everything about *using* the package —
installation, the command line and Python API guides, the tutorials, and the
reference generated from the parser and the docstrings. The Hugo site is the
research: the corpus, the engines as measured, routing, results and method,
and the articles. The site's `/reference/cli/` page is a stub that links to
the guide; the generated API page it used to carry (`tools/generate_api_docs.py`)
was retired in favour of Sphinx's, so the two could not drift. Build the
Sphinx site locally with `pip install -e '.[apidocs]'` and
`sphinx-build -W -b html docs docs/_build/html`; `-W` is what CI runs, so a
warning is a failure.

The Cloudflare Pages project:

Expand All @@ -381,11 +393,12 @@ The Cloudflare Pages project:

Two things make that build command work, and both are load-bearing:

- **`pip install -e .` comes first.** `prebuild` regenerates
`site/content/reference/api.md` by importing the installed package. The file
is gitignored, so without the install the build fails rather than shipping a
page of placeholders. Only the core dependencies are installed — the heavy OCR
backends are extras and a docs build does not need them.
- **`pip install -e .` comes first.** `prebuild` runs
`tools/generate_tuning_data.py`, which imports `tetrak_ocr.backends.tuning`
to publish the auto-configuration bands into `site/data/tuning.toml`.
Without the install the generator exits 1 rather than shipping a page with
no bands. Only the core dependencies are installed — the heavy OCR backends
are extras and a docs build does not need them.
- **The mermaid SVGs are committed.** `prebuild` also runs
`scripts/render-mermaid.mjs`, which now exits early when every diagram already
has its rendered SVG. Cloudflare's build image has no browser and no way to
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ material — postcards, posters, playbills, programmes and trade papers.
> Install it as `pip install tetrak`. The command it provides is still
> `tetrak-ocr`, so every command below is unchanged.

**📖 [Full documentation](https://tetrak.dev/)**
**📖 [User guide and reference](https://scattercode.github.io/tetrak/)** · **[Research and benchmark](https://tetrak.dev/)**

No single OCR engine wins across document types. Tetrak's answer is not to make
you choose: point it at a folder and it runs several engines per file, scores
Expand Down
5 changes: 4 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Python API
# Python API reference

Every public module, function and class, generated from the docstrings. For
how the pieces fit together, see [using the Python API](guide/python-api.md).

```{eval-rst}
.. autosummary::
Expand Down
5 changes: 3 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Command line
# Command line reference

Installing the package provides a `tetrak-ocr` command.
Every subcommand and flag, generated from the parser. For what the flags
are for, see [using the command line](guide/command-line.md).

```{argparse}
:module: tetrak_ocr.cli
Expand Down
17 changes: 12 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Sphinx configuration for the tetrak CLI/API reference.

Published to GitHub Pages by .github/workflows/sphinx-docs.yml. Scoped to
CLI + Python API reference only -- narrative content (corpus, engines,
routing, licensing) lives on the Hugo site at https://tetrak.dev/.
"""Sphinx configuration for the tetrak user guide and reference.

Published to GitHub Pages by .github/workflows/sphinx-docs.yml, at each
release. This site is how to use the package: installation, the command
line and Python API guides, tutorials, and the CLI and API reference
generated from the code. The research -- the corpus, what each engine was
measured to do, the routing evidence, the articles -- lives on the Hugo site
at https://tetrak.dev/, which links here for everything operational.
"""

from __future__ import annotations
Expand Down Expand Up @@ -44,6 +47,10 @@
napoleon_numpy_docstring = True

source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
# The guide links to headings on other pages (`command-line.md#the-run-log`).
# MyST only resolves those when it generates anchors for headings; three
# levels covers every heading the guide links to.
myst_heading_anchors = 3
root_doc = "index"

html_theme = "furo"
Expand Down
Loading
Loading