pycairo icon indicating copy to clipboard operation
pycairo copied to clipboard

Missing Docstrings

Open naveen521kk opened this issue 4 years ago • 7 comments

Using the help function the docstrings should be displayed.

>>> import cairo
>>> help(cairo.Context)
[...]

It doesn't have docs string on the whole. I don't know how exactly to do on a C extension but it is possible(I tried it using Cython it works there). Also, the docs, instead of hardcoding in .rst files, auto-summary sphinx module must be used so that docstrings can be maintained in the source.

naveen521kk avatar Feb 21 '21 04:02 naveen521kk

It looks like PyDoc_STRVAR is the thing to achieve this with.

https://github.com/python/cpython/blob/master/Doc/c-api/intro.rst https://www.python.org/dev/peps/pep-0007/

smbusmodule uses it here: https://github.com/pimoroni/py-smbus/blob/master/library/smbusmodule.c

stuaxo avatar Mar 25 '21 18:03 stuaxo

puh, not sure we want to manage the docs all in C this way... that seems a bit tedious.

lazka avatar Apr 30 '21 03:04 lazka

Or another option would be to write stub python wrappers for the existing C function and classes with docstrings(seems a lot simpler to me). What do you think?

naveen521kk avatar Apr 30 '21 04:04 naveen521kk

Is the current type annotation solution good enough to close this?

lazka avatar Nov 21 '22 20:11 lazka

Still looks a bit sparse here -

image

stuaxo avatar Nov 21 '22 22:11 stuaxo

Nothing changed on the C side of things, so that is expected. Your editor should show the docs though.

lazka avatar Nov 21 '22 22:11 lazka

Looks good - image

stuaxo avatar Nov 21 '22 22:11 stuaxo