Urukann
Urukann

Reputation: 485

Is it possible to get jedi autocomplete for a C++ library binded to python?

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 !

Upvotes: 1

Views: 1095

Answers (1)

Dave Halter
Dave Halter

Reputation: 16325

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.

Upvotes: 2

Related Questions