From e7bfc49b52ac95dba4eca228a1ae58c916dbb314 Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Wed, 26 Aug 2026 17:04:35 -0500 Subject: [PATCH 01/11] AGENTS.md: Add runnable example guidance - Define PEP 723 metadata, layout, resource, and docstring conventions - Document local and matrix validation for live examples Assisted-by: Codex --- AGENTS.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 4457231..ab83f06 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -326,6 +326,65 @@ to `.env`) in temporary scripts to drive the in-flight client against live endpoints and capture responses for test data and assertions. +## Example Guidelines + +- Every new public endpoint/helper must include a runnable example under + `examples/`. Group examples by capability in an endpoint-oriented directory + such as `examples/extract_text/`, and use a descriptive `*_example.py` + filename. Add the script to the inventory in `examples/README.md` and update + relevant docs links or usage guidance when the new capability changes + discoverability. + +- Make each example a standalone uv script. Its first lines must be a PEP 723 + metadata block in the single-line form understood by the Nox example discovery + code: + + ```python + # /// script + # requires-python = ">=3.10" + # dependencies = ["pdfrest", "python-dotenv"] + # /// + ``` + + Set `requires-python` to the widest supported range the example actually + supports and list every third-party import in `dependencies`. Keep the block + first (do not put a shebang above it), because `noxfile.py` reads metadata + starting at line one. PEP 723 metadata gives `uv run` an isolated environment; + do not rely on undeclared project or development dependencies. + +- Follow the metadata with a module docstring that states the user outcome, + lists the important upload/API/output steps, and gives the exact command to + run from the repository root, for example + `uv run examples/extract_text/extract_pdf_text_example.py`. Name required + environment variables, input files, and any expected setup in that docstring. + +- Prefer deterministic, redistributable inputs under `examples/resources/` and + resolve them relative to `Path(__file__)`, never the caller's working + directory. Reuse a suitable checked-in resource when possible. Before adding a + new binary or specialized input, confirm its provenance, redistribution + suitability, and expected API behavior; ask the contributor for the required + asset when those cannot be established. + +- Examples exercise the real service, load `PDFREST_API_KEY` from the + environment (optionally through `python-dotenv`), upload local inputs through + `client.files.create_from_paths`, and use client context managers. Keep the + flow short and instructional while printing enough typed response data for a + user and CI to confirm success. + +- Put interpreter-specific alternatives beside the base script as + `python-X.Y/.py`, with a local `ruff.toml` extending the parent + configuration, only when syntax or compatibility requires a distinct script. + The base script remains the default for newer supported interpreters. + +- Validate a new or changed example directly with `uv run