Metadata-Version: 2.5
Name: phlo-querymd
Version: 0.1.0
Summary: Composable SQL and Markdown reports in one standalone HTML file
Project-URL: Homepage, https://github.com/phlohouse/querymd
Project-URL: Repository, https://github.com/phlohouse/querymd
Project-URL: Issues, https://github.com/phlohouse/querymd/issues
Author: Phlo House
License-Expression: MIT
Keywords: duckdb,markdown,reports,sql,vega-lite
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: SQL
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.12
Requires-Dist: altair<7,>=5.5
Requires-Dist: duckdb<2,>=1.5
Requires-Dist: jsonschema<5,>=4.18
Requires-Dist: markdown-it-py<5,>=4.0
Requires-Dist: mdit-py-plugins<1,>=0.5
Requires-Dist: pyyaml<7,>=6.0
Requires-Dist: vl-convert-python<2,>=1.9
Provides-Extra: iceberg
Requires-Dist: duckdb-extension-avro<2,>=1.5; extra == 'iceberg'
Requires-Dist: duckdb-extension-iceberg<2,>=1.5; extra == 'iceberg'
Description-Content-Type: text/markdown

# QueryMD

Build a report from Markdown, SQL queries, and reusable chart definitions.
The output is one standalone HTML file with interactive charts, fonts, styles, data
downloads, and provenance embedded. It needs no network connection or supporting files.

## Run the example

From this folder:

```bash
uv run querymd examples/measurements/report.md
```

For a fuller report (a headline that states the finding, a KPI strip, cards, a highlighted
chart, a table with bars and an at-risk callout, all on invented batch data):

```bash
uv run querymd examples/batch-review/report.md
```

Open `examples/measurements/report.html`. The example uses invented measurements.
It uses only the included CSV and query library.

To select other series:

```bash
uv run querymd examples/measurements/report.md --param series=alpha,beta
```

To rebuild whenever the report, its library files, sources, or evidence change:

```bash
uv run querymd examples/measurements/report.md --watch
```

A failed rebuild prints the error, keeps the previous report, and keeps watching.
Add `--strict` to fail on charts, tables, or parameters the report defines but never uses.

To print a PDF alongside the HTML, for a document-management system or a batch record:

```bash
uv run querymd examples/measurements/report.md --pdf
```

The PDF goes next to the HTML unless you give a path (`--pdf out/review.pdf`). It uses the
report's print layout, with a footer giving the title, snapshot hash and page numbers on every
page. Paper is A4 unless you pass `--paper letter`. Printing needs Chrome, Chromium or Edge on
Linux or macOS; querymd finds a common install, or set `QUERYMD_BROWSER` to the browser's path.
No other dependency is needed. As with the HTML, querymd replaces only PDFs a browser printed,
and `--watch` reprints after each rebuild.

To validate a report without writing anything, for example in CI:

```bash
uv run querymd check examples/measurements/report.md
```

`check` loads the sources, runs every query, and compiles every chart and table, including
library charts the report does not reference. It exits non-zero on the first problem.

Report blocks and library files are checked against a JSON Schema, which catches misspelt
settings. `querymd schema` prints it. For autocomplete in editors that use the YAML language
server, start a library file with:

```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/phlohouse/querymd/main/src/querymd/report.schema.json
```

## Use your own data

Create a Markdown report with a top fenced `report` YAML block. Declare CSV, Parquet, JSON,
read-only DuckDB, or Iceberg sources in that report (Iceberg needs `uv sync --extra iceberg`). Include reusable query and chart definitions from any directory.
Library files describe queries and charts against named sources; reports supply the data paths.

For an existing report outside this folder:

```bash
uv run --project /path/to/querymd querymd /path/to/your/report.md
```

The HTML file goes beside the Markdown. Use `-o` or `--output /path/to/output.html` to change it.
Paths inside reports resolve relative to the report file, regardless of the working directory.
The **Resolved definition** download includes imported definitions with overrides applied.

The [report format reference](docs/report-format.md) describes sources, parameters, charts,
composition, and overrides. Python callers use `querymd.render.build(report, output, overrides)`.

## Reference from another project

QueryMD is published on PyPI as `phlo-querymd`. The import name and the command are still `querymd`:

```bash
uv add phlo-querymd
uv run querymd path/to/report.md
```

To work against a local checkout instead, point uv at it:

```toml
[project]
dependencies = ["phlo-querymd"]

[tool.uv.sources]
phlo-querymd = { path = "../querymd", editable = true }
```

The package contains the renderer and its assets. It contains no project data or query libraries.

## Validate locally

```bash
uv run ruff check src tests
uv run python -m unittest discover -s tests -v
uv build --out-dir /tmp/querymd-dist
```

Or use `make install`, `make test`, `make lint` and `make build`.

Dependencies are declared in `pyproject.toml`. After installation, `uv run --offline`
prevents package downloads. The default appearance uses locally bundled Inter Variable
and Departure Mono fonts with their licenses. Vega renders the charts with an
Interfere-inspired categorical palette. The same series colours appear in light and dark modes;
backgrounds, labels, and grid lines follow the system colour scheme, including live changes.
PNG and SVG downloads are drawn in the browser and match the displayed theme.
Each query's rows are stored once, however many charts use them. A light static SVG of each
chart is the fallback without JavaScript and the version used for printing.

## Releasing

Versions come from git tags. To release from a clean `main`:

```bash
make release-check VERSION=0.1.0   # build locally at that version without tagging
make release VERSION=0.1.0         # tag v0.1.0 and push it
```

Pushing the tag runs the publish workflow. It reruns CI, builds the sdist and wheel, uploads them to
PyPI as `phlo-querymd` through trusted publishing (the `pypi` environment), and creates a GitHub
release with the built files attached.
