Scaffold doced: OPC package I/O, XML core, AST model, locator model, reader, LLM contract

This commit is contained in:
doced builder
2026-09-08 03:33:01 +00:00
commit 8b53171913
29 changed files with 1868 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
"""Document loading: open a ``.docx`` package and parse it into a model.
This is the single choke point for reading a document. It opens the OPC
package and returns a :class:`~doced.ast.doc.DocumentModel` — the package plus
a parsed AST plus a locator index, ready for read + in-place mutation.
"""
from __future__ import annotations
from pathlib import Path
from ..ast.doc import DocumentModel
from ..package import (
NotAZipError,
Package,
PackageNotFound,
PackagePartMissing,
PartNotFoundError,
)
def open_document(path: str | Path) -> DocumentModel:
"""Open *path* and return a :class:`~doced.ast.doc.DocumentModel`.
Raises the package-level errors through so the CLI can map them to the
LLM contract's error codes.
"""
pkg = Package.open(path)
return DocumentModel(pkg)
__all__ = [
"open_document",
"PackageNotFound",
"PartNotFoundError",
"PackagePartMissing",
"NotAZipError",
]