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
40 changes: 17 additions & 23 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Build the reference and publish it to GitHub Pages.
#
# The site at https://scattercode.github.io/sillybos/ is the README followed
# by the API and command line reference, generated by Sphinx from docs/ and
# the package's docstrings (docs/conf.py). Every push to main builds it and
# deploys it with the official Pages flow (upload-pages-artifact, then
# deploy-pages from a job of its own): no gh-pages branch, nothing committed.
# A pull request runs the build alone, with warnings as errors, so a
# docstring that renders badly fails the review rather than main.
# by the API and command line reference, generated by Zensical from docs/
# and the package's docstrings (zensical.toml). Every push to main builds
# it and deploys it with the official Pages flow (upload-pages-artifact,
# then deploy-pages from a job of its own): no gh-pages branch, nothing
# committed. A pull request runs the build alone, in strict mode, so a
# docstring that renders badly or a cross-reference to nothing fails the
# review rather than main.
#
# Publishing needs the repository's Pages source set to "GitHub Actions"
# (Settings > Pages > Build and deployment), once, by hand. Until it is, the
# deploy job fails and says so; the build job reports regardless.
#
# The version in the page title comes from hatch-vcs. A merge that cuts no
# release (docs, ci, chore) therefore publishes as X.Y.Z.devN until the
# release commit for the next one lands, which is the honest reading of
# main at that moment; docs/conf.py says why the .devN is kept.
# (Settings > Pages > Build and deployment), which it is.
name: Docs

on:
Expand Down Expand Up @@ -47,32 +42,31 @@ jobs:
steps:
- uses: actions/checkout@v7
with:
# hatch-vcs derives the version from `git describe --tags`, and
# the page title carries it. A shallow clone has no tags
# reachable and the site would call itself 0.1.dev1.
fetch-depth: 0
persist-credentials: false

# No pip cache: Zensical's own guidance is not to cache on CI, and
# the install takes seconds.
- uses: actions/setup-python@v7
with:
python-version: "3.12"

- name: Install the package with the docs extra
run: pip install -e '.[docs]'

# -W makes every warning a failure; --keep-going reports them all
# rather than stopping at the first.
# --strict makes every warning a failure; --clean starts from
# nothing rather than a cache.
- name: Build
run: sphinx-build -W --keep-going -b html docs docs/_build/html
run: zensical build --clean --strict

# The artifact is what deploy-pages publishes. actions/configure-pages
# is left out on purpose: it only sets outputs for static site
# generators that need the site's base path, which Sphinx does not,
# and it would need Pages permissions on a job that otherwise reads.
# generators that need the site's base path, which this one has in
# zensical.toml, and it would need Pages permissions on a job that
# otherwise reads.
- uses: actions/upload-pages-artifact@v5
if: github.event_name != 'pull_request'
with:
path: docs/_build/html
path: site

deploy:
name: Deploy to GitHub Pages
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ htmlcov/
# Written at build time by hatch-vcs; the version lives in the git tag.
src/sillybos/_version.py

# Sphinx output (docs/)
/docs/_build/
# Zensical output (zensical.toml)
/site/

# OS
.DS_Store
16 changes: 8 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ in `SECURITY.md`.
project.
- The checks: `ruff check .`, `ruff format --check .`, `mypy`, `pytest --cov`
(floor in `pyproject.toml`), `uv lock --check`, and
`sphinx-build -W -b html docs docs/_build/html` with the `docs` extra.
The Ruff set includes the `S` (bandit) rules; an ignore needs a reason
beside it.
- The reference site (`docs/`, published to GitHub Pages on merge) is the
README, included between its two `docs:` comment markers, plus the API
and command line generated from the docstrings. Document the API in the
docstrings, Google style with reStructuredText cross-references; never
copy it into a page by hand.
`zensical build --clean --strict` with the `docs` extra. The Ruff set
includes the `S` (bandit) rules; an ignore needs a reason beside it.
- The reference site (`docs/` and `zensical.toml`, published to GitHub
Pages on merge) is the README, included between its two `--8<--` snippet
markers, plus the API and command line generated from the docstrings.
Document the API in the docstrings, Google style with Markdown
cross-references (`[Policy][sillybos.Policy]`); never copy it into a
page by hand.
- Conventional Commits, enforced by `.githooks/commit-msg` (shared from
`scattercode/release-pipelines`; do not edit the copy). `fix` → patch,
`feat` → minor, `!` → major. Releases are automatic on merge to `main`:
Expand Down
29 changes: 16 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ uv pip install -e '.[dev,docs]'

(`python -m venv` and `pip` work too.) The PDF tests need `pdfinfo` from
poppler (`brew install poppler`, `apt install poppler-utils`) and skip
without it. The `docs` extra is Sphinx and its theme, for the reference
site; leave it out if you are not touching the docs. Then activate the git
hooks, one of:
without it. The `docs` extra is Zensical and the API documentation
handler, for the reference site; leave it out if you are not touching the
docs. Then activate the git hooks, one of:

```bash
lefthook install # if you have lefthook (brew install lefthook gitleaks zizmor)
Expand All @@ -57,7 +57,7 @@ ruff format --check .
mypy
pytest --cov
uv lock --check # the lockfile matches pyproject.toml
sphinx-build -W -b html docs docs/_build/html # the docs, with the docs extra
zensical build --clean --strict # the docs, with the docs extra
gitleaks git --no-banner --redact . # secrets in the history
uvx zizmor --min-severity medium .github/workflows
```
Expand All @@ -70,15 +70,18 @@ above the floor in `pyproject.toml`.
## The docs

The reference site at <https://scattercode.github.io/sillybos/> is built by
Sphinx from `docs/` and published by `docs.yml` on every push to `main`. It
is the README (included, not copied, between the two `docs:` comment
markers) followed by the API and the command line, generated from the
docstrings and the parser. There is nothing to write by hand when the API
changes: the docstrings are the reference, in Google style with
reStructuredText cross-references (`:class:`, `:func:`, `:data:`), and a
docstring that does not render is a build failure, since the build runs
with warnings as errors on every pull request. Build it locally with the
command above and open `docs/_build/html/index.html`.
[Zensical](https://zensical.org/) from `docs/` and `zensical.toml`, and
published by `docs.yml` on every push to `main`. It is the README
(included, not copied, between its two `--8<--` snippet markers) followed
by the API and the command line, generated from the docstrings and the
parser. There is nothing to write by hand when the API changes: the
docstrings are the reference, in Google style with Markdown
cross-references (`[Policy][sillybos.Policy]`; the function `check` is
`[check][sillybos.check.check]`, since `sillybos.check` is also the module
it lives in), and a docstring that does not render, or a reference to a
name that is not documented, is a build failure, since the build runs in
strict mode on every pull request. Preview it locally with
`zensical serve`.

## Dependencies and the lockfile

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**📖 [Documentation and API reference](https://scattercode.github.io/sillybos/)**

<!-- docs: include from here -->
<!-- --8<-- [start:docs] -->
<img src="https://raw.githubusercontent.com/scattercode/sillybos/main/docs/logo.png" alt="A rolled scroll with a small parchment tag hanging from it, reading: metadata, caps and format vetted" width="280" align="right">

**Decide before decoding.** A σίλλυβος (*sillybos*; Latin *sittybus*) was
Expand Down Expand Up @@ -210,7 +210,7 @@ Say this plainly, because a security library carries an implied promise.
the rest are refused by name until someone shows a scan in one. Each
format added is attack surface added.

<!-- docs: include to here -->
<!-- --8<-- [end:docs] -->

## Development

Expand Down
59 changes: 27 additions & 32 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,58 @@
Everything the package exports, generated from the docstrings. The
[policy table](index.md#the-policy) says what each limit bounds and why.

```{eval-rst}
.. automodule:: sillybos
```
::: sillybos
options:
members: false
show_root_heading: false
show_root_toc_entry: false

## The check

```{eval-rst}
.. autofunction:: sillybos.check
<!-- sillybos.check is both the function and the module it is defined in;
griffe keeps the module under that name, so the function is addressed
by where it is defined. -->
::: sillybos.check.check

.. autofunction:: sillybos.require
::: sillybos.require

.. autoclass:: sillybos.Verdict
:members:
::: sillybos.Verdict

.. autoclass:: sillybos.Facts
::: sillybos.Facts

.. autoexception:: sillybos.Refused
::: sillybos.Refused

.. autoexception:: sillybos.pdf.PdfInfoMissing
```
::: sillybos.pdf.PdfInfoMissing

## The policy

```{eval-rst}
.. autoclass:: sillybos.Policy
:members:
::: sillybos.Policy

.. autodata:: sillybos.DEFAULT
:no-value:
::: sillybos.DEFAULT

.. autodata:: sillybos.STRICT
:no-value:
```
::: sillybos.STRICT

## The names

What a policy's fields and a verdict's facts are spelt with. Each tuple is
every name the library knows, in the order the reasons list them; a policy
chooses from it.

```{eval-rst}
.. autodata:: sillybos.FORMATS
::: sillybos.FORMATS

.. autodata:: sillybos.JPEG_FRAMES
::: sillybos.JPEG_FRAMES

.. autodata:: sillybos.PNG_COLOUR_TYPES
::: sillybos.PNG_COLOUR_TYPES

.. autodata:: sillybos.TIFF_COMPRESSIONS
::: sillybos.TIFF_COMPRESSIONS

.. autodata:: sillybos.TIFF_PHOTOMETRICS
::: sillybos.TIFF_PHOTOMETRICS

.. autodata:: sillybos.TIFF_SUBSAMPLINGS
```
::: sillybos.TIFF_SUBSAMPLINGS

## With Pillow

```{eval-rst}
.. automodule:: sillybos.pillow
:members:
```
::: sillybos.pillow
options:
show_root_heading: false
show_root_toc_entry: false
21 changes: 12 additions & 9 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Command line reference

Every flag of the `sillybos` command, generated from its parser. The
[README](index.md#the-command) shows what a run looks like.
Every flag of the `sillybos` command, as its own `--help` prints them,
generated from the parser at build time. The [README](index.md#the-command)
shows what a run looks like.

```{eval-rst}
.. automodule:: sillybos.cli
```
::: sillybos.cli
options:
members: false
show_root_heading: false
show_root_toc_entry: false

```python exec="true" result="text"
from sillybos.cli import build_parser

```{argparse}
:module: sillybos.cli
:func: build_parser
:prog: sillybos
print(build_parser().format_help())
```
104 changes: 0 additions & 104 deletions docs/conf.py

This file was deleted.

Loading
Loading