MCPcopy Index your code
hub / github.com/python-openxml/python-docx / add_paragraph

Method add_paragraph

src/docx/comments.py:101–115  ·  view source on GitHub ↗

Return paragraph newly added to the end of the content in this container. The paragraph has `text` in a single run if present, and is given paragraph style `style`. When `style` is |None| or ommitted, the "CommentText" paragraph style is applied, which is the default style f

(self, text: str = "", style: str | ParagraphStyle | None = None)

Source from the content-addressed store, hash-verified

99 self._comment_elm = comment_elm
100
101 def add_paragraph(self, text: str = "", style: str | ParagraphStyle | None = None) -> Paragraph:
102 """Return paragraph newly added to the end of the content in this container.
103
104 The paragraph has `text` in a single run if present, and is given paragraph style `style`.
105 When `style` is |None| or ommitted, the "CommentText" paragraph style is applied, which is
106 the default style for comments.
107 """
108 paragraph = super().add_paragraph(text, style)
109
110 # -- have to assign style directly to element because `paragraph.style` raises when
111 # -- a style is not present in the styles part
112 if style is None:
113 paragraph._p.style = "CommentText" # pyright: ignore[reportPrivateUsage]
114
115 return paragraph
116
117 @property
118 def author(self) -> str:

Callers 1

add_commentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected