mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
param docstrings cleaned up - #370
This commit is contained in:
@@ -19,6 +19,7 @@ from textwrap import dedent
|
|||||||
|
|
||||||
from jedi.evaluate.cache import memoize_default
|
from jedi.evaluate.cache import memoize_default
|
||||||
from jedi.parser import Parser
|
from jedi.parser import Parser
|
||||||
|
from jedi.parser import representation as pr
|
||||||
from jedi.common import indent_block
|
from jedi.common import indent_block
|
||||||
|
|
||||||
DOCSTRING_PARAM_PATTERNS = [
|
DOCSTRING_PARAM_PATTERNS = [
|
||||||
@@ -40,8 +41,8 @@ def follow_param(evaluator, param):
|
|||||||
param_str = _search_param_in_docstr(func.raw_doc, str(param.get_name()))
|
param_str = _search_param_in_docstr(func.raw_doc, str(param.get_name()))
|
||||||
|
|
||||||
code = dedent("""
|
code = dedent("""
|
||||||
class PseudoDocstring():
|
def PseudoDocstring():
|
||||||
'''Create a pseudo class for docstring statements.'''
|
'''Create a pseudo function for docstring statements.'''
|
||||||
%s
|
%s
|
||||||
""")
|
""")
|
||||||
if param_str is not None:
|
if param_str is not None:
|
||||||
@@ -59,7 +60,10 @@ def follow_param(evaluator, param):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
stmt.start_pos = param.start_pos
|
# Use the module of the param.
|
||||||
|
# TODO this module is not the module of the param in case of a function
|
||||||
|
# call. In that case it's the module of the function call.
|
||||||
|
# stuffed with content from a function call.
|
||||||
pseudo_cls.parent = param.get_parent_until()
|
pseudo_cls.parent = param.get_parent_until()
|
||||||
return evaluator.eval_statement(stmt)
|
return evaluator.eval_statement(stmt)
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -44,18 +44,23 @@ def f(a, b):
|
|||||||
f()
|
f()
|
||||||
|
|
||||||
# local classes -> github #370
|
# local classes -> github #370
|
||||||
class ProgramNode(object):
|
class ProgramNode():
|
||||||
def add_child(self, child):
|
pass
|
||||||
pass
|
|
||||||
|
|
||||||
def func(node):
|
def func(node, node2):
|
||||||
"""
|
"""
|
||||||
Do something with a ``node``.
|
|
||||||
|
|
||||||
:type node: ProgramNode
|
:type node: ProgramNode
|
||||||
|
... and the class definition after this func definition:
|
||||||
|
:type node2: ProgramNode2
|
||||||
"""
|
"""
|
||||||
#? ProgramNode
|
#? ProgramNode
|
||||||
node
|
node
|
||||||
|
#? ProgramNode2
|
||||||
|
node2
|
||||||
|
|
||||||
|
class ProgramNode2():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# epydoc style
|
# epydoc style
|
||||||
|
|||||||
Reference in New Issue
Block a user