Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1ff6db48
Commit
1ff6db48
authored
Nov 23, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some additional cleanup transformations.
parent
df12a593
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
Doc/tools/sgmlconv/docfixer.py
Doc/tools/sgmlconv/docfixer.py
+67
-0
No files found.
Doc/tools/sgmlconv/docfixer.py
View file @
1ff6db48
...
...
@@ -153,15 +153,82 @@ def handle_labels(doc):
parent
.
removeChild
(
label
)
def
fixup_trailing_whitespace
(
doc
,
wsmap
):
queue
=
[
doc
]
while
queue
:
node
=
queue
[
0
]
del
queue
[
0
]
if
node
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
\
and
wsmap
.
has_key
(
node
.
tagName
):
ws
=
wsmap
[
node
.
tagName
]
children
=
node
.
childNodes
children
.
reverse
()
if
children
[
0
].
nodeType
==
xml
.
dom
.
core
.
TEXT
:
data
=
string
.
rstrip
(
children
[
0
].
data
)
+
ws
children
[
0
].
data
=
data
children
.
reverse
()
# hack to get the title in place:
if
node
.
tagName
==
"title"
\
and
node
.
parentNode
.
firstChild
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
node
.
parentNode
.
insertBefore
(
doc
.
createText
(
"
\
n
"
),
node
.
parentNode
.
firstChild
)
for
child
in
node
.
childNodes
:
if
child
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
queue
.
append
(
child
)
def
normalize
(
doc
):
for
node
in
doc
.
childNodes
:
if
node
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
node
.
normalize
()
def
cleanup_trailing_parens
(
doc
,
element_names
):
d
=
{}
for
gi
in
element_names
:
d
[
gi
]
=
gi
rewrite_element
=
d
.
has_key
queue
=
[]
for
node
in
doc
.
childNodes
:
if
node
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
queue
.
append
(
node
)
while
queue
:
node
=
queue
[
0
]
del
queue
[
0
]
if
rewrite_element
(
node
.
tagName
):
children
=
node
.
childNodes
if
len
(
children
)
==
1
\
and
children
[
0
].
nodeType
==
xml
.
dom
.
core
.
TEXT
:
data
=
children
[
0
].
data
if
data
[
-
2
:]
==
"()"
:
children
[
0
].
data
=
data
[:
-
2
]
else
:
for
child
in
node
.
childNodes
:
if
child
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
queue
.
append
(
child
)
def
convert
(
ifp
,
ofp
):
p
=
xml
.
dom
.
esis_builder
.
EsisBuilder
()
p
.
feed
(
ifp
.
read
())
doc
=
p
.
document
normalize
(
doc
)
handle_args
(
doc
)
handle_comments
(
doc
)
simplify
(
doc
)
handle_labels
(
doc
)
fixup_trailing_whitespace
(
doc
,
{
"abstract"
:
"
\
n
"
,
"title"
:
""
,
"chapter"
:
"
\
n
\
n
"
,
"section"
:
"
\
n
\
n
"
,
"subsection"
:
"
\
n
\
n
"
,
"subsubsection"
:
"
\
n
\
n
"
,
"paragraph"
:
"
\
n
\
n
"
,
"subparagraph"
:
"
\
n
\
n
"
,
})
cleanup_root_text
(
doc
)
cleanup_trailing_parens
(
doc
,
[
"function"
,
"method"
,
"cfunction"
])
try
:
ofp
.
write
(
doc
.
toxml
())
ofp
.
write
(
"
\
n
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment