summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodemarker.cpp
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@qt.io>2018-05-04 14:31:18 +0200
committerMartin Smith <martin.smith@qt.io>2018-06-01 12:14:36 +0000
commit26027a9b13491a4851c42e12d06af87f7e864a51 (patch)
tree399340d91e7aaea82b1c133c695a066586e1bc7a /src/qdoc/cppcodemarker.cpp
parent1beb7d176492c284640082e6c8d7b9b37d5ce0f0 (diff)
downloadqttools-26027a9b13491a4851c42e12d06af87f7e864a51.tar.gz
qdoc: Refactor section construction and processing
This update adds two classes called Section and Sections. These classes replace the FastSection and Section structs that used to be in codemarker.h, and they also replace the section building functions that used to be in codemarker.cpp and cppcodemarker.cpp. Basically, the two structs FastSection and Section are combined into the single new class Section. FastSection was used to collect all the members for a section in a map with the node names as the keys and the nodes as the values. This allowed the names to be sorted as the map is built. When completed, themap was used to build the Section, where the map keys were copied to a list in the Section, and the map values were copied to another list. The values in these lists were already sorted. Then the Section structs were copied into a list of Sections and the list was returned. The code was becoming too messy to maintain and impossible to use for implementing custom sections for QTBUG-45725. Now the new class Section combines the deleted structs FastSection and Section. The procedure for building an instance of class Section is much the same as the old procedure for building a struct FastSection and then using the FastSection to build a struct Section. In the old procedure, 4 separate passes over all the child nodes of a class were required to build the FastSections and Sections for the Summay lists, the Details lists, the All Members list, and the Obsolete members lists. In the new procedure, only a single pass is required. This single pass is the purpose for the other new class Sections, which manages several static instances of QVector<Section>. All the required Section objects are built at the same time, and the never have to be copied. When the docs for a class, namespace, etc have been written, each Section is cleared but not deleted. The static instances of QVector<Section> are kept in their constructed state. I thought this would speed up qdoc some, because there is much less allocating and deallocating of objects, but it seems to have actually slowed down a bit, and I can't see why. But the code is a lot simpler and reusable for the custom sections proposal, so I will continue with it and hopefully find the cause of the slowdown. Change-Id: I49f592c631ccc6182d1dae742985c7b2bb15c81b Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/qdoc/cppcodemarker.cpp')
-rw-r--r--src/qdoc/cppcodemarker.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 8b334736f..8d657e252 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -111,7 +111,7 @@ QString CppCodeMarker::markedUpCode(const QString &code,
QString CppCodeMarker::markedUpSynopsis(const Node *node,
const Node * /* relative */,
- Sections::Style style)
+ Section::Style style)
{
const int MaxEnumValues = 6;
const FunctionNode *func;
@@ -124,11 +124,11 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
QString name;
name = taggedNode(node);
- if (style != Sections::Detailed)
+ if (style != Section::Details)
name = linkTag(node, name);
name = "<@name>" + name + "</@name>";
- if ((style == Sections::Detailed) && !node->parent()->name().isEmpty() &&
+ if ((style == Section::Details) && !node->parent()->name().isEmpty() &&
(node->type() != Node::Property) && !node->isQmlNode() && !node->isJsNode())
name.prepend(taggedNode(node->parent()) + "::");
@@ -145,7 +145,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
case Node::QmlMethod:
func = (const FunctionNode *) node;
- if (style != Sections::Subpage && !func->returnType().isEmpty())
+ if (style != Section::AllMembers && !func->returnType().isEmpty())
synopsis = typified(func->returnType(), true);
synopsis += name;
if (!func->isMacroWithoutParams()) {
@@ -159,9 +159,9 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
if (hasName)
synopsis += typified((*p).dataType(), true);
const QString &paramName = hasName ? (*p).name() : (*p).dataType();
- if (style != Sections::Subpage || !hasName)
+ if (style != Section::AllMembers || !hasName)
synopsis += "<@param>" + protect(paramName) + "</@param>";
- if (style != Sections::Subpage && !(*p).defaultValue().isEmpty())
+ if (style != Section::AllMembers && !(*p).defaultValue().isEmpty())
synopsis += " = " + protect((*p).defaultValue());
++p;
}
@@ -171,7 +171,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
if (func->isConst())
synopsis += " const";
- if (style == Sections::Summary || style == Sections::Accessors) {
+ if (style == Section::Summary || style == Section::Accessors) {
if (!func->isNonvirtual())
synopsis.prepend("virtual ");
if (func->isFinal())
@@ -189,7 +189,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
else if (func->isRefRef())
synopsis.append(" &&");
}
- else if (style == Sections::Subpage) {
+ else if (style == Section::AllMembers) {
if (!func->returnType().isEmpty() && func->returnType() != "void")
synopsis += " : " + typified(func->returnType());
}
@@ -237,7 +237,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
case Node::Enum:
enume = static_cast<const EnumNode *>(node);
synopsis = "enum " + name;
- if (style == Sections::Summary) {
+ if (style == Section::Summary) {
synopsis += " { ";
QStringList documentedItems = enume->doc().enumItemNames();
@@ -288,7 +288,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
break;
case Node::Variable:
variable = static_cast<const VariableNode *>(node);
- if (style == Sections::Subpage) {
+ if (style == Section::AllMembers) {
synopsis = name + " : " + typified(variable->dataType());
}
else {
@@ -300,7 +300,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node,
synopsis = name;
}
- if (style == Sections::Summary) {
+ if (style == Section::Summary) {
if (node->status() == Node::Preliminary) {
extra += "(preliminary) ";
}