]> granicus.if.org Git - python/commitdiff
Cleanup the docs ElementTree a bit.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 13 Jan 2013 20:24:27 +0000 (22:24 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 13 Jan 2013 20:24:27 +0000 (22:24 +0200)
1  2 
Doc/library/xml.etree.elementtree.rst
Lib/xml/etree/ElementTree.py

index 88855d952fa8effa3e5d52a7ddf8796c28f702b8,144e344397abd5fdba382a795f81ad460924822c..2a9f9b30b050f4e1ae677c18b2406c7a8b00658b
@@@ -428,23 -428,17 +428,23 @@@ Function
     arguments.  Returns an element instance.
  
  
- .. function:: tostring(element, encoding="us-ascii", method="xml", *,\
 -.. function:: tostring(element, encoding="us-ascii", method="xml")
++.. function:: tostring(element, encoding="us-ascii", method="xml", *, \
 +                       short_empty_elements=True)
  
     Generates a string representation of an XML element, including all
     subelements.  *element* is an :class:`Element` instance.  *encoding* [1]_ is
     the output encoding (default is US-ASCII).  Use ``encoding="unicode"`` to
     generate a Unicode string (otherwise, a bytestring is generated).  *method*
     is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``).
 +   *short_empty_elements* has the same meaning as in :meth:`ElementTree.write`.
     Returns an (optionally) encoded string containing the XML data.
  
 +   .. versionadded:: 3.4
 +      The *short_empty_elements* parameter.
  
 -.. function:: tostringlist(element, encoding="us-ascii", method="xml")
 +
- .. function:: tostringlist(element, encoding="us-ascii", method="xml", *,\
++.. function:: tostringlist(element, encoding="us-ascii", method="xml", *, \
 +                           short_empty_elements=True)
  
     Generates a string representation of an XML element, including all
     subelements.  *element* is an :class:`Element` instance.  *encoding* [1]_ is
@@@ -751,9 -741,8 +751,9 @@@ ElementTree Object
        section root element.
  
  
-    .. method:: write(file, encoding="us-ascii", xml_declaration=None,\
-                      default_namespace=None, method="xml", *,\
+    .. method:: write(file, encoding="us-ascii", xml_declaration=None, \
 -                     default_namespace=None, method="xml")
++                     default_namespace=None, method="xml", *, \
 +                     short_empty_elements=True)
  
        Writes the element tree to a file, as XML.  *file* is a file name, or a
        :term:`file object` opened for writing.  *encoding* [1]_ is the output
        *xml_declaration* controls if an XML declaration should be added to the
        file.  Use ``False`` for never, ``True`` for always, ``None``
        for only if not US-ASCII or UTF-8 or Unicode (default is ``None``).
+       *default_namespace* sets the default XML namespace (for "xmlns").
        *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is
-       ``"xml"``). *default_namespace* sets the default XML namespace (for
-       "xmlns").
+       ``"xml"``).
 +      The keyword-only *short_empty_elements* parameter controls the formatting
 +      of elements that contain no content.  If *True* (the default), they are
 +      emitted as a single self-closed tag, otherwise they are emitted as a pair
 +      of start/end tags.
  
        The output is either a string (:class:`str`) or binary (:class:`bytes`).
        This is controlled by the *encoding* argument.  If *encoding* is
index eab0a4fa3f88ddd68619def66fe09597c43844c7,e8e309c3a0436e076fdb70332f3b5a27d6a498be..85cab2b17b50a7f1f8382179a8d95dae9f10406b
@@@ -783,22 -800,7 +783,22 @@@ class ElementTree
                encoding=None,
                xml_declaration=None,
                default_namespace=None,
 -              method=None):
 +              method=None, *,
 +              short_empty_elements=True):
-         """Write the element tree to a file, as XML. 'file_or_filename' is a
-            file name or a file object opened for writing. 'encoding' is the
-            output encoding (default is US-ASCII). 'xml_declaration' controls
-            if an XML declaration should be added to the output. Use False
-            for never, True for always, None for only if not US-ASCII or
-            UTF-8 or Unicode (default is None). 'method' is either "xml"
-            (default), "html", "text" or "c14n".
++        """Write the element tree to a file, as XML.  'file_or_filename' is a
++           file name or a file object opened for writing.
++           'encoding' is the output encoding (default is US-ASCII).
++           'xml_declaration' controls if an XML declaration should be added
++           to the output.  Use False for never, True for always, None for only
++           if not US-ASCII or UTF-8 or Unicode (default is None).
 +           'default_namespace' sets the default XML namespace (for "xmlns").
++           'method' is either "xml" (default), "html", "text" or "c14n".
 +           The keyword-only 'short_empty_elements' parameter controls the
-            formatting of elements that contain no content. If True (default),
++           formatting of elements that contain no content.  If True (default),
 +           they are emitted as a single self-closed tag, otherwise they are
 +           emitted as a pair of start/end tags.
 +
 +        """
          if not method:
              method = "xml"
          elif method not in _serialize: