[Doxygen-develop] Doxygen doesn't handle elaborated type specifiers in method parameters correctly
Brought to you by:
dimitri
From: John S. <jsc...@gm...> - 2011-05-23 04:07:18
|
Doxygen Developers, I am new to this list but I have been hacking doxygen to get it to work for me while working on the documentation for the Haiku OS. Congratulations on creating such a great project with code that is so easy to read and modify. I have come across an issue with doxygen not handling elaborated type specifiers correctly. More information on what an elaborated type specifier is can be found here: http://msdn.microsoft.com/en-us/library/f432x8c6%28v=vs.80%29.aspx In short you can include enum, class, struct, or union in front of a method parameter name. In C++ this is normally optional but if you use the same type name as the param name then it is required to differentiate them. Anyway, this is valid C++ and doxygen doesn't parse this correctly. It instead treats the entire parameter as a type with no name. Here is an example where this is happening in the documentation for Haiku: http://api.haiku-os.org/classBTwoDimensionalLayout.html#a8db0a165b3ee1275447af5043d69f00f Here is the doxygen documentation code for the GetColumnRowConstraints() function linked above. You can use this code to test the presence of the bug. /*! \fn void BTwoDimensionalLayout::GetColumnRowConstraints(enum orientation orientation, int32 index, ColumnRowConstraints* constraints) \brief Fill in the ColumnRowConstraints for a certain column or row in this BTwoDimensionalLayout. This method is used to communicate the size constraints and weight for a given row/column in this BTwoDimensionalLayout. */ I have modified doxygen to correct this. It treats the symptoms (fixes the parsing up after the fact in memberdef.cpp) and not the disease (the parsing code) but it should be sufficient I think. The patch to correct this issue on top of SVN rev 765 is below. If this patch passes your requirements it would be someone committed it, if not, perhaps I can get some pointers to make it better. Index: src/memberdef.cpp =================================================================== --- src/memberdef.cpp (revision 765) +++ src/memberdef.cpp (working copy) @@ -184,6 +184,25 @@ if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } if (a->type!="...") { + if (a->name.isEmpty()) + { + int sp = a->type.find(' '); + int mp = a->type.find(' ', sp+1); + if (sp!=-1 && mp!=-1 && mp>sp && + ( + a->type.left((uint)sp) == "enum" || + a->type.left((uint)sp) == "struct" || + a->type.left((uint)sp) == "union" || + a->type.left((uint)sp) == "class" + ) + ) + // parameter type has an elaborated type specifier. + { + a->name = a->type.mid((uint)mp+1); + n = a->type = a->type.left((uint)mp); + if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } + } + } if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName); linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md->name(),n); } Thank you, John Scipione |