Branch data Line data Source code
1 : : /* Automatic generation of links into GCC's documentation.
2 : : Copyright (C) 2023-2025 Free Software Foundation, Inc.
3 : : Contributed by David Malcolm <dmalcolm@redhat.com>.
4 : :
5 : : This file is part of GCC.
6 : :
7 : : GCC is free software; you can redistribute it and/or modify it
8 : : under the terms of the GNU General Public License as published by
9 : : the Free Software Foundation; either version 3, or (at your option)
10 : : any later version.
11 : :
12 : : GCC is distributed in the hope that it will be useful, but
13 : : WITHOUT ANY WARRANTY; without even the implied warranty of
14 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 : : General Public License for more details.
16 : :
17 : : You should have received a copy of the GNU General Public License
18 : : along with GCC; see the file COPYING3. If not see
19 : : <http://www.gnu.org/licenses/>. */
20 : :
21 : : #ifndef GCC_GCC_URLIFIER_H
22 : : #define GCC_GCC_URLIFIER_H
23 : :
24 : : #include "pretty-print-urlifier.h"
25 : : #include "label-text.h"
26 : :
27 : : extern std::unique_ptr<urlifier> make_gcc_urlifier (unsigned int lang_mask);
28 : : extern char *make_doc_url (const char *doc_url_suffix);
29 : :
30 : : /* RAII class to temporarily override global_dc's urlifier
31 : : with another one (possibly nullptr). */
32 : :
33 : : class auto_override_urlifier
34 : : {
35 : : public:
36 : : auto_override_urlifier (const urlifier &new_urlifier);
37 : : ~auto_override_urlifier ();
38 : : };
39 : :
40 : : /* Subclass of urlifier that attempts to add URLs to quoted strings
41 : : containing names of attributes. */
42 : :
43 : 1885787295 : class attribute_urlifier : public urlifier
44 : : {
45 : : public:
46 : : attribute_urlifier ();
47 : : attribute_urlifier (const char *target_docs_name);
48 : :
49 : : char *
50 : : get_url_for_quoted_text (const char *p, size_t sz) const final override;
51 : :
52 : : label_text
53 : : get_url_suffix_for_quoted_text (const char *p, size_t sz) const;
54 : :
55 : : /* We use ATTRIBUTE_UNUSED as this helper is called only from ASSERTs. */
56 : : label_text
57 : : get_url_suffix_for_quoted_text (const char *p) const ATTRIBUTE_UNUSED;
58 : :
59 : : private:
60 : : const char *m_target_docs_name;
61 : : };
62 : :
63 : : /* RAII class: during the lifetime of instances, global_dc will attempt
64 : : to auto-generate documentation links for any attributes mentioned in
65 : : quotes in diagnostics . */
66 : :
67 : 1885787291 : class auto_urlify_attributes
68 : : {
69 : : public:
70 : 1885787292 : auto_urlify_attributes ()
71 : 1885787292 : : m_override (m_urlifier)
72 : : {
73 : 1885787292 : }
74 : :
75 : : private:
76 : : attribute_urlifier m_urlifier;
77 : : auto_override_urlifier m_override;
78 : : };
79 : :
80 : : #endif /* GCC_GCC_URLIFIER_H */
|