Skip to content

Commit

Permalink
Merge pull request #484 from birkenfeld/local
Browse files Browse the repository at this point in the history
Docstring: show what exact object the docstring is for
  • Loading branch information
jorgenschaefer committed Feb 8, 2015
2 parents 5a7d37e + 1be05d6 commit ed07629
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion elpy/jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def rpc_get_docstring(self, filename, source, offset):
except jedi.NotFoundError:
return None
if locations:
return locations[-1].docstring()
return ('Documentation for {0}:\n\n'.format(
locations[-1].full_name) + locations[-1].docstring())
else:
return None

Expand Down
15 changes: 9 additions & 6 deletions elpy/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,19 +649,22 @@ def test_should_find_calltip_different_package(self):
class RPCGetDocstringTests(GenericRPCTests):
METHOD = "rpc_get_docstring"

def check_docstring(self, docstring):

def first_line(s):
return s[:s.index("\n")]

self.assertEqual(first_line(docstring),
self.THREAD_JOIN_DOCSTRING)

def test_should_get_docstring(self):
source, offset = source_and_offset(
"import threading\nthreading.Thread.join_|_(")
filename = self.project_file("test.py", source)
docstring = self.backend.rpc_get_docstring(filename,
source,
offset)

def first_line(s):
return s[:s.index("\n")]

self.assertEqual(first_line(docstring),
self.THREAD_JOIN_DOCSTRING)
self.check_docstring(docstring)

def test_should_return_none_for_bad_identifier(self):
source, offset = source_and_offset(
Expand Down
5 changes: 5 additions & 0 deletions elpy/tests/test_jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class TestRPCGetDocstring(RPCGetDocstringTests,
JediBackendTestCase):
THREAD_JOIN_DOCSTRING = 'join(self, timeout = None)'

def check_docstring(self, docstring):
lines = docstring.splitlines()
self.assertEqual(lines[0], 'Documentation for threading.Thread.join:')
self.assertEqual(lines[2], self.THREAD_JOIN_DOCSTRING)


class TestRPCGetDefinition(RPCGetDefinitionTests,
JediBackendTestCase):
Expand Down

0 comments on commit ed07629

Please sign in to comment.