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;
21
22enum class HrefSuppressReason {
23 NullNode,
24 NoFileBase,
25 ExcludedByPolicy,
26 InternalAbstractQml,
27 SameFileAnchor,
28};
29
30using HrefResult = std::variant<QString, HrefSuppressReason>;
31
32struct HrefResolverConfig
33{
34 QString project;
35 QString fileExtension;
36 bool useOutputSubdirs{false};
37 bool noLinkErrors{false};
38 InclusionPolicy inclusionPolicy;
39 std::function<QString(const Node *)> outputPrefixFn;
40 std::function<QString(const Node *)> outputSuffixFn;
41 std::function<QString(const QString &)> cleanRefFn;
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 fileBase(const Node *node) const;
56
57 HrefResolverConfig m_config;
58 mutable QHash<const Node *, QString> m_fileBaseCache;
59};
60
61QT_END_NAMESPACE
62
63#endif // QDOC_TEMPLATE_GENERATOR_ENABLED
64
65#endif // QDOC_HREFRESOLVER_H