API/Document

Data Objects

Document

Read the path, frontmatter, body, and raw bytes of a Markdown document in a Package.

Document is the immutable view returned when a knowledge document is read from an OCTX Package. It preserves both the parsed Markdown content and the original bytes referenced by the manifest digest.

Getting the object

OctxPackage.iter_documents() yields Document objects in Package path order:

python
from octx import open_octx

with open_octx("product-guide.octx") as package:
    for document in package.iter_documents():
        print(document.path, document.metadata.get("title"))

Fields

FieldPurpose
pathMarkdown path inside the Package.
metadataRead-only YAML frontmatter mapping.
bodyMarkdown with the frontmatter and optional UTF-8 BOM removed.
rawOriginal bytes referenced by the manifest digest.

Read boundaries

Document is read-only and never writes modifications back to the Package. Use raw when you need to preserve the original content or recompute a digest. Use body and metadata when displaying, retrieving, or parsing the document content.