From 6893a0d656f8e08d93b44794e78c9b980a2937d5 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 16 Oct 2013 16:28:56 +0200 Subject: qdoc: Part 2 of fix for inheriting abstract QML types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix not only gets the property lists correct but also creates correct links to the property docs. A side effect is that QML properties, methods, and signals whose names begin with "__" are automatically treated as if they are marked \internal. This had been agreed earlier but had not been implemented. It is also required to fix this bug so it is included here. Task-number: QTBUG-33814 Change-Id: I57de1e49774db47cb57c042f181ccc8edec62d13 Reviewed-by: Topi Reiniƶ Reviewed-by: Nico Vertriest Reviewed-by: Jerome Pasion --- src/tools/qdoc/cppcodemarker.cpp | 8 ++++++++ src/tools/qdoc/htmlgenerator.cpp | 5 +++-- src/tools/qdoc/node.cpp | 7 ++++++- src/tools/qdoc/node.h | 2 ++ src/tools/qdoc/qdocindexfiles.cpp | 34 +++++++++++++++++++++++++++------- src/tools/qdoc/qmlvisitor.cpp | 1 - 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/tools/qdoc/cppcodemarker.cpp b/src/tools/qdoc/cppcodemarker.cpp index 24bd654238..64b11109f7 100644 --- a/src/tools/qdoc/cppcodemarker.cpp +++ b/src/tools/qdoc/cppcodemarker.cpp @@ -1111,6 +1111,10 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno while (qcn != 0) { NodeList::ConstIterator c = qcn->childNodes().constBegin(); while (c != qcn->childNodes().constEnd()) { + if ((*c)->status() == Node::Internal) { + ++c; + continue; + } if ((*c)->type() == Node::QmlPropertyGroup) { insert(qmlproperties, *c, style, Okay); } @@ -1172,6 +1176,10 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno while (qcn != 0) { NodeList::ConstIterator c = qcn->childNodes().constBegin(); while (c != qcn->childNodes().constEnd()) { + if ((*c)->status() == Node::Internal) { + ++c; + continue; + } if ((*c)->type() == Node::QmlPropertyGroup) { insert(qmlproperties,*c,style,Okay); } diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index a7dd6666db..986b4ae261 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -2311,7 +2311,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(const QmlClassNode* qml_cn, } out() << "
    \n"; for (int j=0; jaccess() == Node::Private) { + if (nodes[j]->access() == Node::Private || nodes[j]->status() == Node::Internal) { continue; } out() << "
  • "; @@ -2320,7 +2320,8 @@ QString HtmlGenerator::generateAllQmlMembersFile(const QmlClassNode* qml_cn, prefix = keys.at(j).mid(1); prefix = prefix.left(keys.at(j).indexOf("::")+1); } - generateSynopsis(nodes[j], qcn, marker, CodeMarker::Summary, false, &prefix); + generateQmlItem(nodes[j], qcn, marker, true); + //generateSynopsis(nodes[j], qcn, marker, CodeMarker::Subpage, false, &prefix); out() << "
  • \n"; } out() << "
\n"; diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 75896e2718..c88ebfc760 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -1867,7 +1867,10 @@ FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bo rf(0), ap(0) { - // nothing. + if (type == QmlMethod || type == QmlSignal) { + if (name.startsWith("__")) + setStatus(Internal); + } } /*! @@ -2326,6 +2329,8 @@ QmlPropertyNode::QmlPropertyNode(InnerNode* parent, setPageType(ApiPage); if (type_ == QString("alias")) isAlias_ = true; + if (name.startsWith("__")) + setStatus(Internal); } /*! diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 9e736aeba6..236b495bd0 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -195,6 +195,7 @@ public: virtual bool isInnerNode() const = 0; virtual bool isQmlModule() const { return false; } + virtual bool isQmlType() const { return false; } virtual bool isExample() const { return false; } virtual bool isExampleFile() const { return false; } virtual bool isLeaf() const { return false; } @@ -610,6 +611,7 @@ public: QmlClassNode(InnerNode* parent, const QString& name); virtual ~QmlClassNode(); virtual bool isQmlNode() const { return true; } + virtual bool isQmlType() const { return true; } virtual bool isQtQuickNode() const { return (qmlModuleName() == QLatin1String("QtQuick")); } virtual ClassNode* classNode() { return cnode_; } virtual void setClassNode(ClassNode* cn) { cnode_ = cn; } diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index 02508e3589..47e302dad6 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -120,7 +120,6 @@ void QDocIndexFiles::readIndexFile(const QString& path) { QFile file(path); if (file.open(QFile::ReadOnly)) { - //qDebug() << "READING:" << path; QDomDocument document; document.setContent(&file); file.close(); @@ -515,10 +514,12 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, QString moduleName = element.attribute("module"); if (!moduleName.isEmpty()) node->setModuleName(moduleName); - if (node->isExternalPage()) - node->setUrl(href); - else if (!indexUrl.isEmpty()) - node->setUrl(indexUrl + QLatin1Char('/') + href); + if (!href.isEmpty()) { + if (node->isExternalPage()) + node->setUrl(href); + else if (!indexUrl.isEmpty()) + node->setUrl(indexUrl + QLatin1Char('/') + href); + } QString since = element.attribute("since"); if (!since.isEmpty()) { @@ -717,6 +718,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, access = "protected"; break; case Node::Private: +#if 0 // Do not include private non-internal nodes in the index. // (Internal public and protected nodes are marked as private // by qdoc. We can check their internal status to determine @@ -725,6 +727,13 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, access = "internal"; else return false; +#endif + { + access = "private"; + bool b = generateInternalNodes; + if (b) + b = false; + } break; default: return false; @@ -811,13 +820,24 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, } else href = node->name(); - writer.writeAttribute("href", href); + if (node->isQmlNode()) { + InnerNode* p = node->parent(); + if (p) { + if (p->isQmlPropertyGroup()) + p = p->parent(); + if (p && p->isQmlType() && p->isAbstract()) + href.clear(); + } + } + if (!href.isEmpty()) + writer.writeAttribute("href", href); writer.writeAttribute("access", access); writer.writeAttribute("status", status); if (node->isAbstract()) writer.writeAttribute("abstract", "true"); - writer.writeAttribute("location", node->location().fileName()); + if (!node->location().fileName().isEmpty()) + writer.writeAttribute("location", node->location().fileName()); if (!node->location().filePath().isEmpty()) { writer.writeAttribute("filepath", node->location().filePath()); writer.writeAttribute("lineno", QString("%1").arg(node->location().lineNo())); diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp index 323c312eb5..fb90dcd59a 100644 --- a/src/tools/qdoc/qmlvisitor.cpp +++ b/src/tools/qdoc/qmlvisitor.cpp @@ -404,7 +404,6 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation, } } else if (command == COMMAND_INTERNAL) { - node->setAccess(Node::Private); node->setStatus(Node::Internal); } else if (command == COMMAND_OBSOLETE) { -- cgit v1.2.3