diff options
author | Martin Smith <martin.smith@digia.com> | 2015-01-30 10:21:46 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@digia.com> | 2015-02-20 11:37:07 +0000 |
commit | fe7c2662b5a6a458459bf11b8d06a2b34318918d (patch) | |
tree | 2232ab01c547cea0c1a5855bce5741f5595767b7 /src/tools/qdoc | |
parent | edb2ad9117ee1598f18ad79fd2493ca53b0c9513 (diff) |
qdoc: Mark Genus of each Node object
The concept of Genus was introduced to allow link commands
(\l) to specify what kind of entity should be accepted as the
link target. Possible values were CPP, QML, DOC, and DONTCARE.
This became necessary when we started seeing more cases where
the same name was used for a C++ class and a QML type. The
Genus for an entity was returned by a member function of the
specific subclass of Node that represents that entity. For
example, QmlTypeNode::genus() returns QML, while Class::genus()
returns CPP.
Now we are seeing an increasing need to document Javascript.
Rather than add subclasses of all the QmlXxxNode classes to
represent the javascript entities, the Qml Node subclasses
will be used. JS is added to the Genus enum to mark Nodes
that represent javascript entities. But this requires storing
the Genus value in the node, rather than just having a member
function in each subclass return it. Now there are two member
functions in the Node base class, genus() and setGenus(), and
the value is stored in the Node. This doesn't increase the
size, because there was a byte available.
Change-Id: Ifcee78595f4288792e09bb255d2e8c01ebafac46
Task-number: QTBUG-43715
Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'src/tools/qdoc')
-rw-r--r-- | src/tools/qdoc/cppcodeparser.cpp | 12 | ||||
-rw-r--r-- | src/tools/qdoc/cppcodeparser.h | 16 | ||||
-rw-r--r-- | src/tools/qdoc/node.cpp | 17 | ||||
-rw-r--r-- | src/tools/qdoc/node.h | 34 |
4 files changed, 50 insertions, 29 deletions
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index a03f9dad2e..2f26dd1f64 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -295,7 +295,17 @@ const QSet<QString>& CppCodeParser::topicCommands() << COMMAND_QMLMETHOD << COMMAND_QMLATTACHEDMETHOD << COMMAND_QMLBASICTYPE - << COMMAND_QMLMODULE; + << COMMAND_QMLMODULE + << COMMAND_JSTYPE + << COMMAND_JSPROPERTY + << COMMAND_JSPROPERTYGROUP + << COMMAND_JSATTACHEDPROPERTY + << COMMAND_JSSIGNAL + << COMMAND_JSATTACHEDSIGNAL + << COMMAND_JSMETHOD + << COMMAND_JSATTACHEDMETHOD + << COMMAND_JSBASICTYPE + << COMMAND_JSMODULE; } return topicCommands_; } diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h index 63f9ff9991..9c775da538 100644 --- a/src/tools/qdoc/cppcodeparser.h +++ b/src/tools/qdoc/cppcodeparser.h @@ -234,11 +234,17 @@ protected: #define COMMAND_LICENSEDESCRIPTION Doc::alias("licensedescription") #define COMMAND_RELEASEDATE Doc::alias("releasedate") #define COMMAND_QTVARIABLE Doc::alias("qtvariable") -#define COMMAND_JSTYPE Doc::alias("jstype") -#define COMMAND_JSPROPERTY Doc::alias("jsproperty") -#define COMMAND_JSMETHOD Doc::alias("jsmethod") -#define COMMAND_JSSIGNAL Doc::alias("jssignal") -#define COMMAND_JSMODULE Doc::alias("jsmodule") +// Some of these are not used currenmtly, but they are included now for completeness. +#define COMMAND_JSTYPE Doc::alias("jstype") +#define COMMAND_JSPROPERTY Doc::alias("jsproperty") +#define COMMAND_JSPROPERTYGROUP Doc::alias("jspropertygroup") +#define COMMAND_JSATTACHEDPROPERTY Doc::alias("jsattachedproperty") +#define COMMAND_JSSIGNAL Doc::alias("jssignal") +#define COMMAND_JSATTACHEDSIGNAL Doc::alias("jsattachedsignal") +#define COMMAND_JSMETHOD Doc::alias("jsmethod") +#define COMMAND_JSATTACHEDMETHOD Doc::alias("jsattachedmethod") +#define COMMAND_JSBASICTYPE Doc::alias("jsbasictype") +#define COMMAND_JSMODULE Doc::alias("jsmodule") QT_END_NAMESPACE diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index e34119b5e6..1ade3e2aca 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -1454,6 +1454,7 @@ LeafNode::LeafNode(InnerNode* parent, Type type, const QString& name) NamespaceNode::NamespaceNode(InnerNode *parent, const QString& name) : InnerNode(Namespace, parent, name), tree_(0) { + setGenus(Node::CPP); setPageType(ApiPage); } @@ -1471,6 +1472,7 @@ ClassNode::ClassNode(InnerNode *parent, const QString& name) abstract_ = false; wrapper_ = false; qmlelement = 0; + setGenus(Node::CPP); setPageType(ApiPage); } @@ -1651,6 +1653,7 @@ QmlTypeNode* ClassNode::findQmlBaseNode() DocNode::DocNode(InnerNode* parent, const QString& name, SubType subtype, Node::PageType ptype) : InnerNode(Document, parent, name), nodeSubtype_(subtype) { + setGenus(Node::DOC); switch (subtype) { case Page: setPageType(ptype); @@ -1735,7 +1738,7 @@ QString DocNode::subTitle() const EnumNode::EnumNode(InnerNode *parent, const QString& name) : LeafNode(Enum, parent, name), ft(0) { - // nothing. + setGenus(Node::CPP); } /*! @@ -1780,6 +1783,7 @@ QString EnumNode::itemValue(const QString &name) const TypedefNode::TypedefNode(InnerNode *parent, const QString& name) : LeafNode(Typedef, parent, name), ae(0) { + setGenus(Node::CPP); } /*! @@ -1869,7 +1873,7 @@ FunctionNode::FunctionNode(InnerNode *parent, const QString& name) rf(0), ap(0) { - // nothing. + setGenus(Node::CPP); } /*! @@ -1889,10 +1893,13 @@ FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bo rf(0), ap(0) { + setGenus(Node::QML); if (type == QmlMethod || type == QmlSignal) { if (name.startsWith("__")) setStatus(Internal); } + else if (type == Function) + setGenus(Node::CPP); } /*! @@ -2079,7 +2086,7 @@ PropertyNode::PropertyNode(InnerNode *parent, const QString& name) rev(-1), overrides(0) { - // nothing. + setGenus(Node::CPP); } /*! @@ -2156,6 +2163,7 @@ QmlTypeNode::QmlTypeNode(InnerNode *parent, const QString& name) } setTitle(name.mid(i)); setPageType(Node::ApiPage); + setGenus(Node::QML); } /*! @@ -2281,6 +2289,7 @@ QmlBasicTypeNode::QmlBasicTypeNode(InnerNode *parent, : InnerNode(QmlBasicType, parent, name) { setTitle(name); + setGenus(Node::QML); } /*! @@ -2291,6 +2300,7 @@ QmlPropertyGroupNode::QmlPropertyGroupNode(QmlTypeNode* parent, const QString& n : InnerNode(QmlPropertyGroup, parent, name) { idNumber_ = -1; + setGenus(Node::QML); } /*! @@ -2328,6 +2338,7 @@ QmlPropertyNode::QmlPropertyNode(InnerNode* parent, isAlias_ = true; if (name.startsWith("__")) setStatus(Internal); + setGenus(Node::QML); } /*! diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 671aedfd1e..8de6015214 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -170,6 +170,8 @@ public: const QString& fileNameBase() const { return fileNameBase_; } bool hasFileNameBase() const { return !fileNameBase_.isEmpty(); } void setFileNameBase(const QString& t) { fileNameBase_ = t; } + Node::Genus genus() const { return (Genus) genus_; } + void setGenus(Genus t) { genus_ = (unsigned char) t; } void setAccess(Access access) { access_ = (unsigned char) access; } void setLocation(const Location& location) { loc_ = location; } @@ -225,7 +227,6 @@ public: virtual bool hasClasses() const { return false; } virtual void setAbstract(bool ) { } virtual void setWrapper() { } - virtual Node::Genus genus() const { return DontCare; } virtual QString title() const { return name(); } virtual QString fullTitle() const { return name(); } virtual QString subTitle() const { return QString(); } @@ -325,6 +326,7 @@ protected: private: unsigned char nodeType_; + unsigned char genus_; unsigned char access_; unsigned char safeness_; unsigned char pageType_; @@ -439,7 +441,6 @@ public: virtual bool isNamespace() const Q_DECL_OVERRIDE { return true; } virtual Tree* tree() const Q_DECL_OVERRIDE { return (parent() ? parent()->tree() : tree_); } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } void setTree(Tree* t) { tree_ = t; } private: @@ -472,7 +473,6 @@ public: virtual bool isClass() const Q_DECL_OVERRIDE { return true; } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } virtual bool isWrapper() const Q_DECL_OVERRIDE { return wrapper_; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } virtual QString obsoleteLink() const Q_DECL_OVERRIDE { return obsoleteLink_; } virtual void setObsoleteLink(const QString& t) Q_DECL_OVERRIDE { obsoleteLink_ = t; } virtual void setWrapper() Q_DECL_OVERRIDE { wrapper_ = true; } @@ -537,7 +537,6 @@ public: virtual bool isExampleFile() const Q_DECL_OVERRIDE { return (parent() && parent()->isExample()); } virtual bool isExternalPage() const Q_DECL_OVERRIDE { return nodeSubtype_ == ExternalPage; } virtual bool isDocNode() const Q_DECL_OVERRIDE { return true; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::DOC; } protected: SubType nodeSubtype_; @@ -603,7 +602,7 @@ public: virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE; virtual QmlModuleNode* logicalModule() const Q_DECL_OVERRIDE { return logicalModule_; } virtual void setQmlModule(QmlModuleNode* t) Q_DECL_OVERRIDE { logicalModule_ = t; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; } + const ImportList& importList() const { return importList_; } void setImportList(const ImportList& il) { importList_ = il; } const QString& qmlBaseName() const { return qmlBaseName_; } @@ -641,7 +640,6 @@ public: virtual ~QmlBasicTypeNode() { } virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; } virtual bool isQmlBasicType() const Q_DECL_OVERRIDE { return true; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; } }; class QmlPropertyGroupNode : public InnerNode @@ -663,8 +661,6 @@ public: } virtual QString idNumber() Q_DECL_OVERRIDE; virtual bool isQmlPropertyGroup() const Q_DECL_OVERRIDE { return true; } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; } - virtual QString element() const Q_DECL_OVERRIDE { return parent()->name(); } private: @@ -682,7 +678,6 @@ public: bool attached); virtual ~QmlPropertyNode() { } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; } virtual void setDataType(const QString& dataType) Q_DECL_OVERRIDE { type_ = dataType; } void setStored(bool stored) { stored_ = toFlagValue(stored); } void setDesignable(bool designable) { designable_ = toFlagValue(designable); } @@ -747,7 +742,6 @@ public: EnumNode(InnerNode* parent, const QString& name); virtual ~EnumNode() { } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } void addItem(const EnumItem& item); void setFlagsType(TypedefNode* typedeff); @@ -770,7 +764,6 @@ public: TypedefNode(InnerNode* parent, const QString& name); virtual ~TypedefNode() { } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } const EnumNode* associatedEnum() const { return ae; } @@ -879,9 +872,6 @@ public: (type() == QmlSignalHandler)); } virtual bool isCppNode() const Q_DECL_OVERRIDE { return !isQmlNode(); } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { - return (isQmlNode() ? Node::QML : Node::CPP); - } virtual bool isQtQuickNode() const Q_DECL_OVERRIDE { return parent()->isQtQuickNode(); } virtual QString qmlTypeName() const Q_DECL_OVERRIDE { return parent()->qmlTypeName(); } virtual QString logicalModuleName() const Q_DECL_OVERRIDE { @@ -926,7 +916,6 @@ public: PropertyNode(InnerNode* parent, const QString& name); virtual ~PropertyNode() { } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } virtual void setDataType(const QString& dataType) Q_DECL_OVERRIDE { type_ = dataType; } void addFunction(FunctionNode* function, FunctionRole role); @@ -1015,7 +1004,6 @@ public: VariableNode(InnerNode* parent, const QString &name); virtual ~VariableNode() { } - virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; } virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; } void setLeftType(const QString &leftType) { lt = leftType; } void setRightType(const QString &rightType) { rt = rightType; } @@ -1035,7 +1023,7 @@ private: inline VariableNode::VariableNode(InnerNode* parent, const QString &name) : LeafNode(Variable, parent, name), sta(false) { - // nothing. + setGenus(Node::CPP); } class DitaMapNode : public DocNode @@ -1089,7 +1077,9 @@ class GroupNode : public CollectionNode { public: GroupNode(InnerNode* parent, const QString& name) - : CollectionNode(Node::Group, parent, name) { } + : CollectionNode(Node::Group, parent, name) { + setGenus(Node::DOC); + } virtual ~GroupNode() { } virtual bool isGroup() const Q_DECL_OVERRIDE { return true; } @@ -1099,7 +1089,9 @@ class ModuleNode : public CollectionNode { public: ModuleNode(InnerNode* parent, const QString& name) - : CollectionNode(Node::Module, parent, name) { } + : CollectionNode(Node::Module, parent, name) { + setGenus(Node::CPP); + } virtual ~ModuleNode() { } virtual bool isModule() const Q_DECL_OVERRIDE { return true; } @@ -1115,7 +1107,9 @@ class QmlModuleNode : public CollectionNode { public: QmlModuleNode(InnerNode* parent, const QString& name) - : CollectionNode(Node::QmlModule, parent, name) { } + : CollectionNode(Node::QmlModule, parent, name) { + setGenus(Node::QML); + } virtual ~QmlModuleNode() { } virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; } |