[Python-checkins] bpo-13743: Add some documentation strings to xml.dom.minidom (GH-16355)

Alex Itkes webhook-mailer at python.org
Sun Apr 12 10:22:06 EDT 2020


https://github.com/python/cpython/commit/63e5b59c06fc99f95d274e7f181296e094cc3ee7
commit: 63e5b59c06fc99f95d274e7f181296e094cc3ee7
branch: master
author: Alex Itkes <38556752+alexitkes at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-04-12T16:21:58+02:00
summary:

bpo-13743: Add some documentation strings to xml.dom.minidom (GH-16355)

files:
A Misc/NEWS.d/next/Documentation/2019-09-25-23-20-55.bpo-13743.5ToLDy.rst
M Lib/xml/dom/minidom.py

diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 1083b48138710..d09ef5e7d0371 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -719,6 +719,14 @@ def unlink(self):
         Node.unlink(self)
 
     def getAttribute(self, attname):
+        """Returns the value of the specified attribute.
+
+        Returns the value of the element's attribute named attname as
+        a string. An empty string is returned if the element does not
+        have such an attribute. Note that an empty string may also be
+        returned as an explicitly given attribute value, use the
+        hasAttribute method to distinguish these two cases.
+        """
         if self._attrs is None:
             return ""
         try:
@@ -829,6 +837,11 @@ def removeAttributeNode(self, node):
     removeAttributeNodeNS = removeAttributeNode
 
     def hasAttribute(self, name):
+        """Checks whether the element has an attribute with the specified name.
+
+        Returns True if the element has an attribute with the specified name.
+        Otherwise, returns False.
+        """
         if self._attrs is None:
             return False
         return name in self._attrs
@@ -839,6 +852,11 @@ def hasAttributeNS(self, namespaceURI, localName):
         return (namespaceURI, localName) in self._attrsNS
 
     def getElementsByTagName(self, name):
+        """Returns all descendant elements with the given tag name.
+
+        Returns the list of all descendant elements (not direct children
+        only) with the specified tag name.
+        """
         return _get_elements_by_tagName_helper(self, name, NodeList())
 
     def getElementsByTagNameNS(self, namespaceURI, localName):
@@ -849,6 +867,11 @@ def __repr__(self):
         return "<DOM Element: %s at %#x>" % (self.tagName, id(self))
 
     def writexml(self, writer, indent="", addindent="", newl=""):
+        """Write an XML element to a file-like object
+
+        Write the element to the writer object that must provide
+        a write method (e.g. a file or StringIO object).
+        """
         # indent = current indentation
         # addindent = indentation to add to higher levels
         # newl = newline string
diff --git a/Misc/NEWS.d/next/Documentation/2019-09-25-23-20-55.bpo-13743.5ToLDy.rst b/Misc/NEWS.d/next/Documentation/2019-09-25-23-20-55.bpo-13743.5ToLDy.rst
new file mode 100644
index 0000000000000..02dc4331a1251
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-09-25-23-20-55.bpo-13743.5ToLDy.rst
@@ -0,0 +1 @@
+Some methods within xml.dom.minidom.Element class are now better documented.



More information about the Python-checkins mailing list