summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/preprocessor.cpp7
-rw-r--r--src/tools/moc/preprocessor.h3
-rw-r--r--src/tools/moc/symbols.h15
-rw-r--r--src/tools/qdoc/cppcodemarker.cpp27
-rw-r--r--src/tools/qdoc/ditaxmlgenerator.cpp5
-rw-r--r--src/tools/qdoc/doc/qdoc-manual.qdoc93
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp5
-rw-r--r--src/tools/qdoc/node.cpp35
-rw-r--r--src/tools/qdoc/node.h34
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp101
-rw-r--r--src/tools/qdoc/qdocdatabase.h1
-rw-r--r--src/tools/qdoc/qdocindexfiles.cpp61
-rw-r--r--src/tools/qdoc/qmlvisitor.cpp41
-rw-r--r--src/tools/qdoc/qmlvisitor.h3
14 files changed, 372 insertions, 59 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 96b920b7cd..8f4b84a9c8 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -536,12 +537,14 @@ static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode m
return symbols;
}
-Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one)
+Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &index,
+ int lineNum, bool one, const QSet<QByteArray> &excludeSymbols)
{
SymbolStack symbols;
SafeSymbols sf;
sf.symbols = toExpand;
sf.index = index;
+ sf.excludedSymbols = excludeSymbols;
symbols.push(sf);
Symbols result;
@@ -664,7 +667,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
if (i == macro.symbols.size() - 1 || macro.symbols.at(i + 1).token != PP_HASHHASH) {
Symbols arg = arguments.at(index);
int idx = 1;
- expansion += macroExpand(that, arg, idx, lineNum, false);
+ expansion += macroExpand(that, arg, idx, lineNum, false, symbols.excludeSymbols());
} else {
expansion += arguments.at(index);
}
diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h
index 55e452a2bd..72d02a3292 100644
--- a/src/tools/moc/preprocessor.h
+++ b/src/tools/moc/preprocessor.h
@@ -85,7 +85,8 @@ public:
void substituteUntilNewline(Symbols &substituted);
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName);
- static Symbols macroExpand(Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one);
+ static Symbols macroExpand(Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one,
+ const QSet<QByteArray> &excludeSymbols = QSet<QByteArray>());
int evaluateCondition();
diff --git a/src/tools/moc/symbols.h b/src/tools/moc/symbols.h
index 35d4ed6ec9..b588cd5beb 100644
--- a/src/tools/moc/symbols.h
+++ b/src/tools/moc/symbols.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -134,6 +135,7 @@ typedef QVector<Symbol> Symbols;
struct SafeSymbols {
Symbols symbols;
QByteArray expandedMacro;
+ QSet<QByteArray> excludedSymbols;
int index;
};
@@ -159,6 +161,7 @@ public:
inline QByteArray unquotedLexem() { return symbol().unquotedLexem(); }
bool dontReplaceSymbol(const QByteArray &name);
+ QSet<QByteArray> excludeSymbols();
};
inline bool SymbolStack::test(Token token)
@@ -178,12 +181,22 @@ inline bool SymbolStack::test(Token token)
inline bool SymbolStack::dontReplaceSymbol(const QByteArray &name)
{
for (int i = 0; i < size(); ++i) {
- if (name == at(i).expandedMacro)
+ if (name == at(i).expandedMacro || at(i).excludedSymbols.contains(name))
return true;
}
return false;
}
+inline QSet<QByteArray> SymbolStack::excludeSymbols()
+{
+ QSet<QByteArray> set;
+ for (int i = 0; i < size(); ++i) {
+ set << at(i).expandedMacro;
+ set += at(i).excludedSymbols;
+ }
+ return set;
+}
+
QT_END_NAMESPACE
#endif // SYMBOLS_H
diff --git a/src/tools/qdoc/cppcodemarker.cpp b/src/tools/qdoc/cppcodemarker.cpp
index c85c5c64ef..f0cfc18515 100644
--- a/src/tools/qdoc/cppcodemarker.cpp
+++ b/src/tools/qdoc/cppcodemarker.cpp
@@ -1259,7 +1259,6 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
}
else {
FastSection all(qmlClassNode,QString(),QString(),"member","members");
-
const QmlClassNode* current = qmlClassNode;
while (current != 0) {
NodeList::ConstIterator c = current->childNodes().constBegin();
@@ -1271,9 +1270,9 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
if ((*p)->type() == Node::QmlProperty) {
QString key = current->name() + "::" + (*p)->name();
key = sortName(*p, &key);
- if (!all.memberMap.contains(key))
+ if (!all.memberMap.contains(key)) {
all.memberMap.insert(key,*p);
- //insert(all,*p,style,Okay);
+ }
}
++p;
}
@@ -1281,23 +1280,21 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
else {
QString key = current->name() + "::" + (*c)->name();
key = sortName(*c, &key);
- if (!all.memberMap.contains(key))
+ if (!all.memberMap.contains(key)) {
all.memberMap.insert(key,*c);
- //insert(all,*c,style,Okay);
+ }
}
++c;
}
- const DocNode* dn = current->qmlBaseNode();
- if (dn) {
- if (dn->subType() == Node::QmlClass)
- current = static_cast<const QmlClassNode*>(dn);
- else {
- dn->doc().location().warning(tr("Base class of QML class '%1' is ambgiguous").arg(current->name()));
- current = 0;
- }
+ current = current->qmlBaseNode();
+ while (current) {
+ if (current->isAbstract())
+ break;
+ if (current->isInternal())
+ current = current->qmlBaseNode();
+ else
+ break;
}
- else
- current = 0;
}
append(sections, all, true);
}
diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp
index 22694dd0d3..21bbdafaf5 100644
--- a/src/tools/qdoc/ditaxmlgenerator.cpp
+++ b/src/tools/qdoc/ditaxmlgenerator.cpp
@@ -4198,7 +4198,10 @@ void DitaXmlGenerator::generateQmlInherits(const QmlClassNode* qcn, CodeMarker*
{
if (!qcn)
return;
- const DocNode* base = qcn->qmlBaseNode();
+ const QmlClassNode* base = qcn->qmlBaseNode();
+ while (base && base->isInternal()) {
+ base = base->qmlBaseNode();
+ }
if (base) {
writeStartTag(DT_qmlInherits);
//writeStartTag(DT_qmlTypeDef);
diff --git a/src/tools/qdoc/doc/qdoc-manual.qdoc b/src/tools/qdoc/doc/qdoc-manual.qdoc
index 4d70faa968..b715b200bf 100644
--- a/src/tools/qdoc/doc/qdoc-manual.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual.qdoc
@@ -65,6 +65,7 @@
\li \l {C++ Specific Configuration Variables}
\li \l {HTML Specific Configuration Variables}
\li \l {Supporting Derived Projects}
+ \li \l {Example Manifest Files}
\li \l {qt.qdocconf}
\li \l {minimum.qdocconf}
\li \l {Generating DITA XML Output}
@@ -7154,6 +7155,7 @@
\li \l {22-qdoc-configuration-generalvariables.html#images.fileextensions-variable} {images.fileextensions}
\li \l {22-qdoc-configuration-generalvariables.html#language-variable} {language}
\li \l {22-qdoc-configuration-generalvariables.html#macro-variable} {macro}
+ \li \l {22-qdoc-configuration-generalvariables.html#manifestmeta-variable} {manifestmeta}
\li \l {22-qdoc-configuration-generalvariables.html#outputdir-variable} {outputdir}
\li \l {22-qdoc-configuration-generalvariables.html#outputformats-variable} {outputformats}
\li \l {22-qdoc-configuration-generalvariables.html#sourcedirs-variable} {sourcedirs}
@@ -7850,6 +7852,14 @@
See also \l {alias-variable} {alias}.
+ \target manifestmeta-variable
+ \section1 manifestmeta
+
+ The \c manifestmeta variable specifies additional meta-content
+ for the example manifest files generated by QDoc.
+
+ See the \l{Manifest Meta Content} section for more information.
+
\target naturallanguage-variable
\section1 naturallanguage
@@ -8472,6 +8482,7 @@
\page 25-qdoc-configuration-derivedprojects.html
\previouspage HTML Specific Configuration Variables
\contentspage QDoc Manual
+ \nextpage Example Manifest Files
\title Supporting Derived Projects
@@ -8610,6 +8621,88 @@
*/
/*!
+ \page 26-qdoc-configuration-example-manifest-files.html
+ \previouspage Supporting Derived Projects
+ \contentspage QDoc Manual
+
+ \title Example Manifest Files
+
+ QDoc generates XML files that contain information about all documented
+ examples and demos. These files, named \c {examples-manifest.xml} and
+ \c {demos-manifest.xml}, are used by Qt Creator to present a list of
+ examples in its welcome screen and to link to their documentation.
+
+ \section1 Manifest XML Structure
+
+ A manifest file has the following structure:
+
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ <instructionals module="QtGui">
+ <examples>
+ <example
+ name="Analog Clock Window Example"
+ docUrl="qthelp://org.qt-project.qtgui.502/qtgui/analogclock.html"
+ projectPath="gui/analogclock/analogclock.pro"
+ imageUrl="qthelp://org.qt-project.qtgui.502/qtgui/images/analogclock-window-example.png">
+ <description><![CDATA[The Analog Clock Window example shows how
+ to draw the contents of a custom window.]]></description>
+ <tags>analog,clock,window</tags>
+ <fileToOpen>gui/analogclock/main.cpp</fileToOpen>
+ </example>
+ ...
+ </examples>
+ </instructionals>
+ \endcode
+
+ Each \c {<example>} element contains information about a name,
+ description, the location of the project file and documentation,
+ as well as a list of tags associated with the example.
+
+ \target metacontent
+ \section1 Manifest Meta Content
+
+ It is possible to augment the manifest files with additional
+ meta-content - that is, extra attributes and tags for selected
+ examples, using the \c manifestmeta configuration command.
+
+ One use case for meta-content is highlighting a number of prominent
+ examples. Another is improving search functionality by adding
+ relevant keywords as tags for a certain category of examples.
+
+ The examples for which meta-content is applied to is specified using
+ one or more filters. Matching examples to filters is done based on
+ names, with each example name prefixed with a module name and a
+ slash. Simple wildcard matching is supported; by using \c {*} at the
+ end it's possible to match multiple examples with a single string.
+
+ Example:
+
+ \code
+ manifestmeta.filters = highlighted sql webkit global
+
+ manifestmeta.highlighted.names = "QtGui/Analog Clock Window Example" \
+ "QtWidgets/Analog Clock Example"
+ manifestmeta.highlighted.attributes = isHighlighted:true
+
+ manifestmeta.sql.names = "QtSql/*"
+ manifestmeta.sql.tags = database,sql
+
+ manifestmeta.webkit.names = "QtWebKitExamples/*"
+ manifestmeta.webkit.tags = webkit
+
+ manifestmeta.global.names = *
+ manifestmeta.global.tags = qt5
+ \endcode
+
+ Above, an \c isHighlighted attribute is added to two examples. If
+ the attribute value is omitted, QDoc uses the string \c {true} by
+ default. Extra tags are added for Qt WebKit and Qt SQL examples, and
+ another tag is applied to all examples by using just \c {*} as the
+ match string.
+*/
+
+/*!
\page 27-qdoc-commands-alphabetical.html
\previouspage Introduction to QDoc
\contentspage QDoc Manual
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index 2666f10eb4..69d1a69d31 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -3870,7 +3870,10 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* qcn, CodeMarker* mar
{
if (!qcn)
return;
- const DocNode* base = qcn->qmlBaseNode();
+ const QmlClassNode* base = qcn->qmlBaseNode();
+ while (base && base->isInternal()) {
+ base = base->qmlBaseNode();
+ }
if (base) {
Text text;
text << Atom::ParaLeft << "Inherits ";
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index 5fbdb487db..c293d48673 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -662,6 +662,16 @@ bool InnerNode::hasMembers() const
}
/*!
+ Appends \a node to the members list, if and only if it
+ isn't already in the members list.
+ */
+void InnerNode::addMember(Node* node)
+{
+ if (!members_.contains(node))
+ members_.append(node);
+}
+
+/*!
Returns true if this node's members collection contains at
least one namespace node.
*/
@@ -2161,10 +2171,13 @@ void QmlClassNode::subclasses(const QString& base, NodeList& subs)
This function splits \a arg on the blank character to get a
QML module name and version number. It then spilts the version
number on the '.' character to get a major version number and
- a minor vrsion number. Both version numbers must be present.
- It stores these components separately. If all three are found,
- true is returned. If any of the three is not found or is not
- correct, false is returned.
+ a minor vrsion number. Both major the major and minor version
+ numbers should be present, but the minor version number is not
+ absolutely necessary.
+
+ It stores the three components separately in this node. If all
+ three are found, true is returned. If any of the three is not
+ found or is not in the correct format, false is returned.
*/
bool Node::setQmlModuleInfo(const QString& arg)
{
@@ -2185,6 +2198,20 @@ bool Node::setQmlModuleInfo(const QString& arg)
}
/*!
+ If this QML type node has a base type node,
+ return the fully qualified name of that QML
+ type, i.e. <QML-module-name>::<QML-type-name>.
+ */
+QString QmlClassNode::qmlFullBaseName() const
+{
+ QString result;
+ if (baseNode_) {
+ result = baseNode_->qmlModuleIdentifier() + "::" + baseNode_->name();
+ }
+ return result;
+}
+
+/*!
The name of this QML class node might be the same as the
name of some other QML class node. If so, then this node's
parent will be a NameCollisionNode.This function sets the
diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h
index ecb3c5771e..4802b6de54 100644
--- a/src/tools/qdoc/node.h
+++ b/src/tools/qdoc/node.h
@@ -65,7 +65,6 @@ typedef QList<Node*> NodeList;
typedef QMap<QString, Node*> NodeMap;
typedef QMultiMap<QString, Node*> NodeMultiMap;
typedef QMultiMap<QString, const ExampleNode*> ExampleNodeMap;
-typedef QList<QPair<QString,QString> > ImportList;
class Node
{
@@ -206,7 +205,7 @@ public:
virtual bool hasProperty(const QString& ) const { return false; }
virtual void getMemberNamespaces(NodeMap& ) { }
virtual void getMemberClasses(NodeMap& ) { }
- bool isInternal() const;
+ virtual bool isInternal() const;
bool isIndexNode() const { return indexNodeFlag_; }
bool wasSeen() const { return seen_; }
Type type() const { return nodeType_; }
@@ -241,6 +240,7 @@ public:
QString guid() const;
QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
+ virtual QString qmlFullBaseName() const { return QString(); }
virtual QString qmlModuleName() const { return qmlModuleName_; }
virtual QString qmlModuleVersion() const { return qmlModuleVersionMajor_ + "." + qmlModuleVersionMinor_; }
virtual QString qmlModuleIdentifier() const { return qmlModuleName_ + qmlModuleVersionMajor_; }
@@ -333,7 +333,7 @@ public:
const NodeList & childNodes() const { return children_; }
const NodeList & relatedNodes() const { return related_; }
- virtual void addMember(Node* node) { members_.append(node); }
+ virtual void addMember(Node* node);
const NodeList& members() const { return members_; }
virtual bool hasMembers() const;
virtual bool hasNamespaces() const;
@@ -530,6 +530,26 @@ private:
QString imageFileName_;
};
+struct ImportRec {
+ QString name_; // module name
+ QString version_; // <major> . <minor>
+ QString importId_; // "as" name
+ QString importUri_; // subdirectory of module directory
+
+ ImportRec(const QString& name,
+ const QString& version,
+ const QString& importId,
+ const QString& importUri)
+ : name_(name), version_(version), importId_(importId), importUri_(importUri) { }
+ QString& name() { return name_; }
+ QString& version() { return version_; }
+ QString& importId() { return importId_; }
+ QString& importUri() { return importUri_; }
+ bool isEmpty() const { return name_.isEmpty(); }
+};
+
+typedef QList<ImportRec> ImportList;
+
class QmlClassNode : public DocNode
{
public:
@@ -543,12 +563,14 @@ public:
virtual void clearCurrentChild();
virtual bool isAbstract() const { return abstract_; }
virtual void setAbstract(bool b) { abstract_ = b; }
+ virtual bool isInternal() const { return (status() == Internal); }
+ virtual QString qmlFullBaseName() const;
const ImportList& importList() const { return importList_; }
void setImportList(const ImportList& il) { importList_ = il; }
const QString& qmlBaseName() const { return baseName_; }
void setQmlBaseName(const QString& name) { baseName_ = name; }
- const DocNode* qmlBaseNode() const { return baseNode_; }
- void setQmlBaseNode(DocNode* b) { baseNode_ = b; }
+ const QmlClassNode* qmlBaseNode() const { return baseNode_; }
+ void setQmlBaseNode(QmlClassNode* b) { baseNode_ = b; }
void requireCppClass() { cnodeRequired_ = true; }
bool cppClassRequired() const { return cnodeRequired_; }
static void addInheritedBy(const QString& base, Node* sub);
@@ -564,7 +586,7 @@ private:
bool cnodeRequired_;
ClassNode* cnode_;
QString baseName_;
- DocNode* baseNode_;
+ QmlClassNode* baseNode_;
ImportList importList_;
};
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index 4208d529c8..58c674de7a 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -291,18 +291,29 @@ DocNode* QDocDatabase::addToModule(const QString& name, Node* node)
*/
DocNode* QDocDatabase::addToQmlModule(const QString& name, Node* node)
{
+ QString longQmid, shortQmid;
+ QStringList dotSplit;
+ QStringList blankSplit = name.split(QLatin1Char(' '));
+ if (blankSplit.size() > 1) {
+ longQmid = blankSplit[0] + blankSplit[1];
+ dotSplit = blankSplit[1].split(QLatin1Char('.'));
+ shortQmid = blankSplit[0] + dotSplit[0];
+ }
DocNode* dn = findQmlModule(name);
dn->addMember(node);
node->setQmlModuleInfo(name);
if (node->subType() == Node::QmlClass) {
- QString t = node->qmlModuleIdentifier() + "::" + node->name();
QmlClassNode* n = static_cast<QmlClassNode*>(node);
- if (!qmlTypeMap_.contains(t))
- qmlTypeMap_.insert(t,n);
- if (!masterMap_.contains(t))
- masterMap_.insert(t,node);
- if (!masterMap_.contains(node->name(),node))
- masterMap_.insert(node->name(),node);
+ QString key = longQmid + "::" + node->name();
+ for (int i=0; i<2; ++i) {
+ if (!qmlTypeMap_.contains(key))
+ qmlTypeMap_.insert(key,n);
+ if (!masterMap_.contains(key))
+ masterMap_.insert(key,node);
+ if (!masterMap_.contains(node->name(),node))
+ masterMap_.insert(node->name(),node);
+ key = shortQmid + "::" + node->name();
+ }
}
return dn;
}
@@ -332,7 +343,45 @@ QmlClassNode* QDocDatabase::findQmlType(const QString& qmid, const QString& name
}
}
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.
+ If a QML type node is not found, 0 is returned.
+ */
+QmlClassNode* QDocDatabase::findQmlType(const ImportRec& import, const QString& name) const
+{
+ if (!import.isEmpty()) {
+ QStringList dotSplit;
+ dotSplit = name.split(QLatin1Char('.'));
+ QString qmName;
+ if (import.importUri_.isEmpty())
+ qmName = import.name_;
+ else
+ qmName = import.importUri_;
+ for (int i=0; i<dotSplit.size(); ++i) {
+ QString qmid = qmName + import.version_;
+ QString qualifiedName = qmid + "::" + dotSplit[i];
+ QmlClassNode* qcn = qmlTypeMap_.value(qualifiedName);
+ if (qcn) {
+ return qcn;
+ }
+ if (import.version_.size() > 1) {
+ int dot = import.version_.lastIndexOf(QChar('.'));
+ if (dot > 0) {
+ qmid = import.name_ + import.version_.left(dot);
+ qualifiedName = qmid + "::" + dotSplit[i];
+ qcn = qmlTypeMap_.value(qualifiedName);
+ if (qcn) {
+ return qcn;
+ }
+ }
+ }
+ }
+ }
+ return 0;
}
/*!
@@ -836,14 +885,28 @@ void QDocDatabase::resolveQmlInheritance(InnerNode* root)
if (child->type() == Node::Document && child->subType() == Node::QmlClass) {
QmlClassNode* qcn = static_cast<QmlClassNode*>(child);
if ((qcn->qmlBaseNode() == 0) && !qcn->qmlBaseName().isEmpty()) {
- QmlClassNode* bqcn = findQmlType(QString(), qcn->qmlBaseName());
+ QmlClassNode* bqcn = 0;
+ if (qcn->qmlBaseName().contains("::")) {
+ bqcn = qmlTypeMap_.value(qcn->qmlBaseName());
+ }
+ else {
+ const ImportList& imports = qcn->importList();
+ for (int i=0; i<imports.size(); ++i) {
+ bqcn = findQmlType(imports[i], qcn->qmlBaseName());
+ if (bqcn)
+ break;
+ }
+ }
+ if (bqcn == 0) {
+ bqcn = findQmlType(QString(), qcn->qmlBaseName());
+ }
if (bqcn) {
qcn->setQmlBaseNode(bqcn);
}
#if 0
else {
- qDebug() << "Unable to resolve QML base type:" << qcn->qmlBaseName()
- << "for QML type:" << qcn->name();
+ qDebug() << "Temporary error message (ignore): UNABLE to resolve QML base type:"
+ << qcn->qmlBaseName() << "for QML type:" << qcn->name();
}
#endif
}
@@ -851,6 +914,24 @@ void QDocDatabase::resolveQmlInheritance(InnerNode* root)
}
}
+#if 0
+void QDocDatabase::resolveQmlInheritance(InnerNode* root)
+{
+ // Dop we need recursion?
+ foreach (Node* child, root->childNodes()) {
+ if (child->type() == Node::Document && child->subType() == Node::QmlClass) {
+ QmlClassNode* qcn = static_cast<QmlClassNode*>(child);
+ if ((qcn->qmlBaseNode() == 0) && !qcn->qmlBaseName().isEmpty()) {
+ QmlClassNode* bqcn = findQmlType(QString(), qcn->qmlBaseName());
+ if (bqcn) {
+ qcn->setQmlBaseNode(bqcn);
+ }
+ }
+ }
+ }
+}
+#endif
+
/*!
*/
void QDocDatabase::resolveTargets(InnerNode* root)
diff --git a/src/tools/qdoc/qdocdatabase.h b/src/tools/qdoc/qdocdatabase.h
index 9c6810941d..19dde361f8 100644
--- a/src/tools/qdoc/qdocdatabase.h
+++ b/src/tools/qdoc/qdocdatabase.h
@@ -107,6 +107,7 @@ class QDocDatabase
DocNode* addToQmlModule(const QString& name, Node* node);
QmlClassNode* findQmlType(const QString& qmid, const QString& name) const;
+ QmlClassNode* findQmlType(const ImportRec& import, const QString& name) const;
void findAllClasses(const InnerNode *node);
void findAllFunctions(const InnerNode *node);
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp
index 358c2a14d9..466742ee3a 100644
--- a/src/tools/qdoc/qdocindexfiles.cpp
+++ b/src/tools/qdoc/qdocindexfiles.cpp
@@ -190,6 +190,12 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
((element.nodeName() == "page") && (element.attribute("subtype") == "qmlclass"))) {
QmlClassNode* qcn = new QmlClassNode(parent, name);
qcn->setTitle(element.attribute("title"));
+ QString qmlModuleName = element.attribute("qml-module-name");
+ QString qmlModuleVersion = element.attribute("qml-module-version");
+ qdb_->addToQmlModule(qmlModuleName + " " + qmlModuleVersion, qcn);
+ QString qmlFullBaseName = element.attribute("qml-base-type");
+ if (!qmlFullBaseName.isEmpty())
+ qcn->setQmlBaseName(qmlFullBaseName);
if (element.hasAttribute("location"))
name = element.attribute("location", QString());
if (!indexUrl.isEmpty())
@@ -209,6 +215,31 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
location = Location(name);
node = qbtn;
}
+ else if (element.nodeName() == "qmlproperty") {
+ QmlClassNode* qcn = static_cast<QmlClassNode*>(parent);
+ QString type = element.attribute("type");
+ bool attached = false;
+ if (element.attribute("attached") == "true")
+ attached = true;
+ bool readonly = false;
+ if (element.attribute("writable") == "false")
+ readonly = true;
+ QmlPropertyNode* qpn = new QmlPropertyNode(qcn, name, type, attached);
+ qpn->setReadOnly(readonly);
+ node = qpn;
+ }
+ else if ((element.nodeName() == "qmlmethod") ||
+ (element.nodeName() == "qmlsignal") ||
+ (element.nodeName() == "qmlsignalhandler")) {
+ Node::Type t = Node::QmlMethod;
+ if (element.nodeName() == "qmlsignal")
+ t = Node::QmlSignal;
+ else if (element.nodeName() == "qmlsignalhandler")
+ t = Node::QmlSignalHandler;
+ bool attached = false;
+ FunctionNode* fn = new FunctionNode(t, parent, name, attached);
+ node = fn;
+ }
else if (element.nodeName() == "page") {
Node::SubType subtype;
Node::PageType ptype = Node::NoPageType;
@@ -476,17 +507,22 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
InnerNode* inner = static_cast<InnerNode*>(node);
QDomElement child = element.firstChildElement();
while (!child.isNull()) {
- if (element.nodeName() == "class")
+ if (element.nodeName() == "class") {
readIndexSection(child, inner, indexUrl);
- else if (element.nodeName() == "qmlclass")
+ }
+ else if (element.nodeName() == "qmlclass") {
readIndexSection(child, inner, indexUrl);
- else if (element.nodeName() == "page")
+ }
+ else if (element.nodeName() == "page") {
readIndexSection(child, inner, indexUrl);
- else if (element.nodeName() == "namespace" && !name.isEmpty())
+ }
+ else if (element.nodeName() == "namespace" && !name.isEmpty()) {
// The root node in the index is a namespace with an empty name.
readIndexSection(child, inner, indexUrl);
- else
+ }
+ else {
readIndexSection(child, parent, indexUrl);
+ }
child = child.nextSiblingElement();
}
}
@@ -562,6 +598,9 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
return false;
QString nodeName;
+ QString qmlModuleName;
+ QString qmlModuleVersion;
+ QString qmlFullBaseName;
switch (node->type()) {
case Node::Namespace:
nodeName = "namespace";
@@ -571,8 +610,12 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
break;
case Node::Document:
nodeName = "page";
- if (node->subType() == Node::QmlClass)
+ if (node->subType() == Node::QmlClass) {
nodeName = "qmlclass";
+ qmlModuleName = node->qmlModuleName();
+ qmlModuleVersion = node->qmlModuleVersion();
+ qmlFullBaseName = node->qmlFullBaseName();
+ }
else if (node->subType() == Node::QmlBasicType)
nodeName = "qmlbasictype";
break;
@@ -687,6 +730,12 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
writer.writeAttribute("status", status);
writer.writeAttribute("name", objName);
+ if (!qmlModuleName.isEmpty()) {
+ writer.writeAttribute("qml-module-name", qmlModuleName);
+ writer.writeAttribute("qml-module-version", qmlModuleVersion);
+ if (!qmlFullBaseName.isEmpty())
+ writer.writeAttribute("qml-base-type", qmlFullBaseName);
+ }
QString fullName = node->fullDocumentName();
if (fullName != objName)
writer.writeAttribute("fullname", fullName);
diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp
index 15af03d9ba..8b6f81de3e 100644
--- a/src/tools/qdoc/qmlvisitor.cpp
+++ b/src/tools/qdoc/qmlvisitor.cpp
@@ -374,6 +374,24 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation,
}
/*!
+ Reconstruct the qualified \a id using dot notation
+ and return the fully qualified string.
+ */
+QString QmlDocVisitor::getFullyQualifiedId(QQmlJS::AST::UiQualifiedId *id)
+{
+ QString result;
+ if (id) {
+ result = id->name.toString();
+ id = id->next;
+ while (id != 0) {
+ result += QChar('.') + id->name.toString();
+ id = id->next;
+ }
+ }
+ return result;
+}
+
+/*!
Begin the visit of the object \a definition, recording it in the
qdoc database. Increment the object nesting level, which is used
to test whether we are at the public API level. The public level
@@ -381,7 +399,7 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation,
*/
bool QmlDocVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition)
{
- QString type = definition->qualifiedTypeNameId->name.toString();
+ QString type = getFullyQualifiedId(definition->qualifiedTypeNameId);
nestingLevel++;
if (current->type() == Node::Namespace) {
@@ -420,17 +438,18 @@ void QmlDocVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *definition)
*/
bool QmlDocVisitor::visit(QQmlJS::AST::UiImportList *imports)
{
- QQmlJS::AST::UiImport* imp = imports->import;
- quint32 length = imp->versionToken.offset - imp->fileNameToken.offset - 1;
- QString module = document.mid(imp->fileNameToken.offset,length);
- QString version = document.mid(imp->versionToken.offset, imp->versionToken.length);
- if (version.size() > 1) {
- int dot = version.lastIndexOf(QChar('.'));
- if (dot > 0)
- version = version.left(dot);
+ while (imports != 0) {
+ QQmlJS::AST::UiImport* imp = imports->import;
+
+ QString name = document.mid(imp->fileNameToken.offset, imp->fileNameToken.length);
+ if (name[0] == '\"')
+ name = name.mid(1, name.length()-2);
+ QString version = document.mid(imp->versionToken.offset, imp->versionToken.length);
+ QString importId = document.mid(imp->importIdToken.offset, imp->importIdToken.length);
+ QString importUri = getFullyQualifiedId(imp->importUri);
+ importList.append(ImportRec(name, version, importId, importUri));
+ imports = imports->next;
}
- importList.append(QPair<QString, QString>(module, version));
-
return true;
}
diff --git a/src/tools/qdoc/qmlvisitor.h b/src/tools/qdoc/qmlvisitor.h
index 172aca579a..bfec61eb34 100644
--- a/src/tools/qdoc/qmlvisitor.h
+++ b/src/tools/qdoc/qmlvisitor.h
@@ -97,6 +97,7 @@ public:
void endVisit(QQmlJS::AST::UiQualifiedId *);
private:
+ QString getFullyQualifiedId(QQmlJS::AST::UiQualifiedId *id);
QQmlJS::AST::SourceLocation precedingComment(quint32 offset) const;
bool applyDocumentation(QQmlJS::AST::SourceLocation location, Node *node);
void applyMetacommands(QQmlJS::AST::SourceLocation location, Node* node, Doc& doc);
@@ -110,7 +111,7 @@ private:
QString filePath;
QString name;
QString document;
- QList<QPair<QString, QString> > importList;
+ ImportList importList;
QSet<QString> commands;
QSet<QString> topics;
QSet<quint32> usedComments;