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
4db5b463
Kaydet (Commit)
4db5b463
authored
Ara 01, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use esistools.
Generate ESIS data instead of XML. Misc. changes to some transforms.
üst
f077b9d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
15 deletions
+66
-15
docfixer.py
Doc/tools/sgmlconv/docfixer.py
+66
-15
No files found.
Doc/tools/sgmlconv/docfixer.py
Dosyayı görüntüle @
4db5b463
...
@@ -12,6 +12,8 @@ __version__ = '$Revision$'
...
@@ -12,6 +12,8 @@ __version__ = '$Revision$'
import
errno
import
errno
import
esistools
import
re
import
string
import
string
import
sys
import
sys
import
xml.dom.core
import
xml.dom.core
...
@@ -93,7 +95,7 @@ def cleanup_root_text(doc):
...
@@ -93,7 +95,7 @@ def cleanup_root_text(doc):
skip
=
0
skip
=
0
if
n
.
nodeType
==
xml
.
dom
.
core
.
TEXT
and
not
prevskip
:
if
n
.
nodeType
==
xml
.
dom
.
core
.
TEXT
and
not
prevskip
:
discards
.
append
(
n
)
discards
.
append
(
n
)
elif
n
.
nodeType
==
xml
.
dom
.
core
.
COMMENT
:
elif
n
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
and
n
.
tagName
==
"COMMENT"
:
skip
=
1
skip
=
1
for
node
in
discards
:
for
node
in
discards
:
doc
.
removeChild
(
node
)
doc
.
removeChild
(
node
)
...
@@ -126,16 +128,33 @@ def handle_args(doc):
...
@@ -126,16 +128,33 @@ def handle_args(doc):
rewrite_desc_entries
(
doc
,
"constructor-args"
)
rewrite_desc_entries
(
doc
,
"constructor-args"
)
def
handle_comments
(
doc
,
node
=
None
):
def
handle_appendix
(
doc
):
if
node
is
None
:
# must be called after simplfy() if document is multi-rooted to begin with
node
=
doc
docelem
=
doc
.
documentElement
for
n
in
node
.
childNodes
:
toplevel
=
docelem
.
tagName
==
"manual"
and
"chapter"
or
"section"
if
n
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
appendices
=
0
if
n
.
tagName
==
"COMMENT"
:
nodes
=
[]
comment
=
doc
.
createComment
(
n
.
childNodes
[
0
]
.
data
)
for
node
in
docelem
.
childNodes
:
node
.
replaceChild
(
comment
,
n
)
if
appendices
:
else
:
nodes
.
append
(
node
)
handle_comments
(
doc
,
n
)
elif
node
.
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
appnodes
=
node
.
getElementsByTagName
(
"appendix"
)
if
appnodes
:
appendices
=
1
parent
=
appnodes
[
0
]
.
parentNode
parent
.
removeChild
(
appnodes
[
0
])
parent
.
normalize
()
if
nodes
:
map
(
docelem
.
removeChild
,
nodes
)
docelem
.
appendChild
(
doc
.
createTextNode
(
"
\n\n\n
"
))
back
=
doc
.
createElement
(
"back-matter"
)
docelem
.
appendChild
(
back
)
back
.
appendChild
(
doc
.
createTextNode
(
"
\n
"
))
while
nodes
and
nodes
[
0
]
.
nodeType
==
xml
.
dom
.
core
.
TEXT
\
and
not
string
.
strip
(
nodes
[
0
]
.
data
):
del
nodes
[
0
]
map
(
back
.
appendChild
,
nodes
)
docelem
.
appendChild
(
doc
.
createTextNode
(
"
\n
"
))
def
handle_labels
(
doc
):
def
handle_labels
(
doc
):
...
@@ -208,15 +227,42 @@ def cleanup_trailing_parens(doc, element_names):
...
@@ -208,15 +227,42 @@ def cleanup_trailing_parens(doc, element_names):
queue
.
append
(
child
)
queue
.
append
(
child
)
_token_rx
=
re
.
compile
(
r"[a-zA-Z][a-zA-Z0-9.-]*$"
)
def
write_esis
(
doc
,
ofp
,
knownempty
):
for
node
in
doc
.
childNodes
:
nodeType
=
node
.
nodeType
if
nodeType
==
xml
.
dom
.
core
.
ELEMENT
:
gi
=
node
.
tagName
if
knownempty
(
gi
):
if
node
.
hasChildNodes
():
raise
ValueError
,
"declared-empty node has children"
ofp
.
write
(
"e
\n
"
)
for
k
,
v
in
node
.
attributes
.
items
():
value
=
v
.
value
if
_token_rx
.
match
(
value
):
dtype
=
"TOKEN"
else
:
dtype
=
"CDATA"
ofp
.
write
(
"A
%
s
%
s
%
s
\n
"
%
(
k
,
dtype
,
esistools
.
encode
(
value
)))
ofp
.
write
(
"(
%
s
\n
"
%
gi
)
write_esis
(
node
,
ofp
,
knownempty
)
ofp
.
write
(
")
%
s
\n
"
%
gi
)
elif
nodeType
==
xml
.
dom
.
core
.
TEXT
:
ofp
.
write
(
"-
%
s
\n
"
%
esistools
.
encode
(
node
.
data
))
else
:
raise
RuntimeError
,
"unsupported node type:
%
s"
%
nodeType
def
convert
(
ifp
,
ofp
):
def
convert
(
ifp
,
ofp
):
p
=
xml
.
dom
.
esis_builder
.
EsisBuilder
()
p
=
esistools
.
Extended
EsisBuilder
()
p
.
feed
(
ifp
.
read
())
p
.
feed
(
ifp
.
read
())
doc
=
p
.
document
doc
=
p
.
document
normalize
(
doc
)
normalize
(
doc
)
handle_args
(
doc
)
handle_args
(
doc
)
handle_comments
(
doc
)
simplify
(
doc
)
simplify
(
doc
)
handle_labels
(
doc
)
handle_labels
(
doc
)
handle_appendix
(
doc
)
fixup_trailing_whitespace
(
doc
,
{
fixup_trailing_whitespace
(
doc
,
{
"abstract"
:
"
\n
"
,
"abstract"
:
"
\n
"
,
"title"
:
""
,
"title"
:
""
,
...
@@ -229,9 +275,14 @@ def convert(ifp, ofp):
...
@@ -229,9 +275,14 @@ def convert(ifp, ofp):
})
})
cleanup_root_text
(
doc
)
cleanup_root_text
(
doc
)
cleanup_trailing_parens
(
doc
,
[
"function"
,
"method"
,
"cfunction"
])
cleanup_trailing_parens
(
doc
,
[
"function"
,
"method"
,
"cfunction"
])
#
d
=
{}
for
gi
in
p
.
get_empties
():
d
[
gi
]
=
gi
knownempty
=
d
.
has_key
#
try
:
try
:
ofp
.
write
(
doc
.
toxml
())
write_esis
(
doc
,
ofp
,
knownempty
)
ofp
.
write
(
"
\n
"
)
except
IOError
,
(
err
,
msg
):
except
IOError
,
(
err
,
msg
):
# Ignore EPIPE; it just means that whoever we're writing to stopped
# Ignore EPIPE; it just means that whoever we're writing to stopped
# reading. The rest of the output would be ignored. All other errors
# reading. The rest of the output would be ignored. All other errors
...
...
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