diff options
author | albert-github <albert.tests@gmail.com> | 2015-12-26 14:29:39 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2015-12-26 14:29:39 (GMT) |
commit | 0a5dfb77a7d0dfaac2baf8f3e61014a29ba2883b (patch) | |
tree | 65f4af233361f0baee0dd08c7a4a3a660b091fd0 /src | |
parent | 165498dc9ea33bc9991c5ab5234b5e51d74569d0 (diff) | |
download | Doxygen-0a5dfb77a7d0dfaac2baf8f3e61014a29ba2883b.zip Doxygen-0a5dfb77a7d0dfaac2baf8f3e61014a29ba2883b.tar.gz Doxygen-0a5dfb77a7d0dfaac2baf8f3e61014a29ba2883b.tar.bz2 |
Bug 735152 - Python: Allow undocumented "cls" parameter for class methods
Made 'cls' parameter analogous to the 'self' parameter. See also https://www.python.org/dev/peps/pep-0008 (paragraph: Function and method arguments)
Diffstat (limited to 'src')
-rw-r--r-- | src/docparser.cpp | 12 | ||||
-rw-r--r-- | src/pycode.l | 8 | ||||
-rw-r--r-- | src/pyscanner.l | 20 |
3 files changed, 33 insertions, 7 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp index b706c9b..099213d 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -471,9 +471,9 @@ static void checkUndocumentedParams() if (lang==SrcLangExt_Fortran) argName = argName.lower(); argName=argName.stripWhiteSpace(); if (argName.right(3)=="...") argName=argName.left(argName.length()-3); - if (g_memberDef->getLanguage()==SrcLangExt_Python && argName=="self") + if (g_memberDef->getLanguage()==SrcLangExt_Python && (argName=="self" || argName=="cls")) { - // allow undocumented self parameter for Python + // allow undocumented self / cls parameter for Python } else if (!argName.isEmpty() && g_paramsFound.find(argName)==0 && a->docs.isEmpty()) { @@ -494,9 +494,9 @@ static void checkUndocumentedParams() QCString argName = g_memberDef->isDefine() ? a->type : a->name; if (lang==SrcLangExt_Fortran) argName = argName.lower(); argName=argName.stripWhiteSpace(); - if (g_memberDef->getLanguage()==SrcLangExt_Python && argName=="self") + if (g_memberDef->getLanguage()==SrcLangExt_Python && (argName=="self" || argName=="cls")) { - // allow undocumented self parameter for Python + // allow undocumented self / cls parameter for Python } else if (!argName.isEmpty() && g_paramsFound.find(argName)==0) { @@ -554,7 +554,7 @@ static void detectNoDocumentedParams() for (ali.toFirst();(a=ali.current()) && allDoc;++ali) { if (!a->name.isEmpty() && a->type!="void" && - !(isPython && a->name=="self") + !(isPython && (a->name=="self" || a->name=="cls")) ) { allDoc = !a->docs.isEmpty(); @@ -570,7 +570,7 @@ static void detectNoDocumentedParams() for (ali.toFirst();(a=ali.current()) && allDoc;++ali) { if (!a->name.isEmpty() && a->type!="void" && - !(isPython && a->name=="self") + !(isPython && (a->name=="self" || a->name=="cls")) ) { allDoc = !a->docs.isEmpty(); diff --git a/src/pycode.l b/src/pycode.l index c3219d9..3edbcc3 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -989,6 +989,14 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT codify("self."); findMemberLink(*g_code,&yytext[5]); } + "cls."{IDENTIFIER}/"(" { + codify("cls."); + findMemberLink(*g_code,&yytext[4]); + } + "cls."{IDENTIFIER} { + codify("cls."); + findMemberLink(*g_code,&yytext[4]); + } } <ClassDec>{IDENTIFIER} { diff --git a/src/pyscanner.l b/src/pyscanner.l index 1ccb943..c73e7dc 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -745,7 +745,7 @@ STARTDOCSYMS "##" <SearchMemVars>{ "self."{IDENTIFIER}/{B}"=" { - DBG_CTX((stderr,"Found member variable %s in %s at %d\n",&yytext[5],current_root->name.data(),yyLineNr)); + DBG_CTX((stderr,"Found instance method variable %s in %s at %d\n",&yytext[5],current_root->name.data(),yyLineNr)); current->name=&yytext[5]; current->section=Entry::VARIABLE_SEC; current->fileName = yyFileName; @@ -762,6 +762,24 @@ STARTDOCSYMS "##" } newEntry(); } + "cls."{IDENTIFIER}/{B}"=" { + DBG_CTX((stderr,"Found class method variable %s in %s at %d\n",&yytext[4],current_root->name.data(),yyLineNr)); + current->name=&yytext[4]; + current->section=Entry::VARIABLE_SEC; + current->fileName = yyFileName; + current->startLine = yyLineNr; + current->bodyLine = yyLineNr; + current->type.resize(0); + if (current->name.at(0)=='_') // mark as private + { + current->protection=Private; + } + else + { + current->protection=Public; + } + newEntry(); + } {TRIDOUBLEQUOTE} { // start of a comment block initTriDoubleQuoteBlock(); BEGIN(TripleComment); |