File tree 4 files changed +24
-8
lines changed
4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,6 @@ def format_docstring(contents):
136
136
"""
137
137
contents = contents .replace ('\t ' , u'\u00A0 ' * 4 )
138
138
contents = contents .replace (' ' , u'\u00A0 ' * 2 )
139
- contents = contents .replace ('*' , '\\ *' )
140
139
return contents
141
140
142
141
Original file line number Diff line number Diff line change @@ -10,9 +10,26 @@ def pyls_hover(document, position):
10
10
definitions = document .jedi_script (position ).goto_definitions ()
11
11
word = document .word_at_position (position )
12
12
13
- # Find an exact match for a completion
14
- for d in definitions :
15
- if d .name == word :
16
- return {'contents' : _utils .format_docstring (d .docstring ()) or '' }
13
+ # Find first exact matching definition
14
+ definition = next ((x for x in definitions if x .name == word ), None )
17
15
18
- return {'contents' : '' }
16
+ if not definition :
17
+ return {'contents' : '' }
18
+
19
+ # raw docstring returns only doc, without signature
20
+ doc = _utils .format_docstring (definition .docstring (raw = True ))
21
+
22
+ # Find first exact matching signature
23
+ signature = next ((x .to_string () for x in definition .get_signatures () if x .name == word ), '' )
24
+
25
+ contents = []
26
+ if signature :
27
+ contents .append ({
28
+ 'language' : 'python' ,
29
+ 'value' : signature ,
30
+ })
31
+ if doc :
32
+ contents .append (doc )
33
+ if not contents :
34
+ return {'contents' : '' }
35
+ return {'contents' : contents }
Original file line number Diff line number Diff line change 36
36
'future>=0.14.0' ,
37
37
'futures; python_version<"3.2"' ,
38
38
'backports.functools_lru_cache; python_version<"3.2"' ,
39
- 'jedi>=0.14.1 ,<0.15 ' ,
39
+ 'jedi>=0.15.0 ,<0.16 ' ,
40
40
'python-jsonrpc-server>=0.1.0' ,
41
41
'pluggy'
42
42
],
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def test_hover():
21
21
doc = Document (DOC_URI , DOC )
22
22
23
23
assert {
24
- 'contents' : ' main()\n \n hello world'
24
+ 'contents' : [{ 'language' : 'python' , 'value' : ' main()' }, 'hello world']
25
25
} == pyls_hover (doc , hov_position )
26
26
27
27
assert {'contents' : '' } == pyls_hover (doc , no_hov_position )
You can’t perform that action at this time.
0 commit comments