MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / reply_to_comment

Method reply_to_comment

docx/scripts/document.py:765–831  ·  view source on GitHub ↗

Add a reply to an existing comment. Args: parent_comment_id: The w:id of the parent comment to reply to text: Reply text Returns: The comment ID that was created for the reply Example: cm.reply_to_comment(parent_comm

(
        self,
        parent_comment_id: int,
        text: str,
    )

Source from the content-addressed store, hash-verified

763 return comment_id
764
765 def reply_to_comment(
766 self,
767 parent_comment_id: int,
768 text: str,
769 ) -> int:
770 """
771 Add a reply to an existing comment.
772
773 Args:
774 parent_comment_id: The w:id of the parent comment to reply to
775 text: Reply text
776
777 Returns:
778 The comment ID that was created for the reply
779
780 Example:
781 cm.reply_to_comment(parent_comment_id=0, text="I agree with this change")
782 """
783 if parent_comment_id not in self.existing_comments:
784 raise ValueError(f"Parent comment with id={parent_comment_id} not found")
785
786 parent_info = self.existing_comments[parent_comment_id]
787 comment_id = self.next_comment_id
788 para_id = _generate_hex_id()
789 durable_id = _generate_hex_id()
790 timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
791
792 # Add comment ranges to document.xml immediately
793 parent_start_elem = self._document.get_node(
794 tag="w:commentRangeStart", attrs={"w:id": str(parent_comment_id)}
795 )
796 parent_ref_elem = self._document.get_node(
797 tag="w:commentReference", attrs={"w:id": str(parent_comment_id)}
798 )
799
800 self._document.insert_after(
801 parent_start_elem, self._comment_range_start_xml(comment_id)
802 )
803 parent_ref_run = parent_ref_elem.parentNode
804 self._document.insert_after(
805 parent_ref_run, f'<w:commentRangeEnd w:id="{comment_id}"/>'
806 )
807 self._document.insert_after(
808 parent_ref_run, self._comment_ref_run_xml(comment_id)
809 )
810
811 # Add to comments.xml immediately
812 self._add_to_comments_xml(
813 comment_id, para_id, text, self.author, self.initials, timestamp
814 )
815
816 # Add to commentsExtended.xml immediately (with parent)
817 self._add_to_comments_extended_xml(
818 para_id, parent_para_id=parent_info["para_id"]
819 )
820
821 # Add to commentsIds.xml immediately
822 self._add_to_comments_ids_xml(para_id, durable_id)

Callers

nothing calls this directly

Calls 9

_comment_ref_run_xmlMethod · 0.95
_add_to_comments_xmlMethod · 0.95
_generate_hex_idFunction · 0.85
get_nodeMethod · 0.80
insert_afterMethod · 0.45

Tested by

no test coverage detected