Skip to main content

Module stats

Module stats 

Source
Expand description

opys stats — render the project’s configured [[stats]] sections. Each stat is a single SQL query (sql) run against an in-memory, throwaway relational view of the corpus (tables docs, tags, sections, fields); its result set is rendered as a markdown table. Pure read; no feature/type special-casing. The SQL engine is GlueSQL (pure Rust, in-memory).

Functions§

build_db
Materialize corpus into a fresh in-memory database (the four corpus tables).
corpus_json
The corpus projection: a JSON array with one object per live document. This is the intermediate the relational tables are materialized from.
render_all
Render every configured stat over docs, concatenated with a blank line between sections. The corpus DB is built once and reused. Err carries the first failing stat’s problem message.
render_stat
Render one stat over corpus (builds a DB just for it). Convenience for config-time validation over an empty corpus.
render_stat_on
Run one stat against an already-built corpus DB and format the result — as a markdown table, or through the stat’s row template when set. Returns a human-readable problem (prefixed with the stat name) on failure. Used by render_all and by verify.
run

Type Aliases§

CorpusDb
An in-memory corpus database. Built once per opys stats / verify run and reused across every stat — materializing (and re-parsing the INSERT DML) once per stat would be needless O(stats × corpus) work.