1

I am using vim with jedi-vim to edit some python code. However, some libraries we use are C++ shared libraries for which we generated python bindings using pybindgen. When using jedi-vim, I do not get signature for any of the classes and methods, just a listing of them.

For example, in this library, https://github.com/jorisv/SpaceVecAlg if I install the library and import it:

import spacevecalg as sva

Then, sva. will correctly show all first-order functions and classes. However, if I select the first one, sva.ABInertia( jedi will not suggest me any of the class constructors.

I suppose I have to somehow export the class definitions to a kind of python documentation, and I figured I could use the doxygen annotations for that, but I have no idea how to feed that extra documentation to jedi (or any other completion engine, such as the one built in IPython).

Thanks a lot !

Urukann
  • 475
  • 4
  • 10

1 Answers1

2

You cannot feed extra documentation to Jedi. However, you can set the __doc__ attribute in a way that Jedi understands it. If you define call signatures the same way as the standard library, I guess it should work.

As a side note, I have to mention that in Python 3.4+ there's an even better way of defining the docstrings. IMHO it's the proper way to define it. I'm not sure how exactly to do it (but there are ways to use it):

>>> inspect.signature(exit)
<inspect.Signature object at 0x7f2b5a05aa58>
>>> str(inspect.signature(exit))
'(code=None)'

Jedi doesn't understand it yet, but it definitely will in the future.

Dave Halter
  • 15,556
  • 13
  • 76
  • 103
  • Does (or will) Jedi understand `__annotations__`? – asmeurer Sep 26 '14 at 17:16
  • According to http://legacy.python.org/dev/peps/pep-0362/ you can set `__signature__` to one of those `Signature` objects. – asmeurer Sep 26 '14 at 17:22
  • Jedi doesn't understand `__annotations__`, but it could in the future, if there's a need. – Dave Halter Sep 27 '14 at 16:16
  • Hello, thank you for your answer ! I simply modified the way pybindgen handles the "no docstring provided" case to auto-generate one with `"function_name("+",".join(parameters)+")"` and it works :) – Urukann Sep 29 '14 at 08:49