Skip to content

gh-128508: Add some docstrings to xml.dom.minidom #128477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
21bb374
Update and Add docstrings for functions and methods in minidom.py module
srinivasreddy Jan 4, 2025
f16761b
Update Lib/xml/dom/minidom.py
srinivasreddy Jan 6, 2025
eb0208b
Update Lib/xml/dom/minidom.py
srinivasreddy Jan 6, 2025
f4f6334
Update Lib/xml/dom/minidom.py
srinivasreddy Jan 6, 2025
70617ea
Add `check-readthedocs` pre-commit hook (#128453)
sobolevn Jan 4, 2025
90b344f
gh-128152: Argument Clinic: ignore pre-processor directives inside C …
erlend-aasland Jan 4, 2025
34c317a
GH-127381: pathlib ABCs: remove `PathBase.move()` and `move_into()` (…
barneygale Jan 4, 2025
5f7ba82
Docs: mark up json.dump() using parameter list (#128482)
erlend-aasland Jan 4, 2025
23d11be
pathlib tests: create `walk()` test hierarchy without using class und…
barneygale Jan 4, 2025
e6a8d38
gh-126719: Clarify math.fmod docs (#127741)
StanFromIreland Jan 4, 2025
1592145
Docs: amend json.dump() post gh-128482 (#128489)
erlend-aasland Jan 4, 2025
1a8ee69
gh-127954: Document PyObject_DelItemString (#127986)
rruuaanng Jan 4, 2025
61c3e8a
gh-127553: Remove outdated TODO comment in _pydatetime (#127564)
bombs-kim Jan 4, 2025
69f8e4b
gh-115765: Document and enforce Autoconf 2.72 requirement (#128502)
erlend-aasland Jan 4, 2025
7f767cd
gh-128437: Add `BOLT_COMMON_FLAGS` with `-update-debug-sections` (gh-…
zanieb Jan 5, 2025
2f8b072
gh-128137: Update PyASCIIObject to handle interned field with the ato…
corona10 Jan 5, 2025
539b638
gh-128504: Upgrade doctest to ubuntu-24.04 (#128506)
Damien-Chen Jan 5, 2025
a4c5f4f
Docs: fix `MessageDefect` references in email.policy docs (#128468)
koyuki7w Jan 5, 2025
c612744
gh-98188: Fix EmailMessage.get_payload to decode data when CTE value …
RanKKI Jan 6, 2025
b0a9129
Revert __repr__ change
srinivasreddy Jan 6, 2025
3f71f1f
Merge branch 'main' into gh-63882-doc_strings
srinivasreddy Jan 6, 2025
8b7ff8e
Update the docstring for _clone_node(...)
srinivasreddy Jan 6, 2025
afa51ef
Update docstring for cloneNode(...)
srinivasreddy Jan 6, 2025
14bb77e
Update docstrings for cloneNode(...)
srinivasreddy Jan 6, 2025
a4840f3
Convert doc string to imperative mode
srinivasreddy Jan 6, 2025
38be045
Update docstring as recommended by argument clinic
srinivasreddy Jan 6, 2025
cca0fda
Update docstring as recommended by argument clinic
srinivasreddy Jan 6, 2025
8df6795
Undo removing comment
srinivasreddy Jan 6, 2025
727af86
Update docstrings as it was done in argument clinic
srinivasreddy Jan 6, 2025
2da171f
Add space back
srinivasreddy Jan 6, 2025
ecb4a54
Update doc strings
srinivasreddy Jan 6, 2025
8b63730
Update Lib/xml/dom/minidom.py
srinivasreddy Jan 6, 2025
49a12e6
Update Lib/xml/dom/minidom.py
srinivasreddy Jan 6, 2025
298a20f
Merge branch 'main' into gh-63882-doc_strings
srinivasreddy Jan 16, 2025
b97d812
Address review comments
srinivasreddy Jan 16, 2025
19d245c
Update docstrings
srinivasreddy Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions Lib/xml/dom/minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@


class Node(xml.dom.Node):
"""Base class representing a node in the DOM tree.
Provides core properties and methods that all DOM nodes must implement.
"""
namespaceURI = None # this is non-null only for elements and attributes
parentNode = None
ownerDocument = None
Expand All @@ -44,6 +47,7 @@ def __bool__(self):
return True

def toxml(self, encoding=None, standalone=None):
"""Generate a string representation of a DOM."""
return self.toprettyxml("", "", encoding, standalone)

def toprettyxml(self, indent="\t", newl="\n", encoding=None,
Expand Down Expand Up @@ -80,6 +84,14 @@ def _get_lastChild(self):
return self.childNodes[-1]

def insertBefore(self, newChild, refChild):
"""Insert a new DOM Node before an existing Node.

newChild
The new node to insert
refChild
The existing node that will be the next sibling of newChild.
If None, newChild is appended to the end.
"""
if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
for c in tuple(newChild.childNodes):
self.insertBefore(c, refChild)
Expand Down Expand Up @@ -112,6 +124,7 @@ def insertBefore(self, newChild, refChild):
return newChild

def appendChild(self, node):
"""Append a child node to an existing node."""
if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
for c in tuple(node.childNodes):
self.appendChild(c)
Expand All @@ -129,6 +142,7 @@ def appendChild(self, node):
return node

def replaceChild(self, newChild, oldChild):
"""Replace child node *oldChild* with *newChild*."""
if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
refChild = oldChild.nextSibling
self.removeChild(oldChild)
Expand Down Expand Up @@ -161,6 +175,7 @@ def replaceChild(self, newChild, oldChild):
return oldChild

def removeChild(self, oldChild):
"""Remove an existing child."""
try:
self.childNodes.remove(oldChild)
except ValueError:
Expand All @@ -177,6 +192,12 @@ def removeChild(self, oldChild):
return oldChild

def normalize(self):
"""Transform this node into its normalized form.

Remove empty exclusive Text nodes and concatenate data of
remaining contiguous exclusive Text nodes into the first of
their nodes.
"""
L = []
for child in self.childNodes:
if child.nodeType == Node.TEXT_NODE:
Expand Down Expand Up @@ -204,6 +225,12 @@ def normalize(self):
self.childNodes[:] = L

def cloneNode(self, deep):
"""Create and return a duplicate of this node.

deep
If True, recursively clone this node's descendants.
If False, clone only this node.
"""
return _clone_node(self, deep, self.ownerDocument or self)

def isSupported(self, feature, version):
Expand Down Expand Up @@ -1341,6 +1368,12 @@ def _get_internalSubset(self):
return self.internalSubset

def cloneNode(self, deep):
"""Create and return a duplicate of this node.

deep
If True, recursively clone this node's descendants.
If False, clone only this node.
"""
if self.ownerDocument is None:
# it's ok
clone = DocumentType(None)
Expand Down Expand Up @@ -1903,9 +1936,15 @@ def renameNode(self, n, namespaceURI, name):


def _clone_node(node, deep, newOwnerDocument):
"""
Clone a node and give it the new owner document.
Called by Node.cloneNode and Document.importNode
"""Create and return a clone of a DOM node.

node
The DOM node to clone.
deep
If True, recursively clone the node's descendants.
If False, only clone the node itself.
newOwnerDocument
The document that will own the cloned node.
"""
if node.ownerDocument.isSameNode(newOwnerDocument):
operation = xml.dom.UserDataHandler.NODE_CLONED
Expand Down
Loading