Skip to main content

DocXCast

DocXCast

"Your template is the mold. Data is poured in, documents take shape."

🪄 About

DocXCast turns a Word document's content controls into a typed schema, and casts your data back into a formatted document.

The Idea:

A .docx template is a natural schema editor. In Word's Developer tab, anyone can insert content controls and describe them:

Word control property Role in DocXCast
Title field name (e.g. name)
Tag extraction requirement for the LLM (e.g. the candidate's full name)
Repeating section array of records
Building block gallery Section with its own extraction rule
Group control with a name? Title conditional block (see below)
Locked control (sdtLocked) required field

The full control inventory — every construct's Word-visible pseudo-structure and the OOXML it is made of — lives in SYNTAX.md.

Two independent capabilities:

  1. derive_schema(template) — read the controls and produce a Schema, serializable to JSON Schema for LLM structured extraction.
  2. render(template, data) — pour data back into the template: clone repeating sections, fill values, unwrap controls, keeping every run's formatting.

⚡ Key Features

  • Your template IS the schema — field names, extraction requirements and repeats all live in the docx, editable by non-programmers.
  • Typed control mapping — text → string, dropdown → enum, date / date-time → format, checkbox → boolean, picture → derived and removed.
  • LLM-friendly contract validation — schema.validate(data) returns structured, machine-readable issues (path / code / message / expected / got) that can be fed back into an LLM correction loop.
  • Lenient by default, strict on demand — missing fields keep their template values; strict=True raises on the first error.
  • Clean output — controls are unwrapped by default; keep_controls=True keeps them for round-trip editing.
  • Zero magic — a single runtime dependency (python-docx).

🚀 Quick Start

from docxcast import derive_schema, render

schema = derive_schema('resume-template.docx')

# hand this to your LLM as the extraction contract
json_schema = schema.to_json_schema()

# validate what the LLM extracted
report = schema.validate(data)
if not report.ok:
    # feed report.issues back into the LLM for correction
    ...

# cast data into the template; controls are unwrapped
result = render('resume-template.docx', data)
result.save('resume-output.docx')

📏 Validation

Schema.validate() never raises; it returns a ValidationResult:

result.ok      # False if any error-level issue exists
result.errors  # missing_required / type_mismatch / enum_invalid / format_invalid
result.warnings  # unknown_key

render(..., strict=True) raises RenderError on the first error-level issue.

🔀 Conditional Blocks

Wrap a block in a group control and mark the guarded control's Title with a trailing ? (TS-style): a falsy value removes the whole group — label text included — while a truthy value fills normally.

Nationality: [nationality?]   truthy → "Nationality: Chinese"   falsy → the line is gone

Work Experiences              both the heading and the repeat
[repeat: work_experiences?]   disappear when the array is empty

The ? is a render directive only — the derived schema (and the LLM contract) see a plain nationality field. Marker placement, inline vs block-level drops, positional has_prev? / has_next? separators and every misuse error live in SYNTAX.md.

⚠️ Limitations

  • picture controls are recognized in the schema but removed on render (no image insertion yet).
  • Date values are written verbatim; the template's display mask is not enforced.
  • Unnamed controls are skipped in the schema — every field needs a Title to be addressable.
  • No whitespace control: text outside a dropped inline conditional span survives — put separators inside the span.

Metadata

Release files for docxcast 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docxcast 0.1.3
File Size Uploaded Provenance Actions
docxcast-0.1.3.tar.gz 57.8 kB Without provenance Details for docxcast-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docxcast 0.1.3
File Interpreter ABI Platform Actions
docxcast-0.1.3-py3-none-any.whl Python 3 none any Details for docxcast-0.1.3-py3-none-any.whl

Total release size: 80.0 kB

Release files / docxcast-0.1.3.tar.gz

Download URL docxcast-0.1.3.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e6787499392302d210b0a0aa24379b583fc256ef329b385674dadc4e7258b066
BLAKE2b-256 checksum
How to use checksums
af8591522173ee36816f1d815b8674996acad9796fbcc0e44096de7b9799b968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / docxcast-0.1.3-py3-none-any.whl

Download URL docxcast-0.1.3-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4208b09aa7eaff2d7dd74c1014dfd8503da771970e817ec7696461df57c53c5
BLAKE2b-256 checksum
How to use checksums
317b2371015d1b437a6b5dc0648a47c3bf0a1132da32792ef3a3f1f5640504d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for docxcast 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page