Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
contentbuilder.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_CONTENTBUILDER_H
5
#
define
QDOC_IR_CONTENTBUILDER_H
6
7
#
include
"contentblock.h"
8
9
#
include
<
QJsonObject
>
10
#
include
<
QList
>
11
#
include
<
QString
>
12
13
#
include
<
functional
>
14
15
QT_BEGIN_NAMESPACE
16
17
class
Atom;
18
19
namespace
IR
{
20
21
using
DiagnosticHandler
=
std
::
function
<
void
(
QtMsgType
,
const
QString
&)>;
22
23
/*!
24
\enum IR::BriefHandling
25
\internal
26
27
Controls whether ContentBuilder emits brief content into the body.
28
29
\value Skip Brief content between BriefLeft/BriefRight is suppressed.
30
This is the default for IR::Builder, where the brief is stored
31
as a separate field in IR::Document.
32
\value Include Brief content is emitted as a normal Paragraph block.
33
This enables callers that need the brief rendered as part of
34
the body, matching the behavior where the brief appears as the
35
opening paragraph.
36
*/
37
enum
class
BriefHandling
{
Skip
,
Include
};
38
39
class
ContentBuilder
40
{
41
public
:
42
explicit
ContentBuilder
(
BriefHandling
briefHandling =
BriefHandling
::
Skip
,
43
int
headingOffset = 0,
44
DiagnosticHandler diagnosticHandler = {});
45
QList
<
ContentBlock
>
build
(
const
Atom
*firstAtom);
46
47
private
:
48
void
processAtoms(
const
Atom
*atom);
49
const
Atom
*skipFormatIfBlock(
const
Atom
*atom);
50
const
Atom
*dispatchAtom(
const
Atom
*atom);
51
52
void
openBlock(
BlockType
type, QJsonObject attrs = {});
53
void
closeBlock();
54
void
addInline(
InlineContent
inline_);
55
void
addLeafInline(
InlineType
type,
const
QString &text);
56
void
pushInlineContainer(
InlineContent
container);
57
58
ContentBlock
*resolveBlock();
59
InlineContent
*resolveInline();
60
61
QList<ContentBlock> m_result;
62
63
// Index path through m_result / children hierarchy.
64
// First index selects from m_result; subsequent indices descend
65
// through children lists. Indices remain valid as long as we only
66
// append and never remove or reorder items.
67
QList<qsizetype> m_blockPath;
68
69
QList<qsizetype> m_inlinePath;
70
71
// Records m_inlinePath.size() at each openBlock() call, so that
72
// closeBlock() can verify/restore inline depth (one entry per
73
// m_blockPath entry, always in sync).
74
QList<qsizetype> m_inlineBaseDepths;
75
76
BriefHandling
m_briefHandling =
BriefHandling
::
Skip
;
77
int
m_headingOffset = 0;
78
bool
m_inBrief =
false
;
79
bool
m_inLink =
false
;
80
DiagnosticHandler m_diagnose;
81
};
82
83
}
// namespace IR
84
85
QT_END_NAMESPACE
86
87
#
endif
// QDOC_IR_CONTENTBUILDER_H
ATOM_FORMATTING_TELETYPE
#define ATOM_FORMATTING_TELETYPE
Definition
atom.h:204
ATOM_FORMATTING_UNDERLINE
#define ATOM_FORMATTING_UNDERLINE
Definition
atom.h:207
ATOM_FORMATTING_NOTRANSLATE
#define ATOM_FORMATTING_NOTRANSLATE
Definition
atom.h:199
ATOM_LIST_TAG
#define ATOM_LIST_TAG
Definition
atom.h:210
ATOM_FORMATTING_SUBSCRIPT
#define ATOM_FORMATTING_SUBSCRIPT
Definition
atom.h:202
ATOM_FORMATTING_BOLD
#define ATOM_FORMATTING_BOLD
Definition
atom.h:195
ATOM_FORMATTING_TRADEMARK
#define ATOM_FORMATTING_TRADEMARK
Definition
atom.h:205
ATOM_LIST_VALUE
#define ATOM_LIST_VALUE
Definition
atom.h:211
ATOM_FORMATTING_ITALIC
#define ATOM_FORMATTING_ITALIC
Definition
atom.h:197
ATOM_FORMATTING_LINK
#define ATOM_FORMATTING_LINK
Definition
atom.h:198
ATOM_FORMATTING_SUPERSCRIPT
#define ATOM_FORMATTING_SUPERSCRIPT
Definition
atom.h:203
ATOM_FORMATTING_INDEX
#define ATOM_FORMATTING_INDEX
Definition
atom.h:196
ATOM_FORMATTING_UICONTROL
#define ATOM_FORMATTING_UICONTROL
Definition
atom.h:206
ATOM_FORMATTING_PARAMETER
#define ATOM_FORMATTING_PARAMETER
Definition
atom.h:200
Atom
The Atom class is the fundamental unit for representing documents internally.
Definition
atom.h:19
Atom::type
AtomType type() const
Return the type of this atom.
Definition
atom.h:144
Atom::CaptionLeft
@ CaptionLeft
Definition
atom.h:29
Atom::TableRight
@ TableRight
Definition
atom.h:97
Atom::GeneratedList
@ GeneratedList
Definition
atom.h:52
Atom::BriefRight
@ BriefRight
Definition
atom.h:27
Atom::TableHeaderRight
@ TableHeaderRight
Definition
atom.h:99
Atom::FormatElse
@ FormatElse
Definition
atom.h:47
Atom::InlineImage
@ InlineImage
Definition
atom.h:58
Atom::TableRowRight
@ TableRowRight
Definition
atom.h:101
Atom::Nop
@ Nop
Definition
atom.h:74
Atom::WarningRight
@ WarningRight
Definition
atom.h:111
Atom::ListTagRight
@ ListTagRight
Definition
atom.h:68
Atom::CaptionRight
@ CaptionRight
Definition
atom.h:30
Atom::NavLink
@ NavLink
Definition
atom.h:73
Atom::ListItemNumber
@ ListItemNumber
Definition
atom.h:66
Atom::SinceTagRight
@ SinceTagRight
Definition
atom.h:91
Atom::CodeBad
@ CodeBad
Definition
atom.h:32
Atom::AnnotatedList
@ AnnotatedList
Definition
atom.h:22
Atom::SectionRight
@ SectionRight
Definition
atom.h:84
Atom::SectionHeadingLeft
@ SectionHeadingLeft
Definition
atom.h:85
Atom::TableLeft
@ TableLeft
Definition
atom.h:96
Atom::ListItemRight
@ ListItemRight
Definition
atom.h:70
Atom::Image
@ Image
Definition
atom.h:54
Atom::TableItemRight
@ TableItemRight
Definition
atom.h:103
Atom::ListItemLeft
@ ListItemLeft
Definition
atom.h:69
Atom::ImportantRight
@ ImportantRight
Definition
atom.h:57
Atom::Code
@ Code
Definition
atom.h:31
Atom::ListLeft
@ ListLeft
Definition
atom.h:65
Atom::NavAutoLink
@ NavAutoLink
Definition
atom.h:72
Atom::BriefLeft
@ BriefLeft
Definition
atom.h:26
Atom::ImageText
@ ImageText
Definition
atom.h:55
Atom::ListRight
@ ListRight
Definition
atom.h:71
Atom::ParaRight
@ ParaRight
Definition
atom.h:78
Atom::Qml
@ Qml
Definition
atom.h:79
Atom::FormattingLeft
@ FormattingLeft
Definition
atom.h:50
Atom::FormattingRight
@ FormattingRight
Definition
atom.h:51
Atom::SectionHeadingRight
@ SectionHeadingRight
Definition
atom.h:86
Atom::Link
@ Link
Definition
atom.h:63
Atom::FormatEndif
@ FormatEndif
Definition
atom.h:48
Atom::SinceTagLeft
@ SinceTagLeft
Definition
atom.h:90
Atom::AutoLink
@ AutoLink
Definition
atom.h:23
Atom::TableItemLeft
@ TableItemLeft
Definition
atom.h:102
Atom::NoteRight
@ NoteRight
Definition
atom.h:76
Atom::BaseName
@ BaseName
Definition
atom.h:24
Atom::FormatIf
@ FormatIf
Definition
atom.h:49
Atom::isLinkAtom
virtual bool isLinkAtom() const
Definition
atom.h:152
Atom::next
const Atom * next() const
Return the next atom in the atom list.
Definition
atom.h:141
Atom::genus
virtual Genus genus()
Definition
atom.h:153
IR::ContentBuilder
Converts Atom chains to QList<IR::ContentBlock> trees.
Definition
contentbuilder.h:40
IR::ContentBuilder::build
QList< ContentBlock > build(const Atom *firstAtom)
Walks the atom chain starting at firstAtom and returns a list of ContentBlock trees representing the ...
Definition
contentbuilder.cpp:181
IR::ContentBuilder::ContentBuilder
ContentBuilder(BriefHandling briefHandling=BriefHandling::Skip, int headingOffset=0, DiagnosticHandler diagnosticHandler={})
Constructs a ContentBuilder.
Definition
contentbuilder.cpp:146
genusToString
static QString genusToString(Genus genus)
Definition
contentbuilder.cpp:28
stripCodeMarkerTags
static QString stripCodeMarkerTags(const QString &markedCode)
Definition
contentbuilder.cpp:16
placeholderSortAttribute
static QString placeholderSortAttribute(const Atom *atom)
Definition
contentbuilder.cpp:40
IR
Definition
builder.cpp:14
IR::LinkState
LinkState
Definition
contentblock.h:41
IR::LinkState::Unresolved
@ Unresolved
Definition
contentblock.h:42
IR::LinkOrigin
LinkOrigin
Definition
contentblock.h:35
IR::LinkOrigin::Auto
@ Auto
Definition
contentblock.h:36
IR::LinkOrigin::Explicit
@ Explicit
Definition
contentblock.h:37
IR::BriefHandling
BriefHandling
Definition
contentbuilder.h:37
IR::BriefHandling::Skip
@ Skip
Definition
contentbuilder.h:37
IR::BriefHandling::Include
@ Include
Definition
contentbuilder.h:37
IR::BlockType
BlockType
Definition
contentblock.h:80
IR::formattingToInlineType
static InlineType formattingToInlineType(const QString &formatting)
Definition
contentbuilder.cpp:153
IR::InlineType
InlineType
Definition
contentblock.h:17
IR::InlineType::Bold
@ Bold
Definition
contentblock.h:21
IR::InlineType::Italic
@ Italic
Definition
contentblock.h:22
IR::InlineType::Superscript
@ Superscript
Definition
contentblock.h:27
IR::InlineType::Teletype
@ Teletype
Definition
contentblock.h:23
IR::InlineType::Parameter
@ Parameter
Definition
contentblock.h:28
IR::InlineType::Underline
@ Underline
Definition
contentblock.h:24
IR::InlineType::Subscript
@ Subscript
Definition
contentblock.h:26
IR::InlineType::Link
@ Link
Definition
contentblock.h:20
IR::InlineType::Text
@ Text
Definition
contentblock.h:18
IR::InlineType::Image
@ Image
Definition
contentblock.h:30
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
IR::ContentBlock
Represents a structural block element in documentation.
Definition
contentblock.h:109
IR::ContentBlock::type
BlockType type
Definition
contentblock.h:110
IR::InlineContent::LinkData
Definition
contentblock.h:64
IR::InlineContent::LinkData::LinkData
LinkData(LinkOrigin o, LinkState s, std::optional< SourceLocation > loc=std::nullopt)
Definition
contentblock.h:70
IR::InlineContent::SourceLocation
Definition
contentblock.h:59
IR::InlineContent
Represents inline content within a documentation block.
Definition
contentblock.h:51
IR::InlineContent::type
InlineType type
Definition
contentblock.h:52
qttools
src
qdoc
qdoc
src
qdoc
ir
contentbuilder.h
Generated on
for Qt by
1.18.0