mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 03:24:47 +08:00
minor: rewrite/expand show_documentation (#980)
* minor: rewrite/expand show_documentation * tests: improve 'documentation docstrings'
This commit is contained in:
@@ -726,9 +726,17 @@ def show_documentation():
|
|||||||
if not definitions:
|
if not definitions:
|
||||||
echo_highlight('No documentation found for that.')
|
echo_highlight('No documentation found for that.')
|
||||||
vim.command('return')
|
vim.command('return')
|
||||||
else:
|
return
|
||||||
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '=' * 40, d.docstring())
|
|
||||||
if d.docstring() else '|No Docstring for %s|' % d for d in definitions]
|
docs = []
|
||||||
|
for d in definitions:
|
||||||
|
doc = d.docstring()
|
||||||
|
if doc:
|
||||||
|
title = 'Docstring for %s' % d.desc_with_module
|
||||||
|
underline = '=' * len(title)
|
||||||
|
docs.append('%s\n%s\n%s' % (title, underline, doc))
|
||||||
|
else:
|
||||||
|
docs.append('|No Docstring for %s|' % d)
|
||||||
text = ('\n' + '-' * 79 + '\n').join(docs)
|
text = ('\n' + '-' * 79 + '\n').join(docs)
|
||||||
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
|
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
|
||||||
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
|
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
|
||||||
|
|||||||
@@ -15,7 +15,16 @@ describe 'documentation docstrings'
|
|||||||
normal GK
|
normal GK
|
||||||
Expect bufname('%') == "__doc__"
|
Expect bufname('%') == "__doc__"
|
||||||
Expect &filetype == 'rst'
|
Expect &filetype == 'rst'
|
||||||
let content = join(getline(1,'$'), "\n")
|
let header = getline(1, 2)
|
||||||
|
PythonJedi vim.vars["is_py2"] = sys.version_info[0] == 2
|
||||||
|
if g:is_py2
|
||||||
|
Expect header[0] == "Docstring for __builtin__:class ImportError"
|
||||||
|
Expect header[1] == "==========================================="
|
||||||
|
else
|
||||||
|
Expect header[0] == "Docstring for builtins:class ImportError"
|
||||||
|
Expect header[1] == "========================================"
|
||||||
|
endif
|
||||||
|
let content = join(getline(3, '$'), "\n")
|
||||||
Expect stridx(content, "Import can't find module") > 0
|
Expect stridx(content, "Import can't find module") > 0
|
||||||
normal K
|
normal K
|
||||||
Expect bufname('%') == ''
|
Expect bufname('%') == ''
|
||||||
|
|||||||
Reference in New Issue
Block a user