ocrd_page: alias OcrdPage=PcGtsType, fix/add generateds docstrings
@@ -7,6 +7,7 @@ __all__ = [
'parse',
'parseEtree',
'parseString',
+ 'OcrdPage',
"AdvertRegionType",
"AlternativeImageType",
@@ -129,9 +130,56 @@ from .ocrd_page_generateds import (
from .constants import NAMESPACES
+# add docstrings
+parse.__doc__ = (
+ """Parse a file, create the object tree, and export it.
+
+ Arguments:
+ inFileName (str) -- Path to the PAGE-XML file.
+ print_warnings (boolean) -- If true, write parser \
+ warnings to stderr.
+
+ Returns:
+ The root object in the tree.
+ """
+)
+
+parseEtree.__doc__ = (
+ """Parse a file, create the object tree, and export it. Return tree and mappings, too.
+
+ Arguments:
+ inFileName (str) -- Path to the PAGE-XML file.
+ print_warnings (boolean) -- If true, write parser \
+ warnings to stderr.
+
+ Returns:
+ A tuple of
+ * The root object in the tree.
+ * The full node tree.
+ * A mapping from object IDs to tree nodes.
+ * A reverse mapping from tree nodes to object IDs.
+ """
+)
+
+# fix generated (malformed) docstrings
+parseString.__doc__ = (
+ """Parse a string, create the object tree, and export it.
+
+ Arguments:
+ inString (str) -- This XML fragment should not start \
+ with an XML declaration containing an encoding.
+
+ Returns:
+ The root object in the tree.
+ """
+)
+
+# add alias for DOM root
+OcrdPage = PcGtsType
+
def to_xml(el, skip_declaration=False):
"""
- Serialize ``pc:PcGts`` document
+ Serialize ``pc:PcGts`` document as string.
"""
# XXX remove potential empty ReadingOrder
if hasattr(el, 'prune_ReadingOrder'):
