24#include <QtCore/qobjectdefs.h>
28QList<Section> Sections::s_stdSummarySections {
29 {
"Namespaces",
"namespace",
"namespaces",
"", Section::Summary },
30 {
"Classes",
"class",
"classes",
"", Section::Summary },
31 {
"Types",
"type",
"types",
"", Section::Summary },
32 {
"Variables",
"variable",
"variables",
"", Section::Summary },
33 {
"Static Variables",
"static variable",
"static variables",
"", Section::Summary },
34 {
"Functions",
"function",
"functions",
"", Section::Summary },
35 {
"Macros",
"macro",
"macros",
"", Section::Summary },
38QList<Section>
Sections::s_stdDetailsSections {
42 {
"Variable Documentation",
"variable",
"variables",
"vars",
Section::Details },
43 {
"Static Variables",
"static variable",
"static variables", QString(),
Section::Details },
44 {
"Function Documentation",
"function",
"functions",
"func",
Section::Details },
48QList<Section>
Sections::s_stdCppClassSummarySections {
51 {
"Public Functions",
"public function",
"public functions",
"",
Section::Summary },
54 {
"Public Variables",
"public variable",
"public variables",
"",
Section::Summary },
55 {
"Static Public Members",
"static public member",
"static public members",
"",
Section::Summary },
56 {
"Protected Types",
"protected type",
"protected types",
"",
Section::Summary },
57 {
"Protected Functions",
"protected function",
"protected functions",
"",
Section::Summary },
58 {
"Protected Slots",
"protected slot",
"protected slots",
"",
Section::Summary },
59 {
"Protected Variables",
"protected type",
"protected variables",
"",
Section::Summary },
60 {
"Static Protected Members",
"static protected member",
"static protected members",
"",
Section::Summary },
62 {
"Private Functions",
"private function",
"private functions",
"",
Section::Summary },
64 {
"Private Variables",
"private variable",
"private variables",
"",
Section::Summary },
65 {
"Static Private Members",
"static private member",
"static private members",
"",
Section::Summary },
66 {
"Related Non-Members",
"related non-member",
"related non-members",
"",
Section::Summary },
70QList<Section>
Sections::s_stdCppClassDetailsSections {
71 {
"Member Type Documentation",
"member",
"members",
"types",
Section::Details },
73 {
"Member Function Documentation",
"member",
"members",
"func",
Section::Details },
74 {
"Member Variable Documentation",
"member",
"members",
"vars",
Section::Details },
75 {
"Related Non-Members",
"member",
"members",
"relnonmem",
Section::Details },
79QList<Section>
Sections::s_stdQmlTypeSummarySections {
82 {
"Attached Properties",
"attached property",
"attached properties",
"",
Section::Summary },
84 {
"Signal Handlers",
"signal handler",
"signal handlers",
"",
Section::Summary },
85 {
"Attached Signals",
"attached signal",
"attached signals",
"",
Section::Summary },
87 {
"Attached Methods",
"attached method",
"attached methods",
"",
Section::Summary },
90QList<Section>
Sections::s_stdQmlTypeDetailsSections {
91 {
"Enumeration Documentation",
"member",
"members",
"qmlenum",
Section::Details },
92 {
"Property Documentation",
"member",
"members",
"qmlprop",
Section::Details },
93 {
"Attached Property Documentation",
"member",
"members",
"qmlattprop",
Section::Details },
95 {
"Signal Handler Documentation",
"signal handler",
"signal handlers",
"qmlsighan",
Section::Details },
96 {
"Attached Signal Documentation",
"signal",
"signals",
"qmlattsig",
Section::Details },
97 {
"Method Documentation",
"member",
"members",
"qmlmeth",
Section::Details },
98 {
"Attached Method Documentation",
"member",
"members",
"qmlattmeth",
Section::Details },
101QList<Section>
Sections::s_sinceSections {
124
125
126
129
130
131
138
139
140
141
142
145 m_reimplementedMemberMap.clear();
147 m_obsoleteMembers.clear();
148 m_reimplementedMembers.clear();
149 m_inheritedMembers.clear();
150 m_classNodesList.clear();
151 m_aggregate =
nullptr;
155
156
157
160 QString nodeName{node->name()};
163 for (qsizetype i = nodeName.size() - 1; i > 0; --i) {
164 if (nodeName.at(i).digitValue() == -1)
171 for (
int i = 0; i < 4 - numDigits; ++i)
172 nodeName.insert(nodeName.size() - numDigits - 1, QLatin1Char(
'0'));
176 return QLatin1Char(
'A') + nodeName;
179 const auto *fn =
static_cast<
const FunctionNode *>(node);
183 sortNo = QLatin1String(
"C");
185 sortNo = QLatin1String(
"D");
187 sortNo = QLatin1String(
"E");
189 sortNo = QLatin1String(
"F");
190 else if (nodeName.startsWith(QLatin1String(
"operator")) && nodeName.size() > 8
191 && !nodeName[8].isLetterOrNumber())
192 sortNo = QLatin1String(
"H");
194 sortNo = QLatin1String(
"G");
196 return sortNo + nodeName + QLatin1Char(
' ') + QString::number(fn->overloadNumber(), 36);
199 if (node->isFunction(Genus::QML))
200 return QLatin1Char(
'E') + nodeName + QLatin1Char(
' ') +
201 QString::number(
static_cast<
const FunctionNode*>(node)->overloadNumber(), 36);
204 return QLatin1Char(
'G') + nodeName;
206 return QLatin1Char(
'B') + nodeName;
210
211
212
215 bool irrelevant =
false;
216 bool inherited =
false;
225 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
235 irrelevant = (inherited && m_style !=
AllMembers);
237 const auto *tdn =
static_cast<
const TypedefNode *>(node);
244 QString key = sortName(node);
246 m_obsoleteMembers.push_back(node);
249 m_members.push_back(node);
252 if (m_inheritedMembers.isEmpty()
253 || m_inheritedMembers.last().first != node->parent()) {
255 m_inheritedMembers.append(p);
257 m_inheritedMembers.last().second++;
264
265
266
267
268
269
270
273 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
278 const auto *fn =
static_cast<
const FunctionNode *>(node);
279 if (!fn->overridesThis().isEmpty()) {
281 QString key = sortName(fn);
282 if (!m_reimplementedMemberMap.contains(key)) {
283 m_reimplementedMemberMap.insert(key, node);
293
294
295
332 static auto node_less_than = [](
const Node* left,
const Node* right) {
340 return sortName(left) < sortName(right);
343 std::stable_sort(m_members.begin(), m_members.end(), node_less_than);
344 std::stable_sort(m_obsoleteMembers.begin(), m_obsoleteMembers.end(), node_less_than);
346 m_reimplementedMembers = m_reimplementedMemberMap.values().toVector();
348 for (
auto &cn : m_classNodesList) {
349 std::stable_sort(cn.second.begin(), cn.second.end(), node_less_than);
354
355
356
357
358
359
360
363
364
365
368 initAggregate(s_allMembers, m_aggregate);
373 initAggregate(s_stdCppClassSummarySections, m_aggregate);
374 initAggregate(s_stdCppClassDetailsSections, m_aggregate);
379 initAggregate(s_stdQmlTypeSummarySections, m_aggregate);
380 initAggregate(s_stdQmlTypeDetailsSections, m_aggregate);
387 initAggregate(s_stdSummarySections, m_aggregate);
388 initAggregate(s_stdDetailsSections, m_aggregate);
395
396
397
403 for (
auto it = nsmap.constBegin(); it != nsmap.constEnd(); ++it) {
404 Node *node = it.value();
406 case NodeType::QmlType:
407 sections[SinceQmlTypes].appendMember(node);
409 case NodeType::Namespace:
410 sections[SinceNamespaces].appendMember(node);
412 case NodeType::Class:
413 case NodeType::Struct:
414 case NodeType::Union:
415 sections[SinceClasses].appendMember(node);
421 if (!it.key().isEmpty())
422 sections[SinceEnumTypes].appendMember(node);
424 sections[SinceEnumValues].appendMember(node);
427 case NodeType::Typedef:
428 case NodeType::TypeAlias:
429 sections[SinceTypeAliases].appendMember(node);
432 const auto *fn =
static_cast<
const FunctionNode *>(node);
433 switch (fn->metaness()) {
434 case FunctionNode::QmlSignal:
435 sections[SinceQmlSignals].appendMember(node);
437 case FunctionNode::QmlSignalHandler:
438 sections[SinceQmlSignalHandlers].appendMember(node);
440 case FunctionNode::QmlMethod:
441 sections[SinceQmlMethods].appendMember(node);
445 sections[SinceMacros].appendMember(node);
447 Node *p = fn->parent();
450 sections[SinceMemberFunctions].appendMember(node);
452 if (p->name().isEmpty())
453 sections[SinceGlobalFunctions].appendMember(node);
455 sections[SinceNamespaceFunctions].appendMember(node);
457 sections[SinceGlobalFunctions].appendMember(node);
459 sections[SinceGlobalFunctions].appendMember(node);
465 case NodeType::Property:
466 sections[SinceProperties].appendMember(node);
468 case NodeType::Variable:
469 sections[SinceVariables].appendMember(node);
471 case NodeType::QmlProperty:
472 sections[SinceQmlProperties].appendMember(node);
474 case NodeType::QmlEnum:
475 sections[SinceQmlEnumTypes].appendMember(node);
484
485
486
487
488
512 m_aggregate =
nullptr;
519
520
523 for (Section §ion : v)
524 section.setAggregate(aggregate);
528
529
532 for (Section §ion : v)
537
538
541 for (Section §ion : v)
546
547
548
549
550
551
552
553
557 if (
auto *scn =
static_cast<
SharedCommentNode *>(node); scn->collective().size())
558 return scn->collective().first();
564
565
570 case NodeType::Namespace:
571 v[StdNamespaces].insert(n);
573 case NodeType::Class:
574 case NodeType::Struct:
575 case NodeType::Union:
576 v[StdClasses].insert(n);
579 case NodeType::Typedef:
580 case NodeType::TypeAlias:
581 v[StdTypes].insert(n);
586 v[StdMacros].insert(n);
588 v[StdFunctions].insert(n);
593 if (!var
->doc().isEmpty()) {
595 v[StdStaticVariables].insert(n);
597 v[StdVariables].insert(n);
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
625 bool documentAll =
true;
631 for (
auto it = m_aggregate->constBegin(); it != m_aggregate->constEnd(); ++it) {
641 for (
const auto &node : relatedBy)
642 stdRefPageSwitch(stdSummarySections(), node);
645
646
647
648
651 for (
const auto &child : children) {
652 if (documentAll || child->hasDoc())
653 stdRefPageSwitch(stdSummarySections(), child);
662
663
664
665
674 sv[Macros].insert(n);
676 sv[RelatedNonmembers].insert(n);
683 sv[PublicSlots].insert(fn);
684 else if (fn->isPrivate())
685 sv[PrivateSlots].insert(fn);
687 sv[ProtectedSlots].insert(fn);
690 sv[Signals].insert(fn);
693 sv[StaticPublicMembers].insert(fn);
694 else if (!sv[PublicFunctions].insertReimplementedMember(fn))
695 sv[PublicFunctions].insert(fn);
698 sv[StaticPrivateMembers].insert(fn);
699 else if (!sv[PrivateFunctions].insertReimplementedMember(fn))
700 sv[PrivateFunctions].insert(fn);
703 sv[StaticProtectedMembers].insert(fn);
704 else if (!sv[ProtectedFunctions].insertReimplementedMember(fn))
705 sv[ProtectedFunctions].insert(fn);
710 sv[RelatedNonmembers].insert(n);
716 sv[StaticPublicMembers].insert(n);
717 else if (n->isPrivate())
718 sv[StaticPrivateMembers].insert(n);
720 sv[StaticProtectedMembers].insert(n);
723 sv[PublicVariables].insert(n);
724 else if (n->isProtected())
725 sv[ProtectedVariables].insert(n);
726 else if (n->isPrivate())
727 sv[PrivateVariables].insert(n);
732
733
734
735 if (n
->isTypedef() && (n->name() == QLatin1String(
"QtGadgetHelper")))
738 sv[Properties].insert(n);
739 else if (n->isPublic() && n->isInAPI())
740 sv[PublicTypes].insert(n);
741 else if (n->isPrivate())
742 sv[PrivateTypes].insert(n);
743 else if (n->isProtected())
744 sv[ProtectedTypes].insert(n);
748
749
750
751
762 dv[DetailsMacros].insert(n);
764 dv[DetailsRelatedNonmembers].insert(n);
769 if (!fn->hasAssociatedProperties() || !fn->doc().isEmpty())
770 dv[DetailsMemberFunctions].insert(n);
774 dv[DetailsRelatedNonmembers].insert(n);
778 if (t->name() != QLatin1String(
"QtGadgetHelper"))
779 dv[DetailsMemberTypes].insert(n);
783 dv[DetailsProperties].insert(n);
784 else if (t->isVariable() && !t->doc().isEmpty())
785 dv[DetailsMemberVariables].insert(n);
795 dv[QmlProperties].insert(n);
801 if (pn->isAttached())
802 dv[QmlAttachedProperties].insert(n);
804 dv[QmlProperties].insert(n);
806 dv[QmlEnumTypes].insert(n);
810 if (fn->isAttached())
811 dv[QmlAttachedSignals].insert(n);
813 dv[QmlSignals].insert(n);
815 dv[QmlSignalHandlers].insert(n);
817 if (fn->isAttached())
818 dv[QmlAttachedMethods].insert(n);
820 dv[QmlMethods].insert(n);
826
827
828
829
836 if (pn->isAttached())
837 sv[QmlAttachedProperties].insert(pn);
839 sv[QmlProperties].insert(pn);
841 sv[QmlEnumTypes].insert(n);
845 if (fn->isAttached())
846 sv[QmlAttachedSignals].insert(fn);
848 sv[QmlSignals].insert(fn);
850 sv[QmlSignalHandlers].insert(fn);
852 if (fn->isAttached())
853 sv[QmlAttachedMethods].insert(fn);
855 sv[QmlMethods].insert(fn);
860 sv[QmlProperties].insert(scn);
862 for (
const auto &child : scn->collective())
863 distributeQmlNodeInSummaryVector(sv, child,
true);
870 const QList<RelatedClass> baseClasses = cn->baseClasses();
871 for (
const auto &cls : baseClasses) {
873 stack.prepend(cls.m_node);
878
879
880
887 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
889 for (
auto it = m_aggregate->constBegin(); it != m_aggregate->constEnd(); ++it) {
896 distributeNodeInSummaryVector(summarySections, n);
897 distributeNodeInDetailsVector(detailsSections, n);
901 for (
const auto &node : relatedBy)
902 distributeNodeInSummaryVector(summarySections, node);
905 QStack<ClassNode *> stack;
906 auto *cn =
static_cast<
ClassNode *>(m_aggregate);
907 pushBaseClasses(stack, cn);
908 while (!stack.isEmpty()) {
910 for (
auto it = cn->constBegin(); it != cn->constEnd(); ++it) {
918 pushBaseClasses(stack, cn);
926
927
928
940 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
941 for (
const auto n : qtn->childNodes()) {
942 const NodeContext context = n->createContext();
943 if (!InclusionFilter::isIncluded(policy, context))
947 if (qtn != m_aggregate && qtn->isAbstract()) {
949 m_aggregate->findChildren(n->name(), candidates);
950 if (std::any_of(candidates.cbegin(), candidates.cend(), [&n](
const Node *c) {
951 if (c->nodeType() == n->nodeType()) {
952 if (!n->isFunction() ||
953 compare(
static_cast<
const FunctionNode *>(n),
954 static_cast<
const FunctionNode *>(c)) == 0)
963 if (!n->isSharedCommentNode() || n->isPropertyGroup()) {
964 allMembers.insert(n);
965 classNodes->second.push_back(n);
969 if (qtn == m_aggregate || qtn->isAbstract()) {
970 distributeQmlNodeInSummaryVector(summarySections, n);
971 distributeQmlNodeInDetailsVector(detailsSections, n);
975 qCDebug(lcQdoc,
"error: circular type definition: '%s' inherits itself",
976 qPrintable(qtn->name()));
988
989
990
991
992
1003 for (
const auto §ion : *sections) {
1004 if (!section.obsoleteMembers().isEmpty())
1005 summary_spv->append(§ion);
1013 for (
const auto &it : *sections) {
1014 if (!it.obsoleteMembers().isEmpty())
1015 details_spv->append(&it);
1017 return !summary_spv->isEmpty();
virtual QmlTypeNode * qmlBaseNode() const
If this Aggregate is a QmlTypeNode, this function returns a pointer to the QmlTypeNode that is its ba...
NodeList & relatedByProxy()
Returns a reference to a list of node pointers where each element points to a node in an index file f...
The ClassNode represents a C++ class.
This node is used to represent any kind of function being documented.
bool isIgnored() const
In some cases, it is ok for a public function to be not documented.
bool isQmlSignalHandler() const
static bool isReimplementedMemberVisible(const InclusionPolicy &policy, const NodeContext &context)
static bool isIncluded(const InclusionPolicy &policy, const NodeContext &context)
This class represents a C++ namespace.
const NodeList & includedChildren() const
Returns a const reference to the namespace node's list of included children, which contains pointers ...
A class for containing the elements of one documentation section.
void clear()
A Section is now an element in a static vector, so we don't have to repeatedly construct and destroy ...
void insert(Node *node)
Inserts the node into this section if it is appropriate for this section.
void reduce()
If this section is not empty, convert its maps to sequential structures for better traversal during d...
ClassNodesList & classNodesList()
bool insertReimplementedMember(Node *node)
Returns true if the node is a reimplemented member function of the current class.
~Section()
The destructor must delete the members of collections when the members are allocated on the heap.
A class for creating vectors of collections for documentation.
const SectionVector & stdCppClassDetailsSections() const
void buildStdCppClassRefPageSections()
Build the section vectors for a standard reference page, when the aggregate node is a C++.
Sections(Aggregate *aggregate)
This constructor builds the vectors of sections based on the type of the aggregate node.
SectionVector & stdCppClassSummarySections()
SectionVector & stdQmlTypeSummarySections()
~Sections()
The behavior of the destructor depends on the type of the Aggregate node that was passed to the const...
SectionVector & stdDetailsSections()
const SectionVector & stdQmlTypeDetailsSections() const
const SectionVector & stdCppClassSummarySections() const
const SectionVector & stdQmlTypeSummarySections() const
void buildStdRefPageSections()
Build the section vectors for a standard reference page, when the aggregate node is not a C++ class o...
void clear(SectionVector &v)
Reset each Section in vector v to its initialized state.
SectionVector & stdCppClassDetailsSections()
void reduce(SectionVector &v)
Linearize the maps in each Section in v.
const SectionVector & stdDetailsSections() const
void buildStdQmlTypeRefPageSections()
Build the section vectors for a standard reference page, when the aggregate node is a QML type.
SectionVector & stdQmlTypeDetailsSections()
SectionVector & sinceSections()
Sections(const NodeMultiMap &nsmap)
This constructor builds a vector of sections from the since node map, nsmap.
bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const
Returns true if any sections in this object contain obsolete members.
SectionVector & stdSummarySections()
const SectionVector & stdSummarySections() const
static Section & allMembersSection()
const EnumNode * associatedEnum() const
QList< Node * > NodeVector
QString sortName(const Node *node)
Construct a name for the node that can be used for sorting a set of nodes into equivalence classes.
static Node * nodeToTestForDistribution(Node *node)
static void pushBaseClasses(QStack< ClassNode * > &stack, ClassNode *cn)
std::pair< const QmlTypeNode *, NodeVector > ClassNodes
QList< const Section * > SectionPtrVector
QList< Section > SectionVector
The Node class is the base class for all the nodes in QDoc's parse tree.
const Doc & doc() const
Returns a reference to the node's Doc data member.
virtual bool isStatic() const
Returns true if the FunctionNode represents a static function.
bool isEnumType(Genus g) const
bool isPrivate() const
Returns true if this node's access is Private.
virtual bool isAbstract() const
Returns true if the ClassNode or QmlTypeNode is marked abstract.
bool isNamespace() const
Returns true if the node type is Namespace.
bool isTypedef() const
Returns true if the node type is Typedef.
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
bool isSharedCommentNode() const
Returns true if the node type is SharedComment.
NodeType nodeType() const override
Returns this node's type.
bool isEnumType() const
Returns true if the node type is Enum.
Aggregate * parent() const
Returns the node's parent pointer.
bool isPublic() const
Returns true if this node's access is Public.
bool isVariable() const
Returns true if the node type is Variable.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
bool isProperty() const
Returns true if the node type is Property.
NodeContext createContext() const
virtual bool isPropertyGroup() const
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
bool isSharingComment() const
This function returns true if the node is sharing a comment with other nodes.
bool hasDoc() const
Returns true if this node is documented, or it represents a documented node read from the index ('had...
bool isRelatedNonmember() const
Returns true if this is a related nonmember of something.
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
bool isQmlProperty() const
Returns true if the node type is QmlProperty.