From f9cfb6f989b8e591a724e4c7644e6e6897d8e49a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 21 Jan 2022 08:19:50 +0530 Subject: [PATCH] use sphinx extlinks instead of custon roles --- docs/conf.py | 27 ++++++--------------------- docs/index.rst | 3 +-- docs/overview.rst | 3 +-- kitty/options/definition.py | 5 ++--- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3b3ff4507..d35af6ec1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,6 +59,7 @@ extensions = [ 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', + 'sphinx.ext.extlinks', 'sphinx_copybutton', 'sphinx_inline_tabs', "sphinxext.opengraph", @@ -167,24 +168,11 @@ texinfo_documents = [ # GitHub linking inline roles {{{ -def num_role( - which: str, name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = [] -) -> Tuple[List[nodes.reference], List[nodes.problematic]]: - ' Link to a github issue ' - try: - issue_num = int(text) - if issue_num <= 0: - raise ValueError - except ValueError: - msg = inliner.reporter.error( - 'GitHub issue number must be a number greater than or equal to 1; ' - '"%s" is invalid.' % text, line=lineno) - prb = inliner.problematic(rawtext, rawtext, msg) - return [prb], [msg] - url = f'https://github.com/kovidgoyal/kitty/{which}/{issue_num}' - set_classes(options) - node = nodes.reference(rawtext, f'#{issue_num}', refuri=url, **options) - return [node], [] +extlinks = { + 'iss': ('https://github.com/kovidgoyal/kitty/issues/%s', '#%s'), + 'pull': ('https://github.com/kovidgoyal/kitty/pull/%s', '#%s'), + 'disc': ('https://github.com/kovidgoyal/kitty/discussions/%s', '#%s'), +} def commit_role( @@ -517,9 +505,6 @@ def setup(app: Any) -> None: app.connect('html-page-context', add_html_context) app.add_lexer('session', SessionLexer() if version_info[0] < 3 else SessionLexer) app.add_role('link', link_role) - app.add_role('iss', partial(num_role, 'issues')) - app.add_role('pull', partial(num_role, 'pull')) - app.add_role('disc', partial(num_role, 'discussions')) app.add_role('commit', commit_role) # monkey patch sphinx_inline_tabs to avoid a warning about parallel reads # see https://github.com/pradyunsg/sphinx-inline-tabs/issues/26 diff --git a/docs/index.rst b/docs/index.rst index dc5ed894f..ce4046637 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,8 +20,7 @@ kitty .. tab:: Fast * Offloads rendering to the GPU for :doc:`lower system load ` - * Uses threaded rendering for - `absolutely minimal latency `_ + * Uses threaded rendering for :iss:`absolutely minimal latency <2701#issuecomment-636497270>` * Performance tradeoffs can be :ref:`tuned ` .. tab:: Capable diff --git a/docs/overview.rst b/docs/overview.rst index 013162bc8..7d620ce97 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -247,8 +247,7 @@ Would open the scrollback buffer in a new :term:`window` when you press the :kbd key. See :sc:`show_scrollback ` for details. If you want to use it with an editor such as vim to get more powerful features, -you can see tips for doing so, in -`this thread `_. +you can see tips for doing so, in :iss:`this thread <719>`. If you wish to store very large amounts of scrollback to view using the piping or :sc:`show_scrollback ` features, you can use the diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 1e85c2512..f98d4f1f5 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -987,9 +987,8 @@ The tab bar style, can be one of: A user-supplied Python function called draw_tab is loaded from the file :file:`tab_bar.py` in the kitty config directory. For examples of how to write such a function, see the functions named :code:`draw_tab_with_*` in - kitty's source code: :file:`kitty/tab_bar.py`. See also `this discussion - `_ for examples from - kitty users. + kitty's source code: :file:`kitty/tab_bar.py`. See also + :disc:`this discussion <4447>` for examples from kitty users. :code:`hidden` The tab bar is hidden. If you use this, you might want to create a mapping for the :ref:`action-select_tab`