fixed docstr problems with unified interfaces

This commit is contained in:
Dave Halter
2014-02-26 02:33:18 +01:00
parent 5e5bb618ea
commit 44e16c11e5
5 changed files with 43 additions and 56 deletions
+2 -11
View File
@@ -18,7 +18,6 @@ import re
from jedi.evaluate.cache import memoize_default
from jedi.parser import Parser
from jedi.parser.representation import docstring_content
DOCSTRING_PARAM_PATTERNS = [
r'\s*:type\s+%s:\s*([^\n]+)', # Sphinx
@@ -37,13 +36,7 @@ REST_ROLE_PATTERN = re.compile(r':[^`]+:`([^`]+)`')
def follow_param(evaluator, param):
func = param.parent_function
# print func, param, param.parent_function
if not func.docstr:
return []
param_str = _search_param_in_docstr(
# TODO this is ugly, no direct access?
docstring_content(func.docstr),
str(param.get_name())
)
param_str = _search_param_in_docstr(func.raw_doc, str(param.get_name()))
position = (1, 0)
if param_str is not None:
@@ -119,9 +112,7 @@ def find_return_types(evaluator, func):
if match:
return match.group(1)
if not func.docstr:
return []
type_str = search_return_in_docstr(docstring_content(func.docstr))
type_str = search_return_in_docstr(func.raw_doc)
if not type_str:
return []
+2 -2
View File
@@ -168,7 +168,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'name', 'get_imports',
'doc', 'docstr', 'asserts']:
'doc', 'raw_doc', 'asserts']:
raise AttributeError("Instance %s: Don't touch this (%s)!"
% (self, name))
return getattr(self.base, name)
@@ -302,7 +302,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
return self.base.name
def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'docstr',
if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'raw_doc',
'doc', 'get_imports', 'get_parent_until', 'get_code',
'subscopes']:
raise AttributeError("Don't touch this: %s of %s !" % (name, self))