Skip to content

Commit 9ccc24f

Browse files
Bruno dos Santos de Araujohugopl
Bruno dos Santos de Araujo
authored andcommitted
Doxygen support
1 parent 93001f6 commit 9ccc24f

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ docparser.h
162162
qtdocparser.h
163163
include.h
164164
typedatabase.h
165+
doxygenparser.h
165166
)
166167

167168
if (BUILD_TESTS)

doxygenparser.cpp

+38-4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ QString getSectionKindAttr(const AbstractMetaFunction* func)
4646

4747
}
4848

49+
Documentation DoxygenParser::retrieveModuleDocumentation()
50+
{
51+
return retrieveModuleDocumentation(packageName());
52+
}
53+
4954
void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
5055
{
5156
if (!metaClass)
@@ -60,11 +65,12 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
6065
doxyFileSuffix += ".xml";
6166

6267
const char* prefixes[] = { "class", "struct", "namespace" };
63-
const int numPrefixes = sizeof(prefixes);
68+
const int numPrefixes = sizeof(prefixes) / sizeof(const char*);
69+
bool isProperty = false;
6470

6571
QString doxyFilePath;
6672
for (int i = 0; i < numPrefixes; ++i) {
67-
doxyFilePath = documentationDataDirectory() + "./" + prefixes[i] + doxyFileSuffix;
73+
doxyFilePath = documentationDataDirectory() + "/" + prefixes[i] + doxyFileSuffix;
6874
if (QFile::exists(doxyFilePath))
6975
break;
7076
doxyFilePath.clear();
@@ -101,6 +107,7 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
101107
|| func->isPropertyResetter()) {
102108
query += "[@kind=\"property\"]/memberdef/name[text()=\""
103109
+ func->propertySpec()->name() + "\"]";
110+
isProperty = true;
104111
} else { // normal methods
105112
QString kind = getSectionKindAttr(func);
106113
query += "[@kind=\"" + kind + "-func\"]/memberdef/name[text()=\""
@@ -124,9 +131,15 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
124131
}
125132
}
126133
}
127-
query += "/../detaileddescription";
134+
if (!isProperty) {
135+
query += "/../detaileddescription";
136+
} else {
137+
query = "(" + query;
138+
query += "/../detaileddescription)[1]";
139+
}
128140
QString doc = getDocumentation(xquery, query, DocModificationList());
129141
func->setDocumentation(doc);
142+
isProperty = false;
130143
}
131144

132145
//Fields
@@ -144,8 +157,29 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
144157
//Enums
145158
AbstractMetaEnumList enums = metaClass->enums();
146159
foreach (AbstractMetaEnum *meta_enum, enums) {
147-
QString query = "/doxygen/compounddef/sectiondef/memberdef[@kind=\"enum\"]/name[text()=\"" + meta_enum->name() + "\"]/../detaileddescription";
160+
QString query = "/doxygen/compounddef/sectiondef/memberdef[@kind=\"enum\"]/name[text()=\"" + meta_enum->name() + "\"]/..";
148161
QString doc = getDocumentation(xquery, query, DocModificationList());
149162
meta_enum->setDocumentation(doc);
150163
}
164+
165+
}
166+
167+
Documentation DoxygenParser::retrieveModuleDocumentation(const QString& name){
168+
169+
QString sourceFile = documentationDataDirectory() + '/' + "indexpage.xml";
170+
171+
if (!QFile::exists(sourceFile)) {
172+
ReportHandler::warning("Can't find doxygen XML file for module "
173+
+ name + ", tried: "
174+
+ sourceFile);
175+
return Documentation();
176+
}
177+
178+
QXmlQuery xquery;
179+
xquery.setFocus(QUrl(sourceFile));
180+
181+
// Module documentation
182+
QString query = "/doxygen/compounddef/detaileddescription";
183+
return Documentation(getDocumentation(xquery, query, DocModificationList()));
151184
}
185+

doxygenparser.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
#include "docparser.h"
2828

29-
class DoxygenParser : public DocParser
29+
class APIEXTRACTOR_API DoxygenParser : public DocParser
3030
{
3131
public:
3232
DoxygenParser() {}
3333
virtual void fillDocumentation(AbstractMetaClass *metaClass);
34-
virtual Documentation retrieveModuleDocumentation() { return Documentation(); }
34+
virtual Documentation retrieveModuleDocumentation();
35+
virtual Documentation retrieveModuleDocumentation(const QString& name);
3536
};
3637

3738
#endif // DOXYGENPARSER_H

0 commit comments

Comments
 (0)