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

Method _new_comment_reference_run

src/docx/oxml/text/run.py:149–164  ·  view source on GitHub ↗

Return a new `w:r` element with `w:commentReference` referencing `comment_id`. Should look like this:

(self, comment_id: int)

Source from the content-addressed store, hash-verified

147 return rPr
148
149 def _new_comment_reference_run(self, comment_id: int) -> CT_R:
150 """Return a new `w:r` element with `w:commentReference` referencing `comment_id`.
151
152 Should look like this:
153
154 <w:r>
155 <w:rPr><w:rStyle w:val="CommentReference"/></w:rPr>
156 <w:commentReference w:id="0"/>
157 </w:r>
158
159 """
160 r = cast(CT_R, OxmlElement("w:r"))
161 rPr = r.get_or_add_rPr()
162 rPr.style = "CommentReference"
163 r.append(OxmlElement("w:commentReference", attrs={qn("w:id"): str(comment_id)}))
164 return r
165
166
167# ------------------------------------------------------------------------------------

Calls 3

OxmlElementFunction · 0.90
qnFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected