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. Autolinks to deprecated nodes from non-deprecated
40 content are suppressed; explicit \\l and \\sa links keep the author's
41 reference, matching legacy HTML. Suppressed links carry a diagnostic
42 linkState string identifying the reason (policy exclusion,
43 self-reference, etc.).
44 Unresolvable links emit warnings controlled by the injected
45 LinkResolverConfig.
46
47 \sa HrefResolver, IR::ContentBuilder
48*/
49class LinkResolver
50{
51public:
52 /*!
53 Context for a resolve() pass.
54
55 \c semantic is the node whose documentation the content was
56 authored in; \c page is the output page node that renders the
57 content. See resolve() for the role each plays.
58 */
59 struct Context
60 {
61 const Node *semantic { nullptr };
62 const Node *page { nullptr };
63 };
64
65 LinkResolver(QDocDatabase *qdb, const HrefResolver &hrefResolver,
66 const LinkResolverConfig &config);
67
68 void resolve(QList<IR::ContentBlock> &blocks, Context context);
69
70private:
71 void resolveBlock(IR::ContentBlock &block, const Context &context);
72 void resolveInlines(QList<IR::InlineContent> &inlines, const Context &context);
73 void resolveLink(IR::InlineContent &link, const Context &context);
74
75 QDocDatabase *m_qdb;
76 const HrefResolver &m_hrefResolver;
77 LinkResolverConfig m_config;
78};
79
80QT_END_NAMESPACE
81
82#endif // QDOC_TEMPLATE_GENERATOR_ENABLED
83
84#endif // QDOC_LINKRESOLVER_H
A class for holding the members of a collection of doc pages.
contains all the information for a single config variable in a .qdocconf file.
Definition config.h:43
The Config class contains the configuration variables for controlling how qdoc produces documentation...
Definition config.h:95
InclusionPolicy createInclusionPolicy() const
Definition config.cpp:1678
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:87
static QmlTypeNode * qmlTypeContext()
Definition generator.h:93
static bool autolinkErrors()
Definition generator.h:88
Assembles IR Documents from pre-extracted metadata.
Definition builder.h:15
Document buildPageIR(PageMetadata pm) const
Definition builder.cpp:196
\variable PublicationLocation::path
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.
Interface for documentation output producers.
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...
A class for creating vectors of collections for documentation.
Definition sections.h:80
Sections(const Aggregate *aggregate)
This constructor builds the section vectors based on the type of the aggregate node.
Definition sections.cpp:372
bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const
Returns true if any sections in this object contain obsolete members.
Definition sections.cpp:967
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
std::function< void(const QString &message)> RenderFailureHandler
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
void planLocations(const LocationPlanSet &publications)
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
TemplateGenerator(FileResolver &fileResolver, QDocDatabase &qdb, const QString &format, RenderFailureHandler reportFailure)
Constructs a producer for format using fileResolver and qdb.
void generateGenericCollectionPage(CollectionNode *cn, CodeMarker *marker) override
Definition builder.cpp:14
std::optional< IR::AllMembersIR > extractAllMembersIR(const PageNode *pn, const HrefResolver *hrefResolver)
Combined button and popup list for selecting options.
QList< const Section * > SectionPtrVector
Definition sections.h:77
Intermediate representation of the all-members listing page.
Definition member.h:146
Intermediate representation for a documentation topic.
Definition document.h:201
The Node class is the base class for all the nodes in QDoc's parse tree.
Bundles output configuration without static variables.
static void processDocumentBlocks(IR::ListExpander *expander, LinkResolver *resolver, IR::Document &ir, const Node *page, const NodeExtractor::SemanticOrigins *origins=nullptr)
static void writeOrDiscardRenderResult(FileDocumentWriter *writer, const InjaBridge::RenderContext &context, const InjaBridge::RenderResult &result, const TemplateGenerator::RenderFailureHandler &reportFailure)
static std::optional< LoadedTemplate > loadTemplate(const QString &templateDir, const QString &name)