From 69f51747c37bb24b7e296ff01bb7e45a624f6225 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Sun, 4 Aug 2019 22:22:12 -0300 Subject: doxyparse addon new features and bugfixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this commit is a squashed merge from lots of doxyparse evolution and concentrates contributions from many authors, all listed at the end of this message as Signed-off-by follow a list of all improvements and bugfixes on doxyparse: * workarounding strings replaced by doxygen core * print missing module name for some C code (analizo/analizo#155) * do not count/print 'void' as a function argument * rough instructions for doxyparse release * limit identifiers to 1024 chars (analizo/analizo#135) * removing "\\" from function signatures (analizo/analizo#138) * fix override args references (analizo/analizo#79) * check if new_data in removeDoubleQuotes function is empty (analizo/analizo#120) * removing double quotes from function signature (analizo/analizo#117) * check if ArgumentList is null (analizo/analizo#116) * don't report same module/class more than once (analizo/analizo#112) * add missing key "defines:" to all modules (analizo/analizo#111) * check if string is larger than 1 before removing surrounding quotes (analizo/analizo#110) * doxyparse properly detects package methods * output inheritance as list instead of hash * start yaml document: --- * adding double quoted in module name (analizo/analizo#106) * added --version flag to doxyparse * removing double quotes from function arguments list * fix doxyparse segfault for python source files * using quotes to surround members definition on yaml * add the number of conditionals path * generate configvalues.h * adding .cs (csharp) as non-C file extension * adding .pyw (python) as non-C file extension * adding .py (python) as non-C file extension Signed-off-by: Antonio Terceiro Signed-off-by: Henrique Dutra Signed-off-by: Igor Ribeiro Barbosa Duarte Signed-off-by: João M. Miranda Signed-off-by: Jonathan Moraes Signed-off-by: Kleber Signed-off-by: leonardork Signed-off-by: Marcelo Ferreira Signed-off-by: Mateus Andrade Signed-off-by: Matheus Miranda Signed-off-by: Paulo Meirelles Signed-off-by: Sabryna de Sousa Signed-off-by: Vinicius Daros Signed-off-by: VinyPinheiro --- addon/doxyparse/README | 14 +++- addon/doxyparse/doxyparse.cpp | 147 ++++++++++++++++++++++++++++++++---------- src/code.l | 16 +++++ src/memberdef.cpp | 11 ++++ src/memberdef.h | 5 ++ 5 files changed, 158 insertions(+), 35 deletions(-) diff --git a/addon/doxyparse/README b/addon/doxyparse/README index 288b31e..95cce8c 100644 --- a/addon/doxyparse/README +++ b/addon/doxyparse/README @@ -18,8 +18,20 @@ More info and source code repository: https://github.com/analizo/doxygen sudo make install +## release + +* ensure analizo testsuite passing on newer doxyparse version +* update debian/changelog, commit, push +* create git tag, push to github analizo/doxyparse +* build on amd64 and i386 archs, upload tar.gz to github + * tar -zcf doxyparse__amd64.tar.gz -C bin/ doxyparse + * tar -zcf doxyparse__i386.tar.gz -C bin/ doxyparse +* build debian packages for amd64 and i386, update analizo.org repository + * (see analizo.github.io/README.md file for updating repository instructions) + * upload the deb files to github release tag also +* check if a alien-doxyparse release is necessary and do it on cpan + AUTHORS -======= Antonio Terceiro João M. Miranda diff --git a/addon/doxyparse/doxyparse.cpp b/addon/doxyparse/doxyparse.cpp index 26ecea9..babf3d7 100644 --- a/addon/doxyparse/doxyparse.cpp +++ b/addon/doxyparse/doxyparse.cpp @@ -24,6 +24,7 @@ #else #include #endif +#include "version.h" #include "doxygen.h" #include "outputgen.h" #include "parserintf.h" @@ -40,6 +41,9 @@ #include #include #include +#include +#include +#include "namespacedef.h" class Doxyparse : public CodeOutputInterface { @@ -81,8 +85,6 @@ class Doxyparse : public CodeOutputInterface }; static bool is_c_code = true; -static std::map modules; -static std::string current_module; static void findXRefSymbols(FileDef *fd) { @@ -107,7 +109,7 @@ static void findXRefSymbols(FileDef *fd) static bool ignoreStaticExternalCall(MemberDef *context, MemberDef *md) { if (md->isStatic()) { - if(md->getFileDef()) { + if(md->getFileDef() && context->getFileDef()) { if(md->getFileDef()->getOutputFileBase() == context->getFileDef()->getOutputFileBase()) // TODO ignore prefix of file return false; @@ -123,27 +125,48 @@ static bool ignoreStaticExternalCall(MemberDef *context, MemberDef *md) { } } +// that undo some replacing by src/util.cpp escapeCharsInString(...) +// * https://github.com/doxygen/doxygen/pull/577 +std::string unescapeCharsInString(std::string name) { + QCString module = QCString(name.c_str()); + bool replaced = false; + if (module.find('.') == -1) { + module.replace(QRegExp("_8"), "."); + replaced = true; + } + if (module.find('/') == -1) { + module.replace(QRegExp("_2"), "/"); + replaced = true; + } + if (replaced) { + module.replace(QRegExp("__"), "_"); + } + return module.data(); +} + +static void startYamlDocument() { + printf("---\n"); +} static void printFile(std::string file) { printf("%s:\n", file.c_str()); } static void printModule(std::string module) { - current_module = module; - printf(" %s:\n", module.c_str()); + printf(" \"%s\":\n", unescapeCharsInString(module).c_str()); } static void printClassInformation(std::string information) { printf(" information: %s\n", information.c_str()); } +static void printInherits() { + printf(" inherits:\n"); +} static void printInheritance(std::string base_class) { - printf(" inherits: %s\n", base_class.c_str()); + printf(" - %s\n", base_class.c_str()); } static void printDefines() { - if (! modules[current_module]) { - printf(" defines:\n"); - } - modules[current_module] = true; + printf(" defines:\n"); } static void printDefinition(std::string type, std::string signature, int line) { - printf(" - \"%s\":\n", signature.c_str()); + printf(" - \"%s\":\n", signature.substr(0, 1022).c_str()); printf(" type: %s\n", type.c_str()); printf(" line: %d\n", line); } @@ -160,44 +183,47 @@ static void printUses() { printf(" uses:\n"); } static void printReferenceTo(std::string type, std::string signature, std::string defined_in) { - printf(" - \"%s\":\n", signature.c_str()); + printf(" - \"%s\":\n", signature.substr(0, 1022).c_str()); printf(" type: %s\n", type.c_str()); - printf(" defined_in: %s\n", defined_in.c_str()); + printf(" defined_in: \"%s\"\n", unescapeCharsInString(defined_in).c_str()); +} +static void printNumberOfConditionalPaths(MemberDef* md) { + printf(" conditional_paths: %d\n", md->numberOfFlowKeyWords()); } static int isPartOfCStruct(MemberDef * md) { return is_c_code && md->getClassDef() != NULL; } -std::string removeDoubleQuotes(std::string data) { - // remove surrounding double quotes - if (data.front() == '"' && data.back() == '"') { - data.erase(0, 1); // first double quote - data.erase(data.size() - 1); // last double quote - } - return data; +std::string sanitizeString(std::string data) { + QCString new_data = QCString(data.c_str()); + new_data.replace(QRegExp("\""), ""); + new_data.replace(QRegExp("\\"), ""); // https://github.com/analizo/analizo/issues/138 + return !new_data.isEmpty() ? new_data.data() : ""; } std::string argumentData(Argument *argument) { std::string data = ""; - if (argument->type != NULL) - data = removeDoubleQuotes(argument->type.data()); + if (argument->type != NULL && argument->type.size() > 1) + data = sanitizeString(argument->type.data()); else if (argument->name != NULL) - data = removeDoubleQuotes(argument->name.data()); + data = sanitizeString(argument->name.data()); return data; } std::string functionSignature(MemberDef* md) { - std::string signature = md->name().data(); + std::string signature = sanitizeString(md->name().data()); if(md->isFunction()){ ArgumentList *argList = md->argumentList(); - ArgumentListIterator iterator(*argList); signature += "("; - Argument * argument = iterator.toFirst(); - if(argument != NULL) { - signature += argumentData(argument); - for(++iterator; (argument = iterator.current()); ++iterator){ - signature += std::string(",") + argumentData(argument); + if (argList) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + if(argument != NULL) { + signature += argumentData(argument); + for(++iterator; (argument = iterator.current()); ++iterator) { + signature += std::string(",") + argumentData(argument); + } } } signature += ")"; @@ -221,6 +247,9 @@ static void referenceTo(MemberDef* md) { else if (md->getFileDef()) { defined_in = md->getFileDef()->getOutputFileBase().data(); } + else if (md->getNamespaceDef()) { + defined_in = md->getNamespaceDef()->name().data(); + } } printReferenceTo(type, signature, defined_in); } @@ -228,6 +257,12 @@ static void referenceTo(MemberDef* md) { void cModule(ClassDef* cd) { MemberList* ml = cd->getMemberList(MemberListType_variableMembers); if (ml) { + FileDef *fd = cd->getFileDef(); + MemberList *fd_ml = fd->getMemberList(MemberListType_allMembersList); + if (!fd_ml || fd_ml->count() == 0) { + printModule(fd->getOutputFileBase().data()); + printDefines(); + } MemberListIterator mli(*ml); MemberDef* md; for (mli.toFirst(); (md=mli.current()); ++mli) { @@ -239,18 +274,50 @@ void cModule(ClassDef* cd) { } } +static bool checkOverrideArg(ArgumentList *argList, MemberDef *md) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + + if(!md->isFunction() || argList->count() == 0){ + return false; + } + + if(argument != NULL) { + for(; (argument = iterator.current()); ++iterator){ + if(md->name() == argument->name) { + return true; + } + } + } + + return false; +} + void functionInformation(MemberDef* md) { + std::string temp = ""; int size = md->getEndBodyLine() - md->getStartBodyLine() + 1; printNumberOfLines(size); ArgumentList *argList = md->argumentList(); - printNumberOfArguments(argList->count()); + if (argList) { + ArgumentListIterator iterator(*argList); + Argument * argument = iterator.toFirst(); + if(argument != NULL) { + temp = argumentData(argument); +// TODO: This is a workaround; better not include "void" in argList, in the first place. + if(temp != "void") { + printNumberOfArguments(argList->count()); + } + } + } + + printNumberOfConditionalPaths(md); MemberSDict *defDict = md->getReferencesMembers(); if (defDict) { MemberSDict::Iterator msdi(*defDict); MemberDef *rmd; printUses(); for (msdi.toFirst(); (rmd=msdi.current()); ++msdi) { - if (rmd->definitionType() == Definition::TypeMember && !ignoreStaticExternalCall(md, rmd)) { + if (rmd->definitionType() == Definition::TypeMember && !ignoreStaticExternalCall(md, rmd) && !checkOverrideArg(argList, rmd)) { referenceTo(rmd); } } @@ -276,7 +343,6 @@ void listMembers(MemberList *ml) { if (ml) { MemberListIterator mli(*ml); MemberDef *md; - printDefines(); for (mli.toFirst(); (md=mli.current()); ++mli) { lookupSymbol((Definition*) md); } @@ -299,6 +365,7 @@ static void classInformation(ClassDef* cd) { printModule(cd->name().data()); BaseClassList* baseClasses = cd->baseClasses(); if (baseClasses) { + printInherits(); BaseClassListIterator bci(*baseClasses); BaseClassDef* bcd; for (bci.toFirst(); (bcd = bci.current()); ++bci) { @@ -308,6 +375,7 @@ static void classInformation(ClassDef* cd) { if(cd->isAbstract()) { printClassInformation("abstract class"); } + printDefines(); listAllMembers(cd); } } @@ -356,6 +424,7 @@ static void listSymbols() { MemberList *ml = fd->getMemberList(MemberListType_allMembersList); if (ml && ml->count() > 0) { printModule(fd->getOutputFileBase().data()); + printDefines(); listMembers(ml); } @@ -364,7 +433,10 @@ static void listSymbols() { ClassSDict::Iterator cli(*classes); ClassDef *cd; for (cli.toFirst(); (cd = cli.current()); ++cli) { - classInformation(cd); + if (!cd->isVisited()) { + classInformation(cd); + cd->setVisited(TRUE); + } } } } @@ -377,6 +449,11 @@ int main(int argc,char **argv) { printf("Usage: %s [source_file | source_dir]\n",argv[0]); exit(1); } + if (qstrcmp(&argv[1][2], "version") == 0) { + QCString versionString = getVersion(); + printf("%s\n", versionString); + exit(0); + } // initialize data structures initDoxygen(); @@ -411,6 +488,7 @@ int main(int argc,char **argv) { Config_getBool(EXTRACT_STATIC)=TRUE; Config_getBool(EXTRACT_PRIVATE)=TRUE; Config_getBool(EXTRACT_LOCAL_METHODS)=TRUE; + Config_getBool(EXTRACT_PACKAGE)=TRUE; // Extract source browse information, needed // to make doxygen gather the cross reference info Config_getBool(SOURCE_BROWSER)=TRUE; @@ -464,6 +542,7 @@ int main(int argc,char **argv) { // clean up after us thisDir.rmdir(Config_getString(OUTPUT_DIRECTORY)); + startYamlDocument(); listSymbols(); std::string cleanup_command = "rm -rf "; diff --git a/src/code.l b/src/code.l index 8df0085..45429c3 100644 --- a/src/code.l +++ b/src/code.l @@ -2472,6 +2472,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" BEGIN(FuncCall); } {FLOWCONDITION}/{BN}*"(" { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -2489,6 +2493,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" } } {FLOWCONDITION}/([^a-z_A-Z0-9]) { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -2503,6 +2511,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" endFontClass(); } {FLOWCONDITION}/{B}* { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } startFontClass("keywordflow"); codifyLines(yytext); endFontClass(); @@ -3038,6 +3050,10 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" endFontClass(); } {FLOWCONDITION}/([^a-z_A-Z0-9]) { + if (g_currentMemberDef && g_currentMemberDef->isFunction()) + { + g_currentMemberDef->addFlowKeyWord(); + } addParmType(); g_parmName=yytext; startFontClass("keywordflow"); diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 4693bdb..d0b70bb 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -1581,6 +1581,7 @@ MemberDefImpl::MemberDefImpl(const char *df,int dl,int dc, //printf("MemberDefImpl::MemberDef(%s)\n",na); m_impl = new MemberDefImpl::IMPL; m_impl->init(this,t,a,e,p,v,s,r,mt,tal,al,meta); + number_of_flowkw = 1; m_isLinkableCached = 0; m_isConstructorCached = 0; m_isDestructorCached = 0; @@ -5970,6 +5971,16 @@ void MemberDefImpl::invalidateCachedArgumentTypes() invalidateCachedTypesInArgumentList(m_impl->declArgList); } +void MemberDef::addFlowKeyWord() +{ + number_of_flowkw++; +} + +int MemberDef::numberOfFlowKeyWords() +{ + return number_of_flowkw; +} + //---------------- QCString MemberDefImpl::displayName(bool) const diff --git a/src/memberdef.h b/src/memberdef.h index af4fb0a..a94005f 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -183,6 +183,7 @@ class MemberDef : virtual public Definition virtual bool isSliceLocal() const = 0; virtual bool isConstExpr() const = 0; + int numberOfFlowKeyWords(); // derived getters virtual bool isFriendToHide() const = 0; virtual bool isNotFriend() const = 0; @@ -280,6 +281,8 @@ class MemberDef : virtual public Definition // ---- setters ----- //----------------------------------------------------------------------------------- + void addFlowKeyWord(); + // set functions virtual void setMemberType(MemberType t) = 0; virtual void setDefinition(const char *d) = 0; @@ -405,6 +408,8 @@ class MemberDef : virtual public Definition const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, bool onlyText=FALSE) const = 0; + int number_of_flowkw; + // write helpers virtual void warnIfUndocumented() const = 0; virtual void warnIfUndocumentedParams() const = 0; -- cgit v0.12