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