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
linkresolver.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_LINKRESOLVER_H
5#define QDOC_LINKRESOLVER_H
6
7#ifdef QDOC_TEMPLATE_GENERATOR_ENABLED
8
9#include <QtCore/qlist.h>
10
11QT_BEGIN_NAMESPACE
12
13class HrefResolver;
14class Node;
15class QDocDatabase;
16
17namespace IR {
18struct ContentBlock;
19struct InlineContent;
20} // namespace IR
21
22struct LinkResolverConfig
23{
24 bool autolinkErrors{false};
25 bool noLinkErrors{false};
26};
27
28/*!
29 \class LinkResolver
30 \internal
31 \brief Walks ContentBlock trees and resolves unresolved Link inlines to URLs.
32
33 LinkResolver sits between ContentBuilder and rendering. ContentBuilder
34 produces Link inlines with raw target strings (such as "QWidget" or
35 "QString::size"). LinkResolver resolves these targets to actual URLs
36 using QDocDatabase for node lookup and HrefResolver for URL computation.
37
38 External URLs (http, https, ftp, file, mailto) are detected and marked
39 without node lookup. Links to deprecated nodes from non-deprecated
40 content are suppressed. Suppressed links carry a diagnostic linkState
41 string identifying the reason (policy exclusion, self-reference, etc.).
42 Unresolvable links emit warnings controlled by the injected
43 LinkResolverConfig.
44
45 \sa HrefResolver, IR::ContentBuilder
46*/
47class LinkResolver
48{
49public:
50 LinkResolver(QDocDatabase *qdb, const HrefResolver &hrefResolver,
51 const LinkResolverConfig &config);
52
53 void resolve(QList<IR::ContentBlock> &blocks, const Node *relative);
54
55private:
56 void resolveBlock(IR::ContentBlock &block, const Node *relative);
57 void resolveInlines(QList<IR::InlineContent> &inlines, const Node *relative);
58 void resolveLink(IR::InlineContent &link, const Node *relative);
59
60 QDocDatabase *m_qdb;
61 const HrefResolver &m_hrefResolver;
62 LinkResolverConfig m_config;
63};
64
65QT_END_NAMESPACE
66
67#endif // QDOC_TEMPLATE_GENERATOR_ENABLED
68
69#endif // QDOC_LINKRESOLVER_H
A class for holding the members of a collection of doc pages.
The Config class contains the configuration variables for controlling how qdoc produces documentation...
Definition config.h:85
InclusionPolicy createInclusionPolicy() const
Definition config.cpp:1608
Interface handling documentation generation during tree traversal.
Traverses the node tree and dispatches to a handler for documentation generation.
void traverse(Node *root, DocumentationHandler &handler)
Encapsulate the logic that QDoc uses to find files whose path is provided by the user and that are re...
static bool noLinkErrors()
Definition generator.h:85
static QmlTypeNode * qmlTypeContext()
Definition generator.h:91
static bool autolinkErrors()
Definition generator.h:86
Assembles IR Documents from pre-extracted metadata.
Definition builder.h:15
Document buildPageIR(PageMetadata pm) const
Definition builder.cpp:59
Singleton registry for discovering output producers by format.
void registerProducer(OutputProducer *producer)
Registers producer with this registry.
void unregisterProducer(OutputProducer *producer)
Unregisters producer from this registry.
static OutputProducerRegistry & instance()
Returns the singleton registry instance.
A PageNode is a Node that generates a documentation page.
Definition pagenode.h:19
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
NamespaceNode * primaryTreeRoot()
Returns a pointer to the root node of the primary tree.
void mergeCollections(CollectionNode *c)
Finds all the collection nodes with the same name and type as c and merges their members into the mem...
Generates documentation using external templates and a pre-built IR.
void generateProxyPage(Aggregate *aggregate, CodeMarker *marker) override
void endDocument() override
void beginDocument(const QString &fileName) override
void generateCppReferencePage(Aggregate *aggregate, CodeMarker *marker) override
void generatePageNode(PageNode *pn, CodeMarker *marker) override
void finalize() override
Finalizes output production.
void prepare() override
Prepares the producer for an output run.
QString fileExtension() const
TemplateGenerator(FileResolver &fileResolver, QDocDatabase &qdb, const QString &format=QString())
QString fileName(const Node *node) const override
void produce() override
Produces documentation output.
void generateCollectionNode(CollectionNode *cn, CodeMarker *marker) override
QString format() const override
Returns the format identifier for this producer (e.g., "HTML", "DocBook", "template").
void mergeCollections(CollectionNode *cn) override
void generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) override
void generateGenericCollectionPage(CollectionNode *cn, CodeMarker *marker) override
Definition builder.cpp:14
std::optional< IR::AllMembersIR > extractAllMembersIR(const PageNode *pn, const HrefResolver *hrefResolver)
IR::PageMetadata extractPageMetadata(const PageNode *pn, const HrefResolver *hrefResolver)
Combined button and popup list for selecting options.
Intermediate representation of the all-members listing page.
Definition member.h:112
Intermediate representation for a documentation topic.
Definition document.h:81
The Node class is the base class for all the nodes in QDoc's parse tree.
bool hasFileNameBase() const
Returns true if the node's file name base has been set.
Definition node.h:167
Genus genus() const override
Returns this node's Genus.
Definition node.h:85
virtual bool isPageNode() const
Returns true if this node represents something that generates a documentation page.
Definition node.h:148
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
Definition node.h:153
Aggregate * parent() const
Returns the node's parent pointer.
Definition node.h:208
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
Definition node.h:144
Bundles output configuration without static variables.
static QString nodeTypeKey(const Node *node)
static void resolveDocumentLinks(LinkResolver *resolver, IR::Document &ir, const Node *relative)