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
hrefresolver.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_HREFRESOLVER_H
5#define QDOC_HREFRESOLVER_H
6
7#ifdef QDOC_TEMPLATE_GENERATOR_ENABLED
8
9#include "inclusionpolicy.h"
10
11#include <QtCore/qstring.h>
12
13#include <functional>
14#include <variant>
15
16QT_BEGIN_NAMESPACE
17
18class LocationPlan;
19class LocationPlanSet;
20class Node;
21class QmlTypeNode;
22struct OutputContext;
23
24enum class HrefSuppressReason {
25 NullNode,
26 NoFileBase,
27 ExcludedByPolicy,
28 InternalAbstractQml,
29 SameFileAnchor,
30 Unpublished,
31};
32
33using HrefResult = std::variant<QString, HrefSuppressReason>;
34
35struct HrefResolverConfig
36{
37 const OutputContext *context{nullptr};
38 const LocationPlan *plan{nullptr};
39 const LocationPlanSet *publications{nullptr};
40 QString format;
41 InclusionPolicy inclusionPolicy;
42 std::function<const QmlTypeNode *()> qmlTypeContextFn;
43};
44
45class HrefResolver
46{
47public:
48 explicit HrefResolver(const HrefResolverConfig &config);
49
50 [[nodiscard]] HrefResult hrefForNode(const Node *node, const Node *relative) const;
51 [[nodiscard]] QString anchorForNode(const Node *node) const;
52 [[nodiscard]] QString fileName(const Node *node) const;
53
54private:
55 [[nodiscard]] QString crossModulePrefix(const Node *target, const Node *source) const;
56
57 HrefResolverConfig m_config;
58};
59
60QT_END_NAMESPACE
61
62#endif // QDOC_TEMPLATE_GENERATOR_ENABLED
63
64#endif // QDOC_HREFRESOLVER_H