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
irbuilder.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
4
#
include
"irbuilder.h"
5
6
#
include
"../atom.h"
7
#
include
"../pagenode.h"
8
#
include
"../text.h"
9
10
QT_BEGIN_NAMESPACE
11
12
using
namespace
Qt::Literals;
13
14
/*!
15
\class IRBuilder
16
\internal
17
\brief Builds IR (Intermediate Representation) from QDoc's Node tree.
18
19
IRBuilder is the "compiler" in QDoc's compile/link/render pipeline. It
20
transforms Node objects into format-agnostic IR structures that can be:
21
22
\list
23
\li Rendered to output formats (HTML, Markdown, DocBook) by generators.
24
\li Written to .index files for cross-module linking.
25
\li Consumed by other IR processors.
26
\endlist
27
28
\section1 Separation of Concerns
29
30
IRBuilder handles all interaction with Node classes and Atom chains.
31
Generators receive pre-built IR and focus purely on formatting output.
32
This separation enables:
33
34
\list
35
\li Testing IR building independently from rendering.
36
\li Multiple output formats from the same IR.
37
\li Clear architectural boundaries.
38
\endlist
39
40
\section1 Link Resolution
41
42
During IR building, \b{local links} (within the same module) are resolved
43
immediately. \b{Cross-module links} are marked as external with an empty
44
href, to be resolved during the link phase when dependency .index files
45
are available.
46
47
\sa DocumentIR, TemplateGenerator
48
*/
49
50
51
/*!
52
\internal
53
Build IR for a PageNode.
54
55
This method extracts documentation content from the node's atom chain.
56
The brief is stored separately via Doc::briefText(), while body content
57
is extracted by walking the atom chain and collecting text atoms that
58
are not within the brief section.
59
60
\note Currently handles basic text atoms (String, AutoLink, C) and
61
paragraph breaks. More complex atom types (lists, code blocks, images)
62
will be added as the IR layer matures.
63
*/
64
DocumentIR
IRBuilder
::
buildPageIR
(
const
PageNode
*pn)
const
65
{
66
DocumentIR
ir;
67
ir.title = pn->title();
68
ir.fullTitle = pn->fullTitle();
69
ir.url = pn->url();
70
ir.brief = pn
->
doc
().briefText().toString();
71
72
QString bodyText;
73
const
Text
&body = pn
->
doc
().body();
74
const
Atom
*atom = body
.
firstAtom
(
)
;
75
bool
inBrief =
false
;
76
77
while
(atom) {
78
switch
(atom
->
type
(
)
) {
79
case
Atom
::
BriefLeft
:
80
inBrief =
true
;
81
break
;
82
case
Atom
::
BriefRight
:
83
inBrief =
false
;
84
break
;
85
case
Atom::ParaLeft:
86
if
(!inBrief && !bodyText.isEmpty())
87
bodyText +=
"\n\n"_L1
;
88
break
;
89
case
Atom
::
String
:
90
case
Atom
::
AutoLink
:
91
case
Atom
::
C
:
92
if
(!inBrief)
93
bodyText += atom->string();
94
break
;
95
default
:
96
break
;
97
}
98
atom = atom
->
next
(
)
;
99
}
100
101
ir.contentJson[
"text"_L1
] = bodyText.trimmed();
102
103
return
ir;
104
}
105
106
QT_END_NAMESPACE
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:153
Atom::BriefRight
@ BriefRight
Definition
atom.h:27
Atom::String
@ String
Definition
atom.h:93
Atom::BriefLeft
@ BriefLeft
Definition
atom.h:26
Atom::C
@ C
Definition
atom.h:28
Atom::AutoLink
@ AutoLink
Definition
atom.h:23
Atom::next
const Atom * next() const
Return the next atom in the atom list.
Definition
atom.h:150
IRBuilder
Builds IR (Intermediate Representation) from QDoc's Node tree.
Definition
irbuilder.h:14
IRBuilder::buildPageIR
DocumentIR buildPageIR(const PageNode *pn) const
Definition
irbuilder.cpp:64
PageNode
A PageNode is a Node that generates a documentation page.
Definition
pagenode.h:19
Text
Definition
text.h:12
Text::firstAtom
const Atom * firstAtom() const
Definition
text.h:34
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
DocumentIR
Intermediate representation for a documentation topic.
Definition
documentir.h:20
Node::doc
const Doc & doc() const
Returns a reference to the node's Doc data member.
Definition
node.h:235
qttools
src
qdoc
qdoc
src
qdoc
ir
irbuilder.cpp
Generated on
for Qt by
1.16.1