Comment
paper-docx 0.2.0 API reference
Proxy for a single comment in the document.
Reads author, initials, date and body content, and adds paragraphs or tables. Every mutation revalidates that the comment is still live first, so a proxy whose part was removed or replaced refuses instead of writing into a detached tree.
Comment(comment_elm: CT_Comment, comments_part: CommentsPart)Attributes
author
attributeauthorstrRead/write. The recorded author of this comment.
This field is required but can be set to the empty string.
comment_id
attributecomment_idintThe unique identifier of this comment.
initials
attributeinitialsstr | NoneRead/write. The recorded initials of the comment author.
This attribute is optional in the XML, returns None if not set. Assigning None removes
any existing initials from the XML.
paragraphs
attributeparagraphsA list containing the paragraphs in this container, in document order.
Read-only.
part
attributepartStoryPartThe package part containing this object.
tables
attributetablesA list containing the tables in this container, in document order.
Read-only.
text
attributetextstrThe text content of this comment as a string.
Only content in paragraphs is included and of course all emphasis and styling is stripped.
Paragraph boundaries are indicated with a newline ("\\n")
timestamp
attributetimestampdt.datetime | NoneThe date and time this comment was authored.
This attribute is optional in the XML, returns None if not set.
Functions
add_paragraph
funcadd_paragraph(text: str = '', style: str | ParagraphStyle | None = None) -> ParagraphAppend a paragraph to this comment's body and return it.
Re-keys the comment's commentEx, its replies' paraIdParent, and its commentsIds row
onto the new last paragraph, so appending rewrites thread and resolution state. Refuses a
protected document, and a proxy whose part was removed or replaced.
paramtextstr= ''paramstylestr | ParagraphStyle | None= NoneReturns
docx.text.paragraph.Paragraphadd_table
funcadd_table(rows: int, cols: int, width: Length) -> TableAppend a table to this comment's body and return it.
Re-keys thread and resolution state onto the new last paragraph, as add_paragraph does.
Refuses a protected document, and a proxy whose part was removed or replaced.
paramrowsintparamcolsintparamwidthLengthReturns
docx.table.Tableiter_inner_content
funciter_inner_content() -> Iterator[Paragraph | Table]Generate each Paragraph or Table in this container in document order.
Returns
typing.Iterator[docx.text.paragraph.Paragraph | docx.table.Table]