diff options
author | Fred Drake <fdrake@acm.org> | 1999-01-14 21:18:03 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-01-14 21:18:03 (GMT) |
commit | d24167baf2571d9110863aa205032c5bba40804f (patch) | |
tree | 35286b5b387730e71fd4a2c97c3edaf3dead5e75 /Doc | |
parent | e75888eb85489e025fb4a96bea280b8cc2da45f5 (diff) | |
download | cpython-d24167baf2571d9110863aa205032c5bba40804f.zip cpython-d24167baf2571d9110863aa205032c5bba40804f.tar.gz cpython-d24167baf2571d9110863aa205032c5bba40804f.tar.bz2 |
Make <rfc> 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 <args> element so that <optional> 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.
Diffstat (limited to 'Doc')
-rwxr-xr-x | Doc/tools/sgmlconv/docfixer.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py index 28cef83..d843490 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: |