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
builder.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 "builder.h"
5
6#include "pagemetadata.h"
7
8#include <utility>
9
10QT_BEGIN_NAMESPACE
11
12using namespace Qt::Literals;
13
14namespace IR {
15
16/*!
17 \class IR::Builder
18 \internal
19 \brief Assembles IR Documents from pre-extracted metadata.
20
21 Builder consumes PageMetadata, a value-type struct populated by the
22 driver-side extraction layer (NodeExtractor). It copies pre-extracted
23 fields into an IR::Document without touching Node subclass headers,
24 Atom chains, or the documentation database.
25
26 This separation means Builder has no dependencies on the legacy Node
27 layer and is eligible for QDocLib migration. Generators receive
28 pre-built IR and focus purely on formatting output.
29
30 \section1 Content Pipeline
31
32 Content arrives pre-built as a list of ContentBlock values in
33 PageMetadata::body. ContentBuilder (called at extraction time)
34 handles the atom-to-block transformation, including brief
35 exclusion. Format-conditional atoms are skipped unconditionally
36 since the IR is format-agnostic. Builder's role is assembly, not
37 transformation.
38
39 \section1 Flat Text Fallback
40
41 Builder computes a flat text representation from the structured body
42 for \c{content.text}. This is transitional — templates will consume
43 \c{content.blocks} directly once content rendering is in place.
44
45 \sa IR::Document, IR::PageMetadata, TemplateGenerator
46*/
47
48
49/*!
50 \internal
51 Assemble an IR Document from pre-extracted PageMetadata.
52
53 Classification, identity, and content fields are moved from
54 \a pm. The body (a list of ContentBlock values built by
55 ContentBuilder at extraction time) is transferred as-is. A flat
56 text fallback is computed until templates consume the structured
57 body directly.
58*/
60{
61 Document ir;
62
63 ir.nodeType = pm.nodeType;
64 ir.genus = pm.genus;
65 ir.status = pm.status;
66 ir.access = pm.access;
67
68 ir.title = std::move(pm.title);
69 ir.fullTitle = std::move(pm.fullTitle);
70 ir.url = std::move(pm.url);
71 ir.since = std::move(pm.since);
72 ir.deprecatedSince = std::move(pm.deprecatedSince);
73 ir.brief = std::move(pm.brief);
74
75 ir.body = std::move(pm.body);
76
77 // Transitional: templates don't yet consume content.blocks.
78 QStringList paragraphs;
79 for (const auto &block : ir.body) {
80 const QString text = block.plainText();
81 if (!text.isEmpty())
82 paragraphs.append(text);
83 }
84 ir.contentJson["text"_L1] = paragraphs.join("\n\n"_L1);
85
86 return ir;
87}
88
89} // namespace IR
90
91QT_END_NAMESPACE
Assembles IR Documents from pre-extracted metadata.
Definition builder.h:15
Document buildPageIR(PageMetadata pm) const
Definition builder.cpp:59
Definition builder.cpp:14
Intermediate representation for a documentation topic.
Definition document.h:22
Access access
Definition document.h:27
Status status
Definition document.h:26
NodeType nodeType
Definition document.h:24
Genus genus
Definition document.h:25