Skip to main content

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.

Python 3.12+ License: Apache 2.0 PyPI version GitHub stars

简体中文


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):


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

docxnote-0.3.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docxnote-0.3.1-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file docxnote-0.3.1.tar.gz.

File metadata

  • Download URL: docxnote-0.3.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docxnote-0.3.1.tar.gz
Algorithm Hash digest
SHA256 181103d9cb9e1a815a6d448e89aba3022ece2c69ef48d043948271532c30e9c5
MD5 6019a58bb6effcb015b75c0337dc163c
BLAKE2b-256 8a8510a0f8e5846e270f36437e629555c03e96d100c0258b5594222c60cb25bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for docxnote-0.3.1.tar.gz:

Publisher: publish.yml on touken928/docxnote

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docxnote-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: docxnote-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docxnote-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33ec5e4f1652e135642fdecb202f56a4fe737a56dfb2e89ff86f9e319e40ce3a
MD5 29ee6f187b45c472b8adce823c3ad739
BLAKE2b-256 1eaf2fdd3e58d6b7eddfe6d8a0fc6b185db28f15b40db59be45481b5609a88d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for docxnote-0.3.1-py3-none-any.whl:

Publisher: publish.yml on touken928/docxnote

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page