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
35903c80
Kaydet (Commit)
35903c80
authored
Eki 30, 2014
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Sphinx extension: move imports to the module top
üst
5aa761db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
28 deletions
+33
-28
pyspecific.py
Doc/tools/extensions/pyspecific.py
+33
-28
No files found.
Doc/tools/extensions/pyspecific.py
Dosyayı görüntüle @
35903c80
...
@@ -9,15 +9,32 @@
...
@@ -9,15 +9,32 @@
:license: Python license.
:license: Python license.
"""
"""
ISSUE_URI
=
'https://bugs.python.org/issue
%
s'
import
re
SOURCE_URI
=
'https://hg.python.org/cpython/file/3.4/
%
s'
import
codecs
from
os
import
path
from
time
import
asctime
from
pprint
import
pformat
from
docutils.io
import
StringOutput
from
docutils.utils
import
new_document
from
docutils
import
nodes
,
utils
from
docutils
import
nodes
,
utils
from
sphinx
import
addnodes
from
sphinx.builders
import
Builder
from
sphinx.util.nodes
import
split_explicit_title
from
sphinx.util.nodes
import
split_explicit_title
from
sphinx.util.compat
import
Directive
from
sphinx.util.compat
import
Directive
from
sphinx.writers.html
import
HTMLTranslator
from
sphinx.writers.html
import
HTMLTranslator
from
sphinx.writers.text
import
TextWriter
from
sphinx.writers.latex
import
LaTeXTranslator
from
sphinx.writers.latex
import
LaTeXTranslator
from
sphinx.domains.python
import
PyModulelevel
,
PyClassmember
# Support for checking for suspicious markup
import
suspicious
ISSUE_URI
=
'https://bugs.python.org/issue
%
s'
SOURCE_URI
=
'https://hg.python.org/cpython/file/3.4/
%
s'
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
from
docutils.parsers.rst.states
import
Body
from
docutils.parsers.rst.states
import
Body
...
@@ -29,6 +46,9 @@ Body.enum.converters['loweralpha'] = \
...
@@ -29,6 +46,9 @@ Body.enum.converters['loweralpha'] = \
# monkey-patch HTML and LaTeX translators to keep doctest blocks in the
# monkey-patch HTML and LaTeX translators to keep doctest blocks in the
# doctest docs themselves
# doctest docs themselves
orig_visit_literal_block
=
HTMLTranslator
.
visit_literal_block
orig_visit_literal_block
=
HTMLTranslator
.
visit_literal_block
orig_depart_literal_block
=
LaTeXTranslator
.
depart_literal_block
def
new_visit_literal_block
(
self
,
node
):
def
new_visit_literal_block
(
self
,
node
):
meta
=
self
.
builder
.
env
.
metadata
[
self
.
builder
.
current_docname
]
meta
=
self
.
builder
.
env
.
metadata
[
self
.
builder
.
current_docname
]
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
...
@@ -39,9 +59,7 @@ def new_visit_literal_block(self, node):
...
@@ -39,9 +59,7 @@ def new_visit_literal_block(self, node):
finally
:
finally
:
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
HTMLTranslator
.
visit_literal_block
=
new_visit_literal_block
orig_depart_literal_block
=
LaTeXTranslator
.
depart_literal_block
def
new_depart_literal_block
(
self
,
node
):
def
new_depart_literal_block
(
self
,
node
):
meta
=
self
.
builder
.
env
.
metadata
[
self
.
curfilestack
[
-
1
]]
meta
=
self
.
builder
.
env
.
metadata
[
self
.
curfilestack
[
-
1
]]
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
...
@@ -52,8 +70,11 @@ def new_depart_literal_block(self, node):
...
@@ -52,8 +70,11 @@ def new_depart_literal_block(self, node):
finally
:
finally
:
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
HTMLTranslator
.
visit_literal_block
=
new_visit_literal_block
LaTeXTranslator
.
depart_literal_block
=
new_depart_literal_block
LaTeXTranslator
.
depart_literal_block
=
new_depart_literal_block
# Support for marking up and linking to bugs.python.org issues
# Support for marking up and linking to bugs.python.org issues
def
issue_role
(
typ
,
rawtext
,
text
,
lineno
,
inliner
,
options
=
{},
content
=
[]):
def
issue_role
(
typ
,
rawtext
,
text
,
lineno
,
inliner
,
options
=
{},
content
=
[]):
...
@@ -101,9 +122,6 @@ class ImplementationDetail(Directive):
...
@@ -101,9 +122,6 @@ class ImplementationDetail(Directive):
# Support for documenting decorators
# Support for documenting decorators
from
sphinx
import
addnodes
from
sphinx.domains.python
import
PyModulelevel
,
PyClassmember
class
PyDecoratorMixin
(
object
):
class
PyDecoratorMixin
(
object
):
def
handle_signature
(
self
,
sig
,
signode
):
def
handle_signature
(
self
,
sig
,
signode
):
ret
=
super
(
PyDecoratorMixin
,
self
)
.
handle_signature
(
sig
,
signode
)
ret
=
super
(
PyDecoratorMixin
,
self
)
.
handle_signature
(
sig
,
signode
)
...
@@ -113,12 +131,14 @@ class PyDecoratorMixin(object):
...
@@ -113,12 +131,14 @@ class PyDecoratorMixin(object):
def
needs_arglist
(
self
):
def
needs_arglist
(
self
):
return
False
return
False
class
PyDecoratorFunction
(
PyDecoratorMixin
,
PyModulelevel
):
class
PyDecoratorFunction
(
PyDecoratorMixin
,
PyModulelevel
):
def
run
(
self
):
def
run
(
self
):
# a decorator function is a function after all
# a decorator function is a function after all
self
.
name
=
'py:function'
self
.
name
=
'py:function'
return
PyModulelevel
.
run
(
self
)
return
PyModulelevel
.
run
(
self
)
class
PyDecoratorMethod
(
PyDecoratorMixin
,
PyClassmember
):
class
PyDecoratorMethod
(
PyDecoratorMixin
,
PyClassmember
):
def
run
(
self
):
def
run
(
self
):
self
.
name
=
'py:method'
self
.
name
=
'py:method'
...
@@ -162,7 +182,8 @@ class DeprecatedRemoved(Directive):
...
@@ -162,7 +182,8 @@ class DeprecatedRemoved(Directive):
classes
=
[
'versionmodified'
]))
classes
=
[
'versionmodified'
]))
else
:
else
:
para
=
nodes
.
paragraph
(
''
,
''
,
para
=
nodes
.
paragraph
(
''
,
''
,
nodes
.
inline
(
''
,
'
%
s.'
%
text
,
classes
=
[
'versionmodified'
]))
nodes
.
inline
(
''
,
'
%
s.'
%
text
,
classes
=
[
'versionmodified'
]))
if
len
(
node
):
if
len
(
node
):
node
.
insert
(
0
,
para
)
node
.
insert
(
0
,
para
)
else
:
else
:
...
@@ -174,12 +195,10 @@ class DeprecatedRemoved(Directive):
...
@@ -174,12 +195,10 @@ class DeprecatedRemoved(Directive):
# Support for including Misc/NEWS
# Support for including Misc/NEWS
import
re
import
codecs
issue_re
=
re
.
compile
(
'([Ii])ssue #([0-9]+)'
)
issue_re
=
re
.
compile
(
'([Ii])ssue #([0-9]+)'
)
whatsnew_re
=
re
.
compile
(
r"(?im)^what's new in (.*?)\??$"
)
whatsnew_re
=
re
.
compile
(
r"(?im)^what's new in (.*?)\??$"
)
class
MiscNews
(
Directive
):
class
MiscNews
(
Directive
):
has_content
=
False
has_content
=
False
required_arguments
=
1
required_arguments
=
1
...
@@ -233,15 +252,6 @@ pydoc_topic_labels = [
...
@@ -233,15 +252,6 @@ pydoc_topic_labels = [
'typesseq'
,
'typesseq-mutable'
,
'unary'
,
'while'
,
'with'
,
'yield'
'typesseq'
,
'typesseq-mutable'
,
'unary'
,
'while'
,
'with'
,
'yield'
]
]
from
os
import
path
from
time
import
asctime
from
pprint
import
pformat
from
docutils.io
import
StringOutput
from
docutils.utils
import
new_document
from
sphinx.builders
import
Builder
from
sphinx.writers.text
import
TextWriter
class
PydocTopicsBuilder
(
Builder
):
class
PydocTopicsBuilder
(
Builder
):
name
=
'pydoc-topics'
name
=
'pydoc-topics'
...
@@ -281,17 +291,11 @@ class PydocTopicsBuilder(Builder):
...
@@ -281,17 +291,11 @@ class PydocTopicsBuilder(Builder):
f
.
close
()
f
.
close
()
# Support for checking for suspicious markup
import
suspicious
# Support for documenting Opcodes
# Support for documenting Opcodes
import
re
opcode_sig_re
=
re
.
compile
(
r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?'
)
opcode_sig_re
=
re
.
compile
(
r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?'
)
def
parse_opcode_signature
(
env
,
sig
,
signode
):
def
parse_opcode_signature
(
env
,
sig
,
signode
):
"""Transform an opcode signature into RST nodes."""
"""Transform an opcode signature into RST nodes."""
m
=
opcode_sig_re
.
match
(
sig
)
m
=
opcode_sig_re
.
match
(
sig
)
...
@@ -311,12 +315,13 @@ def parse_opcode_signature(env, sig, signode):
...
@@ -311,12 +315,13 @@ def parse_opcode_signature(env, sig, signode):
pdbcmd_sig_re
=
re
.
compile
(
r'([a-z()!]+)\s*(.*)'
)
pdbcmd_sig_re
=
re
.
compile
(
r'([a-z()!]+)\s*(.*)'
)
# later...
# later...
#pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers
#
pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers
# [.,:]+ | # punctuation
# [.,:]+ | # punctuation
# [\[\]()] | # parens
# [\[\]()] | # parens
# \s+ # whitespace
# \s+ # whitespace
# ''', re.X)
# ''', re.X)
def
parse_pdb_command
(
env
,
sig
,
signode
):
def
parse_pdb_command
(
env
,
sig
,
signode
):
"""Transform a pdb command signature into RST nodes."""
"""Transform a pdb command signature into RST nodes."""
m
=
pdbcmd_sig_re
.
match
(
sig
)
m
=
pdbcmd_sig_re
.
match
(
sig
)
...
...
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