Skip to content

Commit 5a9b6f7

Browse files
committed
PythonCodeCompletion: Improved completion hint formatting by unwrapping wrapped text and using the objects type and name as the heading. Improved calltip formatting by separating default args from the call spec (easier for the plugin to parse).
1 parent b5c2674 commit 5a9b6f7

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

PythonCodeCompletion/PythonCodeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ std::vector<PythonCodeCompletion::CCCallTip> PythonCodeCompletion::GetCallTips(i
381381
Manager::Get()->GetLogManager()->DebugLog(_("PYCC: Supplying the calltip ")+m_ActiveCalltipDef.tip);
382382
PythonCodeCompletion::CCCallTip ct=m_ActiveCalltipDef;
383383
m_ActiveCalltipDef=PythonCodeCompletion::CCCallTip(_T(""));
384-
wxString s = ct.tip;
384+
wxString s = ct.tip.BeforeFirst(_T('\n'));
385385
if(s==_(""))
386386
{
387387
return cts;

PythonCodeCompletion/python/python_completion_server.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def get_doc(self,index):
114114
doclines = comp.follow_definition()[0].raw_doc.splitlines()
115115
else:
116116
doclines = comp.doc.splitlines()
117+
doclines = [l.strip() for l in doclines]
117118
if len(doclines)>0:
118-
doclines[0] = '<b>'+doclines[0]+'</b>'
119-
else:
120-
doclines =['<b>'+comp.type+' '+comp.name+'</b>']
121-
doc = '<br>'.join(doclines)
119+
doclines = ['<br><br>']+[l + ' ' if l!='' else '<br><br>' for l in doclines[:-1]] + [doclines[-1]]
120+
doclines =['<b>'+comp.type+' '+comp.name+'</b>'] + doclines
121+
doc = ''.join(doclines)
122122
return doc
123123

124124
def complete_tip(self,path,source,line,column):
@@ -131,15 +131,18 @@ def complete_tip(self,path,source,line,column):
131131
calltip=c.call_name+'('
132132
if jedi.__version__ >= '0.8.0':
133133
calltip+=', '.join([p.name for p in c.params])+')'
134+
default_args=[]
135+
for p in c.params:
136+
if '=' in p.description:
137+
default_args.append(p.description)
138+
if default_args:
139+
calltip = calltip + '\n\nDefault Arguments: ' + ', '.join(default_args)
140+
# if c.doc:
141+
# calltip = calltip + '\n\nDescription\n' + c.doc
134142
else:
135143
calltip+=', '.join([p.get_name().names[0] for p in c.params])+')'
136-
calltip = '\n'.join(textwrap.wrap(calltip,70))
137-
calltip = '\n'.join(textwrap.wrap(calltip,70))
138-
# docstr=''
139-
# for p in c.params:
140-
# docstr+=p.docstr
141-
# if docstr!='':
142-
# calltip+='\n'+docstr
144+
# calltip = '\n'.join(textwrap.wrap(calltip,70))
145+
143146
return calltip
144147
return ''
145148

0 commit comments

Comments
 (0)