Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
90fbe6a1
Commit
90fbe6a1
authored
Oct 12, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backed out docstring handling change - breaks too many things
parent
716fe67c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
29 deletions
+23
-29
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-27
Cython/Compiler/Parsing.pxd
Cython/Compiler/Parsing.pxd
+1
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+20
-2
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
90fbe6a1
...
...
@@ -179,35 +179,10 @@ class PostParse(ScopeTrackingTransform):
'__cythonbufferdefaults__'
:
self
.
handle_bufferdefaults
}
def
_visit_DocString
(
self
,
result
):
if
hasattr
(
result
.
body
,
'stats'
)
and
result
.
body
.
stats
:
firstNode
=
result
.
body
.
stats
[
0
]
if
isinstance
(
firstNode
,
Nodes
.
ExprStatNode
)
and
firstNode
.
expr
.
is_string_literal
:
result
.
body
.
stats
=
result
.
body
.
stats
[
1
:]
self
.
doc
=
firstNode
.
expr
.
value
result
.
doc
=
self
.
doc
return
firstNode
.
expr
,
result
return
None
,
result
def
visit_FuncDefNode
(
self
,
node
):
docNode
,
result
=
self
.
_visit_DocString
(
super
(
PostParse
,
self
).
visit_FuncDefNode
(
node
))
return
result
def
visit_PyClassDefNode
(
self
,
node
):
docNode
,
result
=
self
.
_visit_DocString
(
super
(
PostParse
,
self
).
visit_PyClassDefNode
(
node
))
if
docNode
:
result
.
classobj
.
doc
=
docNode
return
result
def
visit_CClassDefNode
(
self
,
node
):
docNode
,
result
=
self
.
_visit_DocString
(
super
(
PostParse
,
self
).
visit_CClassDefNode
(
node
))
return
result
def
visit_ModuleNode
(
self
,
node
):
self
.
lambda_counter
=
1
self
.
genexpr_counter
=
1
docNode
,
result
=
self
.
_visit_DocString
(
super
(
PostParse
,
self
).
visit_ModuleNode
(
node
))
return
result
return
super
(
PostParse
,
self
).
visit_ModuleNode
(
node
)
def
visit_LambdaNode
(
self
,
node
):
# unpack a lambda expression into the corresponding DefNode
...
...
@@ -1671,7 +1646,7 @@ if VALUE is not None:
return
None
else
:
return
self
.
visit_ClassDefNode
(
node
)
def
visit_CStructOrUnionDefNode
(
self
,
node
):
# Create a wrapper node if needed.
# We want to use the struct type information (so it can't happen
...
...
Cython/Compiler/Parsing.pxd
View file @
90fbe6a1
...
...
@@ -175,5 +175,6 @@ cdef p_class_statement(PyrexScanner s, decorators)
cdef
p_c_class_definition
(
PyrexScanner
s
,
pos
,
ctx
)
cdef
p_c_class_options
(
PyrexScanner
s
)
cdef
p_property_decl
(
PyrexScanner
s
)
cdef
p_doc_string
(
PyrexScanner
s
)
cdef
p_compiler_directive_comments
(
PyrexScanner
s
)
cdef
p_cpp_class_definition
(
PyrexScanner
s
,
pos
,
ctx
)
Cython/Compiler/Parsing.py
View file @
90fbe6a1
...
...
@@ -1099,7 +1099,10 @@ def p_expression_or_assignment(s):
rhs
=
p_testlist
(
s
)
return
Nodes
.
InPlaceAssignmentNode
(
lhs
.
pos
,
operator
=
operator
,
lhs
=
lhs
,
rhs
=
rhs
)
expr
=
expr_list
[
0
]
return
Nodes
.
ExprStatNode
(
expr
.
pos
,
expr
=
expr
)
if
isinstance
(
expr
,
(
ExprNodes
.
UnicodeNode
,
ExprNodes
.
StringNode
,
ExprNodes
.
BytesNode
)):
return
Nodes
.
PassStatNode
(
expr
.
pos
)
else
:
return
Nodes
.
ExprStatNode
(
expr
.
pos
,
expr
=
expr
)
rhs
=
expr_list
[
-
1
]
if
len
(
expr_list
)
==
2
:
...
...
@@ -1867,6 +1870,8 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
if
s
.
sy
==
'NEWLINE'
:
s
.
next
()
s
.
expect_indent
()
if
with_doc
or
with_pseudo_doc
:
doc
=
p_doc_string
(
s
)
body
=
p_statement_list
(
s
,
ctx
)
s
.
expect_dedent
()
else
:
...
...
@@ -2965,6 +2970,19 @@ def p_property_decl(s):
doc
,
body
=
p_suite
(
s
,
Ctx
(
level
=
'property'
),
with_doc
=
1
)
return
Nodes
.
PropertyNode
(
pos
,
name
=
name
,
doc
=
doc
,
body
=
body
)
def
p_doc_string
(
s
):
if
s
.
sy
==
'BEGIN_STRING'
:
pos
=
s
.
position
()
kind
,
bytes_result
,
unicode_result
=
p_cat_string_literal
(
s
)
if
s
.
sy
!=
'EOF'
:
s
.
expect_newline
(
"Syntax error in doc string"
)
if
kind
in
(
'u'
,
''
):
return
unicode_result
warning
(
pos
,
"Python 3 requires docstrings to be unicode strings"
)
return
bytes_result
else
:
return
None
def
p_code
(
s
,
level
=
None
,
ctx
=
Ctx
):
body
=
p_statement_list
(
s
,
ctx
(
level
=
level
),
first_statement
=
1
)
if
s
.
sy
!=
'EOF'
:
...
...
@@ -2997,7 +3015,7 @@ def p_module(s, pxd, full_module_name, ctx=Ctx):
if
'language_level'
in
directive_comments
:
s
.
context
.
set_language_level
(
directive_comments
[
'language_level'
])
doc
=
None
doc
=
p_doc_string
(
s
)
if
pxd
:
level
=
'module_pxd'
else
:
...
...
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