Lightweight DOCX comment engine based on text view API
Project description
Docxnote
Lightweight DOCX comment engine: add and read Word comments from plain paragraph text, with only an lxml dependency.
Overview
docxnote automates Word comments (annotations) without touching runs: you traverse Paragraph / Table / Cell, call paragraph.comment(...), and optionally read comments via paragraph.comments and doc.comments().
Repository: touken928/docxnote
Installation
pip install docxnote
With uv:
uv add docxnote
Quick start
from docxnote import DocxDocument, Paragraph, Table
# Load document
with open("document.docx", "rb") as f:
# By default existing comments are discarded
doc = DocxDocument.parse(f.read())
# To keep existing comments and add more:
# doc = DocxDocument.parse(f.read(), keep_comments=True)
# Walk block-level content
for block in doc.blocks():
if isinstance(block, Paragraph):
if block.text:
block.comment("Please review wording", end=5, author="reviewer")
elif isinstance(block, Table):
rows, cols = block.shape()
for r in range(rows):
for c in range(cols):
cell = block[r, c]
for inner in cell.blocks():
if isinstance(inner, Paragraph) and inner.text:
inner.comment("Needs review", end=3, author="reviewer")
# Write output
output = doc.render()
with open("output.docx", "wb") as f:
f.write(output)
CLI
Installing docxnote adds a console script of the same name. Every read
command supports --json, every write command takes an explicit output path,
and they all share the library's addressable paths (p:0, t:0/r:1/c:2/p:0,
p:0#3, ...).
docxnote list input.docx --text --json
docxnote show input.docx "t:0/r:1/c:2/p:0"
docxnote comments input.docx --json
docxnote annotate input.docx output.docx --path p:0 --text "please revise"
docxnote annotate input.docx output.docx --spec ops.json --keep-comments
Full reference: docs/CLI.md · docs/CLI_zh.md.
Documentation
Full Python API (methods, parameters, comments, paths, tables, and advanced patterns):
- docs/API.md — English
- docs/API_zh.md — 简体中文
- docs/CLI.md / docs/CLI_zh.md — CLI reference
Index: docs/README.md.
Tests
Test documents are generated with python-docx; no checked-in DOCX fixtures. See tests/README.md.
SKILL
Agent-oriented docs live under skills in github.com/touken928/docxnote. To mirror them under .cursor/, .claude/, or similar, tell your coding agent to use that repository’s skills folder and let it copy or fetch as needed.
License
Licensed under the Apache License, Version 2.0. See LICENSE in the repository root.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docxnote-0.3.0.tar.gz.
File metadata
- Download URL: docxnote-0.3.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b03817540fd290599dacad15f8d56b484072bf0b81be6f2b287939ceb96cfb
|
|
| MD5 |
8dbb4cc0db3e98d291336adf26e4732c
|
|
| BLAKE2b-256 |
4cf4ed62afd041a6da553288002d1960265ab049231004fb3e3af2f015f0a899
|
Provenance
The following attestation bundles were made for docxnote-0.3.0.tar.gz:
Publisher:
publish.yml on touken928/docxnote
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docxnote-0.3.0.tar.gz -
Subject digest:
24b03817540fd290599dacad15f8d56b484072bf0b81be6f2b287939ceb96cfb - Sigstore transparency entry: 1355801383
- Sigstore integration time:
-
Permalink:
touken928/docxnote@47f600fc2d2b50d9d9a7b761a23a20038e7c85e8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/touken928
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47f600fc2d2b50d9d9a7b761a23a20038e7c85e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file docxnote-0.3.0-py3-none-any.whl.
File metadata
- Download URL: docxnote-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3153fbb05fea23beaad65b53dc9013cea1b40970bb098f1cd5bcfcd594602c68
|
|
| MD5 |
901190b367f3abae21b80616d56d3e11
|
|
| BLAKE2b-256 |
2c3ec68ddb0c3673fb3c6146bcddff994d3681bb43c00f8438bb6506049af54f
|
Provenance
The following attestation bundles were made for docxnote-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on touken928/docxnote
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docxnote-0.3.0-py3-none-any.whl -
Subject digest:
3153fbb05fea23beaad65b53dc9013cea1b40970bb098f1cd5bcfcd594602c68 - Sigstore transparency entry: 1355801394
- Sigstore integration time:
-
Permalink:
touken928/docxnote@47f600fc2d2b50d9d9a7b761a23a20038e7c85e8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/touken928
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47f600fc2d2b50d9d9a7b761a23a20038e7c85e8 -
Trigger Event:
push
-
Statement type: