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
nodeextractor.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
6#include "atom.h"
7#include "doc.h"
8#include "ir/contentbuilder.h"
9#include "pagenode.h"
10#include "text.h"
11
13
14namespace NodeExtractor {
15
16/*!
17 \internal
18 Extract page-level metadata from a PageNode into a value-type struct.
19
20 This function reads classification, identity, brief, and body fields
21 from the given PageNode and returns them as an IR::PageMetadata value.
22 Body content is populated via ContentBuilder, which transforms the
23 atom chain into structured content blocks. Format-conditional atoms
24 are skipped unconditionally since the template generator builds a
25 format-agnostic IR.
26
27 The caller (TemplateGenerator) invokes this before passing the
28 result to IR::Builder, ensuring Builder never includes PageNode
29 or other Node subclass headers.
30*/
32{
33 Q_ASSERT_X(pn, "NodeExtractor::extractPageMetadata",
34 "PageNode pointer must be non-null");
35 IR::PageMetadata pm;
36
37 pm.nodeType = pn->nodeType();
38 pm.genus = pn->genus();
39 pm.status = pn->status();
40 pm.access = pn->access();
41
42 pm.title = pn->title();
43 pm.fullTitle = pn->fullTitle();
44 pm.url = pn->url();
45 pm.since = pn->since();
46 pm.deprecatedSince = pn->deprecatedSince();
47 pm.brief = pn->doc().briefText().toString();
48
49 const Text &bodyText = pn->doc().body();
50 if (const Atom *firstAtom = bodyText.firstAtom()) {
51 IR::ContentBuilder contentBuilder;
52 pm.body = contentBuilder.build(firstAtom);
53 }
54
55 return pm;
56}
57
58} // namespace NodeExtractor
59
60QT_END_NAMESPACE
The Atom class is the fundamental unit for representing documents internally.
Definition atom.h:19
Converts Atom chains to QList<IR::ContentBlock> trees.
A PageNode is a Node that generates a documentation page.
Definition pagenode.h:19
Definition text.h:12
const Atom * firstAtom() const
Definition text.h:34
Definition builder.cpp:14
IR::PageMetadata extractPageMetadata(const PageNode *pn)
Combined button and popup list for selecting options.
const Doc & doc() const
Returns a reference to the node's Doc data member.
Definition node.h:235
NodeType nodeType() const override
Returns this node's type.
Definition node.h:82
Genus genus() const override
Returns this node's Genus.
Definition node.h:85
virtual Status status() const
Returns the node's status value.
Definition node.h:239
Access access() const
Returns the node's Access setting, which can be Public, Protected, or Private.
Definition node.h:228