docx_plus.revisions.read¶
Enumerate every tracked change in a document — run-level insertions and
deletions, move source/destination wrappers, run- and paragraph-property
changes, and paragraph-mark insertions/deletions — each paired with its id,
author, timestamp, type, and affected text. Insertion text is read from
<w:t>, deletion text from <w:delText>.
docx_plus.revisions.read ¶
Enumerate every tracked change in a document.
Inverse of :func:docx_plus.revisions.mark_insertion /
:func:~docx_plus.revisions.mark_deletion, and the reader for revision
marks Word itself authored: walks the document body once and reports every
w:ins, w:del, w:moveFrom / w:moveTo, w:rPrChange, and
w:pPrChange with its id, author, timestamp, type, and affected text.
Run text inside revision wrappers is invisible to python-docx's
paragraph.runs, so all text is read through our own XPath — insertions
from <w:t> and deletions from <w:delText>.
This module imports only from docx_plus.core (SPEC §9.1).
RevisionType
module-attribute
¶
RevisionType = Literal[
"insertion",
"deletion",
"move_from",
"move_to",
"format_run",
"format_paragraph",
"paragraph_mark_insertion",
"paragraph_mark_deletion",
]
TrackedChange
dataclass
¶
TrackedChange(
revision_id: int,
revision_type: RevisionType,
author: str,
timestamp: datetime | None,
text: str,
paragraph_index: int,
)
One revision mark paired with the text it affects.
Attributes:
| Name | Type | Description |
|---|---|---|
revision_id |
int
|
The |
revision_type |
RevisionType
|
One of the :data: |
author |
str
|
The |
timestamp |
datetime | None
|
The |
text |
str
|
For insertions, the inserted |
paragraph_index |
int
|
Zero-based index (within |
read_revisions ¶
Return every tracked change in doc in document order.
Enumerates run-level insertions/deletions, move source/destination
wrappers, run- and paragraph-property changes, and paragraph-mark
insertions/deletions. Move range markers (the bookmark-like
*RangeStart / *RangeEnd delimiters) are not reported as separate
entries — the w:moveFrom / w:moveTo wrapper that carries the
moved text and metadata is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The python-docx :class: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[TrackedChange]
|
class: |
list[TrackedChange]
|
Returns |