Back to buildsBUILD RECORD

Career Document Tooling / Python document-generation utilities / 2026

Generating Word layouts and making controlled template edits.

Python builders handle document layout, while selected DOCX patchers check template hashes and XML structure before replacing text.

THE WORK

The project.

Career Document Tooling brings two approaches to preparing Word documents: building a layout in Python and editing selected text in an existing template. The builders use python-docx for ordinary document composition, with WordprocessingML helpers for numbering, page fields and table geometry. The targeted patcher works inside the DOCX archive so it can retain the other document parts while changing selected text.

Those edits depend on a known template. A SHA-256 check identifies the expected reference, and text-node checks test the structure before replacement. The scripts refuse mismatches instead of guessing which paragraph a changed template now contains. This is a group of local utilities, not a shared document service or a submission workflow.

IMPLEMENTATION

Design choices.

  1. A fixed template allows narrow edits without reconstructing every document part. That approach depends on specific paragraph positions, so the selected patcher checks both the reference hash and expected text-node counts. A changed template requires deliberate remapping rather than a best-effort replacement.
  2. Copying the first run's properties preserves a paragraph's starting style while replacing its text. It also discards mixed-run distinctions, so this helper cannot claim full formatting fidelity for arbitrary paragraphs.
  3. The final archive is written through a temporary file and replaced, but that doesn't make the entire operation atomic. The patcher has already copied the reference to the output before checking its shape; a later failure can leave that copy behind.

HOW IT FITS TOGETHER

Architecture.

  • The builders establish page geometry and styles, then add sections and paragraphs through python-docx helpers. Where a reference document is used, the body can be cleared while retaining section properties, so new content can reuse the page setup.
  • Lower-level WordprocessingML handles details that need more control: bullet numbering, page-number fields, table grids, fixed widths and cell margins. These settings describe the document's layout explicitly rather than leaving all geometry to the editor that opens it.
  • One paragraph replacement helper finds the expected paragraph, copies the first run's properties and rebuilds the text. A missing paragraph stops the edit. Keeping that first style is useful for uniform text, but doesn't preserve every mixed bold or italic run in the original.
  • The archive patcher checks the reference hash before copying it, then verifies the document body and expected text-node counts. It changes document.xml, carries the other members and their metadata into a temporary DOCX, and replaces the output with that archive. The earlier reference copy is a separate write, so later validation failure can leave that copy at the destination.
Explore the architecture map8 components · 7 connections

Document composition and fixed-template patching

The utilities use separate paths for styled document construction and hash-checked edits to a reference DOCX.

Direct call
Local inputs
Python utilities
Document parts and files

Scroll or drag the background to move. Use the zoom buttons to resize.Arrow keys move between components. Enter selects.

Choose a component to explore

Select a numbered component on the map or use the component menu. Its details and connections will appear here.

No component selected.

All connections (7)
  1. 01 · Document content and layout parameters03 · python-docx compositionSupply content and layout · Direct call
  2. 02 · Reference DOCX03 · python-docx compositionLoad template where used · Direct call
  3. 03 · python-docx composition04 · WordprocessingML layout helpersApply low-level layout settings · Direct call
  4. 04 · WordprocessingML layout helpers07 · Composed DOCX outputSave structured document · Direct call
  5. 02 · Reference DOCX05 · Reference and text-shape checksVerify fixed reference · Direct call
  6. 05 · Reference and text-shape checks06 · Targeted document.xml editMatch replacement structure · Direct call
  7. 06 · Targeted document.xml edit08 · Rewritten DOCX archiveWrite archive and replace output · Direct call

MADE WITH

Python · python-docx · WordprocessingML · ZIP/XML

CHECKS & RESULTS

What was checked.

A source review shows what the code does. It is not a fresh test of the running app.

  1. Code and development records reviewedReviewed

    The code, tests and available development records were checked. Reported test results keep their original scope. No fresh app or live deployment check was run for this write-up.

    Scope of this check
    Code review, not a fresh run of the app

NEXT

Still to work through.

The scripts provide direct control over Word layout and narrow template edits, with checks tailored to particular documents. They are still separate utilities rather than a reusable validation library. Mixed formatting, cross-editor layout and the actual document content need review of the output; none is established by a matching template hash.