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
listplaceholder.cpp
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
5
7
8using namespace Qt::Literals::StringLiterals;
9
10namespace IR {
11
12/*!
13 \enum IR::ListPlaceholderVariant
14 \internal
15 \brief Discriminator naming the catalog shape carried by a
16 \c{BlockType::ListPlaceholder} block.
17
18 The content builder picks a variant when emitting a list-placeholder
19 for \\generatelist or \\annotatedlist; the list-expander pass
20 matches on the variant when populating the catalog. Adding a
21 catalog form means adding an enumerator here and a matching arm in
22 \c{toString()}, so a missing string mapping fails to compile.
23
24 \value AnnotatedGroup The annotated members of a documentation
25 group, emitted for \\annotatedlist \e{<group>}.
26 \value AnnotatedExamples The annotated list of example projects,
27 emitted for \\generatelist annotatedexamples.
28 \value AnnotatedClasses The annotated list of public classes,
29 emitted for \\generatelist annotatedclasses.
30 \value CompactClasses The compact, alphabetically-grouped classes
31 index, emitted for \\generatelist classes \e{[<rootname>]}.
32*/
33
34/*!
35 \fn QString IR::toString(ListPlaceholderVariant variant)
36 \internal
37
38 Returns the canonical kebab-case string used as the \c variant
39 attribute of the placeholder block in JSON output. The string is
40 the contract between the content builder, the list-expander pass,
41 and the templates: every consumer matches on the same value, and
42 \c{toString()} is the single source of truth.
43*/
45{
46 switch (variant) {
47 case ListPlaceholderVariant::AnnotatedGroup: return u"annotated-group"_s;
48 case ListPlaceholderVariant::AnnotatedExamples: return u"annotated-examples"_s;
49 case ListPlaceholderVariant::AnnotatedClasses: return u"annotated-classes"_s;
50 case ListPlaceholderVariant::CompactClasses: return u"compact-classes"_s;
51 }
52 Q_UNREACHABLE_RETURN({});
53}
54
55/*!
56 \fn std::optional<IR::ListPlaceholderVariant> IR::parseListPlaceholderVariant(
57 QStringView variant)
58 \internal
59
60 Reverse of \c{toString()}: maps the canonical kebab-case string
61 back to a \c{ListPlaceholderVariant}, or \c{std::nullopt} for an
62 unrecognized value. Used by the list-expander pass to dispatch
63 on the placeholder block's \c{variant} attribute without
64 introducing a parallel set of string literals.
65*/
67{
68 if (variant == u"annotated-group")
70 if (variant == u"annotated-examples")
72 if (variant == u"annotated-classes")
74 if (variant == u"compact-classes")
76 return std::nullopt;
77}
78
79} // namespace IR
80
81QT_END_NAMESPACE
Definition builder.cpp:14
ListPlaceholderVariant
QString toString(ListPlaceholderVariant variant)
std::optional< ListPlaceholderVariant > parseListPlaceholderVariant(QStringView variant)
Combined button and popup list for selecting options.