From: Fred Drake Date: Thu, 14 Jan 1999 21:18:03 +0000 (+0000) Subject: Make no longer an empty element but a container. The text X-Git-Tag: v1.5.2b2~337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d24167baf2571d9110863aa205032c5bba40804f;p=python Make no longer an empty element but a container. The text currently generated by the LaTeX and LaTeX2HTML processes is generated here as well, making it more flexible in the SGML version. Reduce the element so that goes away; just use square brackets to indicate what's optional. This makes it easier to read than the LaTeX, and the processor can do any checking it needs to in order to make sure it's legit. Possible shortcoming: DSSSL processors may need more explicit markup. Can probably hack around it for this case, but we'll see. --- diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py index 28cef8380f..d8434909a2 100755 --- a/Doc/tools/sgmlconv/docfixer.py +++ b/Doc/tools/sgmlconv/docfixer.py @@ -578,6 +578,46 @@ def skip_leading_nodes(children, start, i): return start, i +def fixup_rfc_references(doc): + rfc_nodes = [] + for child in doc.childNodes: + if child.nodeType == xml.dom.core.ELEMENT: + kids = child.getElementsByTagName("rfc") + for k in kids: + rfc_nodes.append(k) + for rfc_node in rfc_nodes: + rfc_node.appendChild(doc.createTextNode( + "RFC " + rfc_node.getAttribute("num"))) + + +def fixup_signatures(doc): + for child in doc.childNodes: + if child.nodeType == xml.dom.core.ELEMENT: + args = child.getElementsByTagName("args") + for arg in args: + fixup_args(doc, arg) + args = child.getElementsByTagName("constructor-args") + for arg in args: + fixup_args(doc, arg) + arg.normalize() + + +def fixup_args(doc, arglist): + for child in arglist.childNodes: + if child.nodeType == xml.dom.core.ELEMENT \ + and child.tagName == "optional": + # found it; fix and return + arglist.insertBefore(doc.createTextNode("["), child) + optkids = child.childNodes + while optkids: + k = optkids[0] + child.removeChild(k) + arglist.insertBefore(k, child) + arglist.insertBefore(doc.createTextNode("]"), child) + arglist.removeChild(child) + return fixup_args(doc, arglist) + + _token_rx = re.compile(r"[a-zA-Z][a-zA-Z0-9.-]*$") def write_esis(doc, ofp, knownempty): @@ -638,10 +678,14 @@ def convert(ifp, ofp): "lineiv": ("row", {}), }) fixup_table_structures(doc) + fixup_rfc_references(doc) + fixup_signatures(doc) # d = {} for gi in p.get_empties(): d[gi] = gi + if d.has_key("rfc"): + del d["rfc"] knownempty = d.has_key # try: