Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1ff6db48
Kaydet (Commit)
1ff6db48
authored
Kas 23, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add some additional cleanup transformations.
üst
df12a593
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
docfixer.py
Doc/tools/sgmlconv/docfixer.py
+67
-0
No files found.
Doc/tools/sgmlconv/docfixer.py
Dosyayı görüntüle @
1ff6db48
...
@@ -153,15 +153,82 @@ def handle_labels(doc):
...
@@ -153,15 +153,82 @@ def handle_labels(doc):
parent
.
removeChild
(
label
)
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
):
def
convert
(
ifp
,
ofp
):
p
=
xml
.
dom
.
esis_builder
.
EsisBuilder
()
p
=
xml
.
dom
.
esis_builder
.
EsisBuilder
()
p
.
feed
(
ifp
.
read
())
p
.
feed
(
ifp
.
read
())
doc
=
p
.
document
doc
=
p
.
document
normalize
(
doc
)
handle_args
(
doc
)
handle_args
(
doc
)
handle_comments
(
doc
)
handle_comments
(
doc
)
simplify
(
doc
)
simplify
(
doc
)
handle_labels
(
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_root_text
(
doc
)
cleanup_trailing_parens
(
doc
,
[
"function"
,
"method"
,
"cfunction"
])
try
:
try
:
ofp
.
write
(
doc
.
toxml
())
ofp
.
write
(
doc
.
toxml
())
ofp
.
write
(
"
\n
"
)
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