diff options
| author | Corentin Noël <corentin.noel@collabora.com> | 2025-06-15 01:10:46 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-06-17 14:09:59 +0300 |
| commit | fd5c7dde8a5026b68d8069842aa2d65a9d5e2ceb (patch) | |
| tree | 1835953e1239e291440f551f1b92dfba86b78e06 /docs | |
| parent | 32978023ee995667ec7def4e857777bb61ffbefa (diff) | |
| download | meson-fd5c7dde8a5026b68d8069842aa2d65a9d5e2ceb.tar.gz | |
docs: Make RefMan create symbols for all the references
This makes all the symbols searchable from the .devhelp file.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/extensions/refman_links.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/extensions/refman_links.py b/docs/extensions/refman_links.py index 5c22a0a0b..865668b35 100644 --- a/docs/extensions/refman_links.py +++ b/docs/extensions/refman_links.py @@ -1,11 +1,13 @@ from pathlib import Path from json import loads +import os import re from hotdoc.core.exceptions import HotdocSourceException from hotdoc.core.extension import Extension from hotdoc.core.tree import Page from hotdoc.core.project import Project +from hotdoc.core.symbols import * from hotdoc.run_hotdoc import Application from hotdoc.core.formatter import Formatter from hotdoc.utils.loggable import Logger, warn, info @@ -52,6 +54,35 @@ class RefmanLinksExtension(Extension): with valid links to the correct URL. To reference objects / types use the [[@object]] syntax. ''' + for key, value in self._data.items(): + path = os.path.relpath(value, self.app.config.get_invoke_dir()).split('#')[0] + if path == page.link.ref: + if key.startswith('@'): + res = self.create_symbol( + ClassSymbol, + display_name=key[1:], + filename=path, + unique_name=key) + res.link = Link(value, res.display_name, res.unique_name) + elif '.' in key: + res = self.create_symbol( + MethodSymbol, + parameters=[], + display_name=key.split('.')[-1], + parent_name=f'@{key.split(".")[-2]}', + filename=path, + unique_name=key) + res.link = Link(value, key, res.unique_name) + else: + res = self.create_symbol( + FunctionSymbol, + parameters=[], + display_name=key, + filename=path, + unique_name=key) + res.link = Link(value, res.display_name, res.unique_name) + page.symbols.append(res) + link_regex = re.compile(r'(\[\[#?@?([ \n\t]*[a-zA-Z0-9_]+[ \n\t]*\.)*[ \n\t]*[a-zA-Z0-9_]+[ \n\t]*\]\])(.)?', re.MULTILINE) for m in link_regex.finditer(page.formatted_contents): i = m.group(1) @@ -103,6 +134,10 @@ class RefmanLinksExtension(Extension): ext.formatter.formatting_page_signal.connect(self._formatting_page_cb) info('Meson refman extension LOADED') + def create_symbol(self, *args, **kwargs): + kwargs['language'] = 'meson' + return super(RefmanLinksExtension, self).create_symbol(*args, **kwargs) + @staticmethod def get_dependencies() -> T.List[T.Type[Extension]]: return [] # In case this extension has dependencies on other extensions |
