@@ -28,18 +28,18 @@ package inspection, configurable fingerprints, repair, or low-level package and
2828
2929| Capability | Status | Primary API |
3030| --- | --- | --- |
31- | Documents, paragraphs, tables, styles, sections, headers, and footers | Stable | ` Document() ` and document object APIs |
32- | Custom document properties | Stable | ` document.custom_properties ` |
33- | Custom XML lifecycle | Stable | ` add_custom_xml_part() ` , ` delete_custom_xml_part() ` |
34- | SVG and EMF images | Stable | ` add_picture() ` |
35- | Inline and floating pictures | Stable | ` add_picture() ` , ` add_float_picture() ` |
36- | Latin and East Asian font controls | Stable | ` run.font.name ` , ` run.font.hAnsi ` , ` run.font.eastAsia ` |
37- | Low-level OPC parts and relationships | Stable | ` document.part.package ` , ` part.rels ` |
38- | In-memory read, export, and independent copies | Stable | ` Document() ` , ` to_bytes() ` , ` copy() ` |
39- | Document sanitization | Stable | ` document.sanitize() ` |
40- | Read-only package inspection and streaming feature scanning | Stable | ` inspect() ` , ` ScanEvent ` |
41- | Configurable package-content fingerprints | Stable | ` fingerprint() ` , ` FingerprintPolicy ` , ` serialize_xml ` |
42- | Explicit empty Custom XML repair and hyperlink normalization | Stable | ` repair() ` , ` normalize() ` |
31+ | [ Documents, paragraphs, tables, styles, sections, headers, and footers] ( docs/user/quickstart.rst ) | Stable | ` Document() ` and document object APIs |
32+ | [ Custom document properties] ( docs/user/custom-properties.rst ) | Stable | ` document.custom_properties ` |
33+ | [ Custom XML lifecycle] ( docs/user/custom-xml.rst ) | Stable | ` add_custom_xml_part() ` , ` delete_custom_xml_part() ` |
34+ | [ SVG and EMF images] ( docs/user/shapes.rst ) | Stable | ` add_picture() ` |
35+ | [ Inline and floating pictures] ( docs/user/shapes.rst ) | Stable | ` add_picture() ` , ` add_float_picture() ` |
36+ | [ Latin and East Asian font controls] ( docs/user/text.rst ) | Stable | ` run.font.name ` , ` run.font.hAnsi ` , ` run.font.eastAsia ` |
37+ | [ Low-level OPC parts and relationships] ( docs/user/api-concepts.rst ) | Stable | ` document.part.package ` , ` part.rels ` |
38+ | [ In-memory read, export, and independent copies] ( docs/user/documents.rst ) | Stable | ` Document() ` , ` to_bytes() ` , ` copy() ` |
39+ | [ Document sanitization] ( docs/user/sanitization.rst ) | Stable | ` document.sanitize() ` |
40+ | [ Read-only package inspection and streaming feature scanning] ( docs/user/inspection.rst ) | Stable | ` inspect() ` , ` ScanEvent ` |
41+ | [ Configurable package-content fingerprints] ( docs/user/inspection.rst#content-fingerprints ) | Stable | ` fingerprint() ` , ` FingerprintPolicy ` , ` serialize_xml ` |
42+ | [ Explicit empty Custom XML repair and hyperlink normalization] ( docs/user/transformations.rst ) | Stable | ` repair() ` , ` normalize() ` |
4343| Package and semantic diff | Planned | — |
4444
4545## Installation
@@ -92,42 +92,25 @@ document.save("output.docx")
9292
9393### Package inspection and fingerprints
9494
95- Inspect damaged documents before opening them, stream story elements with caller predicates,
96- and compute reproducible content fingerprints without loading media payloads:
95+ Inspect damaged documents before opening them, and compute reproducible content fingerprints
96+ without loading media payloads:
9797
9898``` python
99- from docx import FingerprintItem, FingerprintPolicy, fingerprint, inspect
99+ from docx import FingerprintPolicy, fingerprint, inspect
100100
101- # 1. Structural inspection and finding detection
102101report = inspect(" input.docx" )
103102for finding in report.findings:
104103 print (finding.code, finding.partname)
105104
106- # 2. Streaming story query with early exit
107- def find_bookmark (event ):
108- return event.kind == " start" and event.tag.endswith(" }bookmarkStart" )
109-
110- query = inspect(" input.docx" , predicate = find_bookmark, stop_on_match = True )
111- if query.matched:
112- print (" Found bookmark; scan complete:" , query.scan_complete)
113-
114- # 3. Content fingerprints with part and native XML exclusions
115- def exclude_item (item : FingerprintItem) -> bool :
116- if item.kind == " part" :
117- return item.part_name.startswith(" docProps/" )
118- return item.tag == " {http: //schemas.openxmlformats.org/wordprocessingml/2006/main} bookmarkStart"
119-
120- policy = FingerprintPolicy(exclude = exclude_item)
121- digest = fingerprint(" input.docx" , policy = policy)
105+ digest = fingerprint(" input.docx" , policy = FingerprintPolicy(exclude_parts = (" docProps/*" ,)))
122106```
123107
124- These APIs leave inputs unchanged and restore seekable stream positions. ` inspect() ` can
125- inventory package members, detect structural damage, or stream story XML elements using
126- caller-defined predicates without loading media payloads. Fingerprints ignore ZIP metadata
127- and member ordering, ignore indentation in schema-derived Word and DrawingML structures
128- via C14N 2.0 (fingerprint v3), and support selective part and XML element exclusions.
129- See [ Package inspection and fingerprints] ( docs/user/inspection.rst ) for finding codes,
130- XML comparison semantics, and policy rules.
108+ These APIs leave inputs unchanged and restore seekable stream positions without loading
109+ media payloads. ` inspect() ` supports structural inventory, damage detection, and streaming
110+ story XML queries with caller-defined predicates. ` fingerprint() ` normalizes structural
111+ indentation (C14N 2.0 / fingerprint v3) and supports selective exclusions. See
112+ [ Package inspection and fingerprints] ( docs/user/inspection.rst ) for finding codes, streaming
113+ queries, and policy rules.
131114
132115### Explicit repair and normalization
133116
@@ -136,19 +119,14 @@ from docx import normalize, repair
136119
137120repaired = repair(source_bytes, empty_custom_xml = True )
138121if repaired.report.succeeded:
139- normalized = normalize(
140- repaired.content,
141- hyperlink_fields = True ,
142- hyperlink_runs = True ,
143- )
122+ normalized = normalize(repaired.content, hyperlink_fields = True , hyperlink_runs = True )
144123 if normalized.report.succeeded:
145124 output_bytes = normalized.content
146125```
147126
148127Operations are disabled by default and transactional: validation failures return the
149- original bytes. Hyperlink normalization safely converts simple or complex fields while
150- isolating text box boundaries, preserving proofing markers, and supporting caller
151- selection callbacks (` select_hyperlink ` ). See
128+ original bytes. Hyperlink normalization converts field codes into native ` w:hyperlink `
129+ elements while preserving text box boundaries and proofing markers. See
152130[ Repair and normalization] ( docs/user/transformations.rst ) for supported structures,
153131selection callbacks, and preservation rules.
154132
0 commit comments