Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d24167b

Browse files
committed
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.
1 parent e75888e commit d24167b

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Doc/tools/sgmlconv/docfixer.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,46 @@ def skip_leading_nodes(children, start, i):
578578
return start, i
579579

580580

581+
def fixup_rfc_references(doc):
582+
rfc_nodes = []
583+
for child in doc.childNodes:
584+
if child.nodeType == xml.dom.core.ELEMENT:
585+
kids = child.getElementsByTagName("rfc")
586+
for k in kids:
587+
rfc_nodes.append(k)
588+
for rfc_node in rfc_nodes:
589+
rfc_node.appendChild(doc.createTextNode(
590+
"RFC " + rfc_node.getAttribute("num")))
591+
592+
593+
def fixup_signatures(doc):
594+
for child in doc.childNodes:
595+
if child.nodeType == xml.dom.core.ELEMENT:
596+
args = child.getElementsByTagName("args")
597+
for arg in args:
598+
fixup_args(doc, arg)
599+
args = child.getElementsByTagName("constructor-args")
600+
for arg in args:
601+
fixup_args(doc, arg)
602+
arg.normalize()
603+
604+
605+
def fixup_args(doc, arglist):
606+
for child in arglist.childNodes:
607+
if child.nodeType == xml.dom.core.ELEMENT \
608+
and child.tagName == "optional":
609+
# found it; fix and return
610+
arglist.insertBefore(doc.createTextNode("["), child)
611+
optkids = child.childNodes
612+
while optkids:
613+
k = optkids[0]
614+
child.removeChild(k)
615+
arglist.insertBefore(k, child)
616+
arglist.insertBefore(doc.createTextNode("]"), child)
617+
arglist.removeChild(child)
618+
return fixup_args(doc, arglist)
619+
620+
581621
_token_rx = re.compile(r"[a-zA-Z][a-zA-Z0-9.-]*$")
582622

583623
def write_esis(doc, ofp, knownempty):
@@ -638,10 +678,14 @@ def convert(ifp, ofp):
638678
"lineiv": ("row", {}),
639679
})
640680
fixup_table_structures(doc)
681+
fixup_rfc_references(doc)
682+
fixup_signatures(doc)
641683
#
642684
d = {}
643685
for gi in p.get_empties():
644686
d[gi] = gi
687+
if d.has_key("rfc"):
688+
del d["rfc"]
645689
knownempty = d.has_key
646690
#
647691
try:

0 commit comments

Comments
 (0)