summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@theqtcompany.com>2016-02-17 14:41:47 +0100
committerMartin Smith <martin.smith@theqtcompany.com>2016-02-22 09:30:45 +0000
commit1381b25560127fa08c91f6d8ff99ed104a907b82 (patch)
treecd9c413696814fddc85970bf44ea4899fc6bcf64
parent98eebb2dc1830b262d72e748817aee25e54d0d35 (diff)
downloadqttools-1381b25560127fa08c91f6d8ff99ed104a907b82.tar.gz
qdoc: QML basic types can now have methods
\qmlmethod now works for QML basic types. Use it the same way it is used for QML types. \qmlsignal should work now too, but I only tested this for methods. There is now not much difference between QML types and basic types. Change-Id: Ie7dfb01dd2ff0b68944b864ebe29d4a95ba7d550 Task-number: QTBUG-51125 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
-rw-r--r--src/qdoc/codemarker.cpp2
-rw-r--r--src/qdoc/codemarker.h2
-rw-r--r--src/qdoc/cppcodemarker.cpp44
-rw-r--r--src/qdoc/cppcodemarker.h2
-rw-r--r--src/qdoc/cppcodeparser.cpp12
-rw-r--r--src/qdoc/htmlgenerator.cpp26
-rw-r--r--src/qdoc/node.h3
-rw-r--r--src/qdoc/qdocdatabase.cpp24
-rw-r--r--src/qdoc/qdocdatabase.h11
-rw-r--r--src/qdoc/tree.h1
10 files changed, 95 insertions, 32 deletions
diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp
index 3663d5009..d1f186e9a 100644
--- a/src/qdoc/codemarker.cpp
+++ b/src/qdoc/codemarker.cpp
@@ -660,7 +660,7 @@ QString CodeMarker::macName(const Node *node, const QString &name)
/*!
Returns an empty list of documentation sections.
*/
-QList<Section> CodeMarker::qmlSections(QmlTypeNode* , SynopsisStyle , Status )
+QList<Section> CodeMarker::qmlSections(Aggregate* , SynopsisStyle , Status )
{
return QList<Section>();
}
diff --git a/src/qdoc/codemarker.h b/src/qdoc/codemarker.h
index 011c8623d..dd41813c6 100644
--- a/src/qdoc/codemarker.h
+++ b/src/qdoc/codemarker.h
@@ -146,7 +146,7 @@ public:
virtual QList<Section> sections(const Aggregate *inner,
SynopsisStyle style,
Status status) = 0;
- virtual QList<Section> qmlSections(QmlTypeNode* qmlTypeNode,
+ virtual QList<Section> qmlSections(Aggregate* aggregate,
SynopsisStyle style,
Status status = Okay);
virtual QStringList macRefsForNode(Node* node);
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 0f413c7f5..23ac9df93 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -1108,50 +1108,50 @@ QString CppCodeMarker::addMarkUp(const QString &in,
/*!
This function is for documenting QML properties. It returns
the list of documentation sections for the children of the
- \a qmlTypeNode.
+ \a aggregate.
*/
-QList<Section> CppCodeMarker::qmlSections(QmlTypeNode* qmlTypeNode, SynopsisStyle style, Status status)
+QList<Section> CppCodeMarker::qmlSections(Aggregate* aggregate, SynopsisStyle style, Status status)
{
QList<Section> sections;
- if (qmlTypeNode) {
+ if (aggregate) {
if (style == Summary) {
- FastSection qmlproperties(qmlTypeNode,
+ FastSection qmlproperties(aggregate,
"Properties",
QString(),
"property",
"properties");
- FastSection qmlattachedproperties(qmlTypeNode,
+ FastSection qmlattachedproperties(aggregate,
"Attached Properties",
QString(),
"attached property",
"attached properties");
- FastSection qmlsignals(qmlTypeNode,
+ FastSection qmlsignals(aggregate,
"Signals",
QString(),
"signal",
"signals");
- FastSection qmlsignalhandlers(qmlTypeNode,
+ FastSection qmlsignalhandlers(aggregate,
"Signal Handlers",
QString(),
"signal handler",
"signal handlers");
- FastSection qmlattachedsignals(qmlTypeNode,
+ FastSection qmlattachedsignals(aggregate,
"Attached Signals",
QString(),
"attached signal",
"attached signals");
- FastSection qmlmethods(qmlTypeNode,
+ FastSection qmlmethods(aggregate,
"Methods",
QString(),
"method",
"methods");
- FastSection qmlattachedmethods(qmlTypeNode,
+ FastSection qmlattachedmethods(aggregate,
"Attached Methods",
QString(),
"attached method",
"attached methods");
- QmlTypeNode* qcn = qmlTypeNode;
+ Aggregate* qcn = aggregate;
while (qcn != 0) {
NodeList::ConstIterator c = qcn->childNodes().constBegin();
while (c != qcn->childNodes().constEnd()) {
@@ -1206,17 +1206,17 @@ QList<Section> CppCodeMarker::qmlSections(QmlTypeNode* qmlTypeNode, SynopsisStyl
append(sections,qmlattachedmethods);
}
else if (style == Detailed) {
- FastSection qmlproperties(qmlTypeNode, "Property Documentation","qmlprop","member","members");
- FastSection qmlattachedproperties(qmlTypeNode,"Attached Property Documentation","qmlattprop",
+ FastSection qmlproperties(aggregate, "Property Documentation","qmlprop","member","members");
+ FastSection qmlattachedproperties(aggregate,"Attached Property Documentation","qmlattprop",
"member","members");
- FastSection qmlsignals(qmlTypeNode,"Signal Documentation","qmlsig","signal","signals");
- FastSection qmlsignalhandlers(qmlTypeNode,"Signal Handler Documentation","qmlsighan","signal handler","signal handlers");
- FastSection qmlattachedsignals(qmlTypeNode,"Attached Signal Documentation","qmlattsig",
+ FastSection qmlsignals(aggregate,"Signal Documentation","qmlsig","signal","signals");
+ FastSection qmlsignalhandlers(aggregate,"Signal Handler Documentation","qmlsighan","signal handler","signal handlers");
+ FastSection qmlattachedsignals(aggregate,"Attached Signal Documentation","qmlattsig",
"signal","signals");
- FastSection qmlmethods(qmlTypeNode,"Method Documentation","qmlmeth","member","members");
- FastSection qmlattachedmethods(qmlTypeNode,"Attached Method Documentation","qmlattmeth",
+ FastSection qmlmethods(aggregate,"Method Documentation","qmlmeth","member","members");
+ FastSection qmlattachedmethods(aggregate,"Attached Method Documentation","qmlattmeth",
"member","members");
- QmlTypeNode* qcn = qmlTypeNode;
+ Aggregate* qcn = aggregate;
while (qcn != 0) {
NodeList::ConstIterator c = qcn->childNodes().constBegin();
while (c != qcn->childNodes().constEnd()) {
@@ -1275,8 +1275,8 @@ QList<Section> CppCodeMarker::qmlSections(QmlTypeNode* qmlTypeNode, SynopsisStyl
members is prepared.
*/
ClassMap* classMap = 0;
- FastSection all(qmlTypeNode,QString(),QString(),"member","members");
- QmlTypeNode* current = qmlTypeNode;
+ FastSection all(aggregate,QString(),QString(),"member","members");
+ Aggregate* current = aggregate;
while (current != 0) {
/*
If the QML type is abstract, do not create
@@ -1291,7 +1291,7 @@ QList<Section> CppCodeMarker::qmlSections(QmlTypeNode* qmlTypeNode, SynopsisStyl
*/
if (!current->isAbstract() || !classMap) {
classMap = new ClassMap;
- classMap->first = current;
+ classMap->first = static_cast<const QmlTypeNode*>(current);
all.classMapList_.append(classMap);
}
NodeList::ConstIterator c = current->childNodes().constBegin();
diff --git a/src/qdoc/cppcodemarker.h b/src/qdoc/cppcodemarker.h
index aa759f299..67d2b07d9 100644
--- a/src/qdoc/cppcodemarker.h
+++ b/src/qdoc/cppcodemarker.h
@@ -70,7 +70,7 @@ public:
virtual QList<Section> sections(const Aggregate *innerNode,
SynopsisStyle style,
Status status) Q_DECL_OVERRIDE;
- virtual QList<Section> qmlSections(QmlTypeNode* qmlTypeNode,
+ virtual QList<Section> qmlSections(Aggregate* aggregate,
SynopsisStyle style,
Status status = Okay) Q_DECL_OVERRIDE;
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 03b74b83e..29f6a07d4 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -556,11 +556,13 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
(command == COMMAND_JSATTACHEDSIGNAL) ||
(command == COMMAND_JSATTACHEDMETHOD)) {
QString module;
- QString qmlTypeName;
+ QString name;
QString type;
- if (splitQmlMethodArg(arg.first, type, module, qmlTypeName)) {
- QmlTypeNode* qmlType = qdb_->findQmlType(module, qmlTypeName);
- if (qmlType) {
+ if (splitQmlMethodArg(arg.first, type, module, name)) {
+ Aggregate* aggregate = qdb_->findQmlType(module, name);
+ if (!aggregate)
+ aggregate = qdb_->findQmlBasicType(module, name);
+ if (aggregate) {
bool attached = false;
Node::NodeType nodeType = Node::QmlMethod;
if ((command == COMMAND_QMLSIGNAL) ||
@@ -582,7 +584,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
return 0; // never get here.
FunctionNode* fn = makeFunctionNode(doc,
arg.first,
- qmlType,
+ aggregate,
nodeType,
attached,
command);
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 74b93b14d..5e39dd786 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -1630,7 +1630,7 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker*
marker = CodeMarker::markerForLanguage(QLatin1String("QML"));
generateHeader(htmlTitle, qbtn, marker);
- QList<Section> sections = marker->sections(qbtn, CodeMarker::Summary, CodeMarker::Okay);
+ QList<Section> sections = marker->qmlSections(qbtn, CodeMarker::Summary);
generateTableOfContents(qbtn,marker,&sections);
generateKeywordAnchors(qbtn);
generateTitle(htmlTitle,
@@ -1638,6 +1638,17 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker*
subTitleSize,
qbtn,
marker);
+
+ s = sections.constBegin();
+ while (s != sections.constEnd()) {
+ QString ref = registerRef((*s).name.toLower());
+ out() << "<a name=\"" << ref
+ << "\"></a>" << divNavTop << '\n';
+ out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n";
+ generateQmlSummary(*s, qbtn, marker);
+ ++s;
+ }
+
generateExtractionMark(qbtn, DetailedDescriptionMark);
out() << "<div class=\"descr\"> <a name=\"" << registerRef("details") << "\"></a>\n"; // QTBUG-9504
@@ -1645,6 +1656,19 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker*
out() << "</div>\n"; // QTBUG-9504
generateAlsoList(qbtn, marker);
generateExtractionMark(qbtn, EndMark);
+
+ sections = marker->qmlSections(qbtn, CodeMarker::Detailed);
+ s = sections.constBegin();
+ while (s != sections.constEnd()) {
+ out() << "<h2>" << protectEnc((*s).name) << "</h2>\n";
+ NodeList::ConstIterator m = (*s).members.constBegin();
+ while (m != (*s).members.constEnd()) {
+ generateDetailedQmlMember(*m, qbtn, marker);
+ out() << "<br/>\n";
+ ++m;
+ }
+ ++s;
+ }
generateFooter(qbtn);
}
diff --git a/src/qdoc/node.h b/src/qdoc/node.h
index 9df3dd70a..a2acaf572 100644
--- a/src/qdoc/node.h
+++ b/src/qdoc/node.h
@@ -407,6 +407,7 @@ public:
virtual QString outputFileName() const Q_DECL_OVERRIDE { return outputFileName_; }
virtual QmlPropertyNode* hasQmlProperty(const QString& ) const Q_DECL_OVERRIDE;
virtual QmlPropertyNode* hasQmlProperty(const QString&, bool attached) const Q_DECL_OVERRIDE;
+ virtual QmlTypeNode* qmlBaseNode() { return 0; }
void addChild(Node* child, const QString& title);
const QStringList& groupNames() const { return groupNames_; }
virtual void appendGroupName(const QString& t) Q_DECL_OVERRIDE { groupNames_.append(t); }
@@ -647,7 +648,7 @@ public:
const QString& qmlBaseName() const { return qmlBaseName_; }
void setQmlBaseName(const QString& name) { qmlBaseName_ = name; }
bool qmlBaseNodeNotSet() const { return (qmlBaseNode_ == 0); }
- QmlTypeNode* qmlBaseNode();
+ virtual QmlTypeNode* qmlBaseNode() Q_DECL_OVERRIDE;
void setQmlBaseNode(QmlTypeNode* b) { qmlBaseNode_ = b; }
void requireCppClass() { cnodeRequired_ = true; }
bool cppClassRequired() const { return cnodeRequired_; }
diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp
index e3331a4f0..5af7867b3 100644
--- a/src/qdoc/qdocdatabase.cpp
+++ b/src/qdoc/qdocdatabase.cpp
@@ -782,6 +782,30 @@ QmlTypeNode* QDocDatabase::findQmlType(const QString& qmid, const QString& name)
}
/*!
+ Looks up the QML basic type node identified by the Qml module id
+ \a qmid and QML basic type \a name and returns a pointer to the
+ QML basic type node. The key is \a qmid + "::" + \a name.
+
+ If the QML module id is empty, it looks up the QML basic type by
+ \a name only.
+ */
+Aggregate* QDocDatabase::findQmlBasicType(const QString& qmid, const QString& name)
+{
+ if (!qmid.isEmpty()) {
+ QString t = qmid + "::" + name;
+ Aggregate* a = forest_.lookupQmlBasicType(t);
+ if (a)
+ return a;
+ }
+
+ QStringList path(name);
+ Node* n = forest_.findNodeByNameAndType(path, Node::QmlBasicType);
+ if (n && n->isQmlBasicType())
+ return static_cast<Aggregate*>(n);
+ return 0;
+}
+
+/*!
Looks up the QML type node identified by the Qml module id
constructed from the strings in the \a import record and the
QML type \a name and returns a pointer to the QML type node.
diff --git a/src/qdoc/qdocdatabase.h b/src/qdoc/qdocdatabase.h
index d51f9476d..5a6ccd7c0 100644
--- a/src/qdoc/qdocdatabase.h
+++ b/src/qdoc/qdocdatabase.h
@@ -189,6 +189,16 @@ class QDocForest
}
return 0;
}
+
+ Aggregate* lookupQmlBasicType(const QString& name)
+ {
+ foreach (Tree* t, searchOrder()) {
+ Aggregate* a = t->lookupQmlBasicType(name);
+ if (a)
+ return a;
+ }
+ return 0;
+ }
void clearSearchOrder() { searchOrder_.clear(); }
void clearLinkCounts()
{
@@ -253,6 +263,7 @@ class QDocDatabase
QmlTypeNode* findQmlType(const QString& name);
QmlTypeNode* findQmlType(const QString& qmid, const QString& name);
QmlTypeNode* findQmlType(const ImportRec& import, const QString& name);
+ Aggregate* findQmlBasicType(const QString& qmid, const QString& name);
private:
void findAllClasses(Aggregate *node);
diff --git a/src/qdoc/tree.h b/src/qdoc/tree.h
index 0558d693c..35a169a42 100644
--- a/src/qdoc/tree.h
+++ b/src/qdoc/tree.h
@@ -202,6 +202,7 @@ class Tree
CollectionNode* addToJsModule(const QString& name, Node* node);
QmlTypeNode* lookupQmlType(const QString& name) const { return qmlTypeMap_.value(name); }
+ Aggregate* lookupQmlBasicType(const QString& name) const { return qmlTypeMap_.value(name); }
void insertQmlType(const QString& key, QmlTypeNode* n);
void addExampleNode(ExampleNode* n) { exampleNodeMap_.insert(n->title(), n); }
ExampleNodeMap& exampleNodeMap() { return exampleNodeMap_; }