Python docstring with vim pythoncomplete is not displaying newlines for my own class functions

落爺英雄遲暮 提交于 2019-12-10 19:47:31

问题


I am getting some unexpected results when trying to use Python Omni Completion on my own class functions. The docstring for the functions are not getting formatted correctly with line breaks as shown in the picture below:

When I am importing modules from the standard python library I get the result I would expect:

According to the python docstring conventions a newline in the source file should be interpreted as a newline. Does anyone know what's going on here and perhaps how to solve the issue?


回答1:


Edit: I wrote an autocompletion, which should is much better than pythoncomplete: https://github.com/davidhalter/jedi-vim


The Python Omni Completion of vim is pretty stupid. It's a simple script which parses the current file and imports all the others. This is pretty dangerous and shouldn't be done. However it works not that bad (but also not good at all).

So really the difference between your two scenarios is, that the standard libraries are being imported. So are your files, but not the current file. If you used a second module named test2 and used:

import test
test.mydoc.prettyStr

It should work.

Your current file is being parsed. The parser is simple and not really good. The dostring parser is especially strange because of this line (line number ~290):

docstr = docstr.replace('\n', ' ')

You can modify it - just change this file: /usr/share/vim/vim73/autoload/pythoncomplete.vim Maybe it's in a different directory.

Currently I'm in the process of writing a better autocompletion for python/vi (this is also the reason why I know this). But that's still quite some work. I hope I'll be ready with a Beta in a month. I try to keep you posted.



来源:https://stackoverflow.com/questions/9980442/python-docstring-with-vim-pythoncomplete-is-not-displaying-newlines-for-my-own-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!