Menu

Patch: improve docstring of slots

2017-10-10
2017-10-10
  • David Brooks

    David Brooks - 2017-10-10

    Currently the docstring generated for a slot doesn't account for the slot being an instance wrapper. The following fixes this and also uses actual parameter names in the generated method signature.

    diff --git a/src/PythonQtSlot.cpp b/src/PythonQtSlot.cpp
    index 612a667..c5c2994 100644
    --- a/src/PythonQtSlot.cpp
    +++ b/src/PythonQtSlot.cpp
    @@ -481,11 +481,17 @@ meth_get__doc__(PythonQtSlotFunctionObject * m, void * /*closure*/)
         infoSearch = infoSearch->nextInfo();
       }
       doc = "X." + info->slotName(true) + "(";
    -  for (int i = 1;i<longestInfo->parameterCount(); i++) {
    -    if (i!=1) {
    +  int firstArgOffset = info->isInstanceDecorator()?2:1;
    +  QList<QByteArray> names = longestInfo->metaMethod()->parameterNames();
    +  for (int i = firstArgOffset;i<longestInfo->parameterCount(); i++) {
    +    if (i!=firstArgOffset) {
           doc += ", ";
         }
    -    doc += QString('a' + i-1);
    +    if (!names.at(i-1).isEmpty()) {
    +      doc += names.at(i-1);
    +    } else {
    +      doc += QString('a' + i-firstArgOffset);
    +    }
       }
       doc += ")";
       QByteArray pyReturnType;
    
     
  • Florian Link

    Florian Link - 2017-10-18

    Thanks, I merged it.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.