Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
classificationjson.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QDOC_IR_CLASSIFICATIONJSON_H
5#define QDOC_IR_CLASSIFICATIONJSON_H
6
7#include "qdoc/access.h"
8#include "qdoc/genustypes.h"
9#include "qdoc/status.h"
10
11#include <QJsonObject>
12#include <QString>
13
14#include <optional>
15
17
18using namespace Qt::Literals::StringLiterals;
19
20namespace IR {
21
22// Returns a JSON object with "id" and "label" keys.
23// Classification fields use a stable kebab-case id for template
24// conditionals and a human-readable label for display.
25inline QJsonObject classificationObject(const QString &id, const QString &label)
26{
27 QJsonObject obj;
28 obj["id"_L1] = id;
29 obj["label"_L1] = label;
30 return obj;
31}
32
33// Returns {id, label} for a NodeType, or std::nullopt for NoType.
35{
36 switch (t) {
38 return std::nullopt;
39 case NodeType::Namespace:
40 return classificationObject("namespace"_L1, "Namespace"_L1);
41 case NodeType::Class:
42 return classificationObject("class"_L1, "Class"_L1);
43 case NodeType::Struct:
44 return classificationObject("struct"_L1, "Struct"_L1);
45 case NodeType::Union:
46 return classificationObject("union"_L1, "Union"_L1);
47 case NodeType::HeaderFile:
48 return classificationObject("header-file"_L1, "Header file"_L1);
49 case NodeType::Page:
50 return classificationObject("page"_L1, "Page"_L1);
51 case NodeType::Enum:
52 return classificationObject("enum"_L1, "Enum"_L1);
53 case NodeType::Example:
54 return classificationObject("example"_L1, "Example"_L1);
55 case NodeType::ExternalPage:
56 return classificationObject("external-page"_L1, "External page"_L1);
57 case NodeType::TypeAlias:
58 return classificationObject("type-alias"_L1, "Type alias"_L1);
59 case NodeType::Typedef:
60 return classificationObject("typedef"_L1, "Typedef"_L1);
61 case NodeType::Function:
62 return classificationObject("function"_L1, "Function"_L1);
63 case NodeType::Property:
64 return classificationObject("property"_L1, "Property"_L1);
65 case NodeType::Proxy:
66 return classificationObject("proxy"_L1, "Proxy"_L1);
67 case NodeType::Variable:
68 return classificationObject("variable"_L1, "Variable"_L1);
69 case NodeType::Group:
70 return classificationObject("group"_L1, "Group"_L1);
71 case NodeType::Module:
72 return classificationObject("module"_L1, "Module"_L1);
73 case NodeType::QmlType:
74 return classificationObject("qml-type"_L1, "QML type"_L1);
75 case NodeType::QmlValueType:
76 return classificationObject("qml-value-type"_L1, "QML value type"_L1);
77 case NodeType::QmlModule:
78 return classificationObject("qml-module"_L1, "QML module"_L1);
79 case NodeType::QmlProperty:
80 return classificationObject("qml-property"_L1, "QML property"_L1);
81 case NodeType::QmlEnum:
82 return classificationObject("qml-enum"_L1, "QML enum"_L1);
83 case NodeType::SharedComment:
84 return classificationObject("shared-comment"_L1, "Shared comment"_L1);
85 case NodeType::Collection:
86 return classificationObject("collection"_L1, "Collection"_L1);
87 }
88 Q_UNREACHABLE();
89}
90
91// Returns {id, label} for a Genus, or std::nullopt for DontCare.
93{
94 switch (g) {
95 case Genus::DontCare:
96 return std::nullopt;
97 case Genus::CPP:
98 return classificationObject("cpp"_L1, "C++"_L1);
99 case Genus::QML:
100 return classificationObject("qml"_L1, "QML"_L1);
101 case Genus::DOC:
102 return classificationObject("doc"_L1, "Documentation"_L1);
103 case Genus::API:
104 return classificationObject("api"_L1, "API"_L1);
105 }
106 Q_UNREACHABLE();
107}
108
109// Returns {id, label} for a Status value.
111{
112 switch (s) {
113 case Status::Deprecated:
114 return classificationObject("deprecated"_L1, "Deprecated"_L1);
115 case Status::Preliminary:
116 return classificationObject("preliminary"_L1, "Preliminary"_L1);
117 case Status::Active:
118 return classificationObject("active"_L1, "Active"_L1);
119 case Status::Internal:
120 return classificationObject("internal"_L1, "Internal"_L1);
121 case Status::DontDocument:
122 return classificationObject("ignored"_L1, "Ignored"_L1);
123 }
124 Q_UNREACHABLE();
125}
126
127// Returns {id, label} for an Access value.
129{
130 switch (a) {
131 case Access::Public:
132 return classificationObject("public"_L1, "Public"_L1);
133 case Access::Protected:
134 return classificationObject("protected"_L1, "Protected"_L1);
135 case Access::Private:
136 return classificationObject("private"_L1, "Private"_L1);
137 }
138 Q_UNREACHABLE();
139}
140
141} // namespace IR
142
143QT_END_NAMESPACE
144
145#endif // QDOC_IR_CLASSIFICATIONJSON_H
Access
Definition access.h:11
Status
Specifies the status of the QQmlIncubator.
NodeType
Definition genustypes.h:150
Definition builder.cpp:14
QJsonObject accessToJson(Access a)
std::optional< QJsonObject > nodeTypeToJson(NodeType t)
std::optional< QJsonObject > genusToJson(Genus g)
static QJsonArray memberEntriesToJson(const QList< CollectionInfo::MemberEntry > &entries)
Definition document.cpp:76
QJsonObject statusToJson(Status s)
QJsonObject classificationObject(const QString &id, const QString &label)
Combined button and popup list for selecting options.
QJsonObject toJson() const
Converts the CollectionInfo to a QJsonObject for template rendering.
Definition document.cpp:99
Intermediate representation for a documentation topic.
Definition document.h:81
QJsonObject toJson() const
Converts the Document to a QJsonObject for template rendering.
Definition document.cpp:141
QJsonObject toJson() const
Converts the QmlTypeInfo to a QJsonObject for template rendering.
Definition document.cpp:38