[PyQt] Docstrings for signals

Phil Thompson phil at riverbankcomputing.com
Mon Feb 26 17:43:39 GMT 2018


On 26 Feb 2018, at 5:36 pm, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
> 
> 
> Digging a bit more...
> Sorry, I mixed things.
> Signals indeed do not have Python docstrings but there is a structure containing the documentation that is written under %Docstring in the SIP file.

Yes that confused me as well which is why I gave a misleading answer.

> So all in all, my question can be resumed as, is there a way in Sphinx to display this signature?
> 
> Le lun. 26 févr. 2018 à 13:23, Denis Rouzaud <denis.rouzaud at gmail.com> a écrit :
> Hi Phil,
> 
> I've been looking a bit more, and it seems signals do have docstring.
> At least I set them in my code and Sphinx seems to pick them up:
> 
> See SIP code:
> https://github.com/qgis/QGIS/blob/master/python/gui/qgsmapcanvas.sip.in#L912-L917
> 
> Resulting doc:
> http://python.qgis.org/api/gui/Map/QgsMapCanvas.html#qgis.gui.QgsMapCanvas.currentLayerChanged
> 
> Is this expected to you?
> 
> If yes, would there be a way to add the signature in the Docstring? Shall we modify the sip gen to achieve this?
> In Python, doing QgsMapCanvas.currentLayerChanged returns:
> <unbound PYQT_SIGNAL currentLayerChanged(QgsMapLayer*)>

It should be possible, but may need changes in PyQt as well.

Phil


More information about the PyQt mailing list