Commit 409e24f6 authored by Nikita Nemkin's avatar Nikita Nemkin

Removed the warning about docstrings for private attributes. Fixed erroneous...

Removed the warning about docstrings for private attributes. Fixed erroneous docstring recognition past the blank line.
parent d8260e75
......@@ -2807,12 +2807,10 @@ def p_c_func_or_var_declaration(s, pos, ctx):
declarator = p_c_declarator(s, ctx, cmethod_flag = cmethod_flag,
assignable = 1, nonempty = 1)
declarators.append(declarator)
doc_line = s.start_line + 1
s.expect_newline("Syntax error in C variable declaration")
if ctx.level == 'c_class':
doc_pos = s.position()
if ctx.level == 'c_class' and s.start_line == doc_line:
doc = p_doc_string(s)
if doc and ctx.visibility not in ('public', 'readonly'):
warning(doc_pos, "Private attributes don't support docstrings.", 1)
else:
doc = None
result = Nodes.CVarDefNode(pos,
......
# mode: error
# tag: werror
cdef class A:
cdef a
"""docstring"""
cdef int b
"""docstring"""
cdef public c
"""docstring"""
cdef public dict d
"""docstring"""
cdef readonly e
"""docstring"""
cdef readonly list e
"""docstring"""
_ERRORS = """
6:4: Private attributes don't support docstrings.
9:4: Private attributes don't support docstrings.
"""
......@@ -22,6 +22,9 @@ __doc__ = ur"""
None
>>> print (Ext.attr4.__doc__)
attr4 docstring
>>> print (Ext.attr5.__doc__)
attr5: 'int'
attr5 docstring
>>> print (Ext.a.__doc__)
Ext.a(self)
......@@ -186,7 +189,12 @@ cdef class Ext:
"""attr1 docstring"""
cdef public list attr2
cdef public Ext attr3
"""NOT attr3 docstring"""
cdef int attr4
cdef public int \
attr5
"""attr5 docstring"""
CONST1, CONST2 = 1, 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment