summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-11-23 21:52:03 (GMT)
committerFred Drake <fdrake@acm.org>1999-11-23 21:52:03 (GMT)
commit645af9fedd52b2ca1d96992ff63e3a8255a869c3 (patch)
treea80e20f640c4c779f688372257e967f5e6ac111e /Doc
parent8a3b4495df3a63f101171f7bac2d0a6d3b05a6f6 (diff)
downloadcpython-645af9fedd52b2ca1d96992ff63e3a8255a869c3.zip
cpython-645af9fedd52b2ca1d96992ff63e3a8255a869c3.tar.gz
cpython-645af9fedd52b2ca1d96992ff63e3a8255a869c3.tar.bz2
rewrite_descriptor(): Fixup conversion of arguments (simpler).
join_adjacent_elements(): Hack to merge adjacent instances of <option>; the source \programopt with GNU-style long options created problems with LaTeX2HTML; this removes the evil workaround, which should never be necessary from structured documents(!).
Diffstat (limited to 'Doc')
-rwxr-xr-xDoc/tools/sgmlconv/docfixer.py47
1 files changed, 35 insertions, 12 deletions
diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py
index 21d3522..9d99c63 100755
--- a/Doc/tools/sgmlconv/docfixer.py
+++ b/Doc/tools/sgmlconv/docfixer.py
@@ -236,18 +236,12 @@ def rewrite_descriptor(doc, descriptor):
pos = skip_leading_nodes(children)
if pos < len(children):
child = children[pos]
- if child.get_nodeName() == "args":
-## bwrite("found <args> in descriptor, moving to <signature>\n")
-## ewrite(descriptor.toxml() + "\n---\n")
- # create an <args> in <signature>:
- args = doc.createElement("args")
- argchildren = []
- map(argchildren.append, child.childNodes)
- for n in argchildren:
- child.removeChild(n)
- args.appendChild(n)
- signature.appendChild(doc.createTextNode("\n "))
- signature.appendChild(args)
+ if child.nodeName == "args":
+ # move <args> to <signature>, or remove if empty:
+ child.parentNode.removeChild(child)
+ if len(child.childNodes):
+ signature.appendChild(doc.createTextNode("\n "))
+ signature.appendChild(child)
signature.appendChild(doc.createTextNode("\n "))
# 3, 4.
pos = skip_leading_nodes(children, pos)
@@ -907,6 +901,32 @@ def fixup_bifuncindexes_chunk(container):
container.removeChild(entry)
+def join_adjacent_elements(container, gi):
+ queue = [container]
+ while queue:
+ parent = queue.pop()
+ i = 0
+ children = parent.get_childNodes()
+ nchildren = len(children)
+ while i < (nchildren - 1):
+ child = children[i]
+ if child.nodeName == gi:
+ if children[i+1].nodeName == gi:
+ ewrite("--- merging two <%s/> elements\n" % gi)
+ child = children[i]
+ nextchild = children[i+1]
+ nextchildren = nextchild.get_childNodes()
+ while len(nextchildren):
+ node = nextchildren[0]
+ nextchild.removeChild(node)
+ child.appendChild(node)
+ parent.removeChild(nextchild)
+ continue
+ if child.nodeType == ELEMENT:
+ queue.append(child)
+ i = i + 1
+
+
_token_rx = re.compile(r"[a-zA-Z][a-zA-Z0-9.-]*$")
def write_esis(doc, ofp, knownempty):
@@ -970,6 +990,9 @@ def convert(ifp, ofp):
add_node_ids(fragment)
fixup_refmodindexes(fragment)
fixup_bifuncindexes(fragment)
+ # Take care of ugly hacks in the LaTeX markup to avoid LaTeX and
+ # LaTeX2HTML screwing with GNU-style long options (the '--' problem).
+ join_adjacent_elements(fragment, "option")
#
d = {}
for gi in p.get_empties():