Skip to content

Commit 2bfe59a

Browse files
committed
Add retrieveModuleDocumentation(modName) function to DocParser API.
Reviewer: Luciano Wolf <[email protected]> Marcelo Lira <[email protected]>
1 parent f3a9cdb commit 2bfe59a

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

docparser.h

+9
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ class APIEXTRACTOR_API DocParser
9191
return m_packageName;
9292
}
9393

94+
/**
95+
* Process and retrieves documentation concerning the entire
96+
* module or library.
97+
* \param name module name
98+
* \return object containing module/library documentation information
99+
* \todo Merge with retrieveModuleDocumentation() on next ABI change.
100+
*/
101+
virtual Documentation retrieveModuleDocumentation(const QString& name) = 0;
102+
94103
protected:
95104
QString getDocumentation(QXmlQuery& xquery, const QString& query,
96105
const DocModificationList& mods) const;

qtdocparser.cpp

+23-18
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,7 @@
2828

2929
Documentation QtDocParser::retrieveModuleDocumentation()
3030
{
31-
// TODO: This method of acquiring the module name supposes that the target language uses
32-
// dots as module separators in package names. Improve this.
33-
QString moduleName = QString(packageName()).remove(0, packageName().lastIndexOf('.') + 1);
34-
QString sourceFile = documentationDataDirectory() + '/' + moduleName.toLower() + ".xml";
35-
36-
if (!QFile::exists(sourceFile)) {
37-
ReportHandler::warning("Can't find qdoc3 file for module "
38-
+ packageName() + ", tried: "
39-
+ sourceFile);
40-
return Documentation();
41-
}
42-
43-
QXmlQuery xquery;
44-
xquery.setFocus(QUrl(sourceFile));
45-
46-
// Module documentation
47-
QString query = "/WebXML/document/page[@name=\"" + moduleName + "\"]/description";
48-
return Documentation(getDocumentation(xquery, query, DocModificationList()));
31+
return retrieveModuleDocumentation(packageName());
4932
}
5033

5134
void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass)
@@ -164,3 +147,25 @@ void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass)
164147
meta_enum->setDocumentation(doc);
165148
}
166149
}
150+
151+
Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
152+
{
153+
// TODO: This method of acquiring the module name supposes that the target language uses
154+
// dots as module separators in package names. Improve this.
155+
QString moduleName = QString(name).remove(0, name.lastIndexOf('.') + 1);
156+
QString sourceFile = documentationDataDirectory() + '/' + moduleName.toLower() + ".xml";
157+
158+
if (!QFile::exists(sourceFile)) {
159+
ReportHandler::warning("Can't find qdoc3 file for module "
160+
+ name + ", tried: "
161+
+ sourceFile);
162+
return Documentation();
163+
}
164+
165+
QXmlQuery xquery;
166+
xquery.setFocus(QUrl(sourceFile));
167+
168+
// Module documentation
169+
QString query = "/WebXML/document/page[@name=\"" + moduleName + "\"]/description";
170+
return Documentation(getDocumentation(xquery, query, DocModificationList()));
171+
}

qtdocparser.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class APIEXTRACTOR_API QtDocParser : public DocParser
3232
QtDocParser() {}
3333
virtual void fillDocumentation(AbstractMetaClass* metaClass);
3434
virtual Documentation retrieveModuleDocumentation();
35+
virtual Documentation retrieveModuleDocumentation(const QString& name);
3536
};
3637

3738
#endif // QTDOCPARSER_H

0 commit comments

Comments
 (0)