From b079543405498630648fae40337b2b5a81ceed78 Mon Sep 17 00:00:00 2001 From: Walter Doerwald Date: Sun, 16 May 2021 12:13:17 +0200 Subject: [PATCH] Add configuration option html_signaturereturn_icon for the arrow before a return type hint. --- doc/usage/configuration.rst | 5 +++++ sphinx/builders/html/__init__.py | 1 + sphinx/writers/html.py | 4 +++- sphinx/writers/html5.py | 4 +++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 0b2bd4e3eab..9993e5078d2 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1191,6 +1191,11 @@ that use Sphinx's HTMLWriter class. .. versionadded:: 3.5 +.. confval:: html_signaturereturn_icon + + A text for prepended to the type hint for the return type of a function or + method. HTML tags are allowed. Default: an wrrow; ``→`` + .. confval:: html_sidebars Custom sidebar templates, must be a dictionary that maps document names to diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 85669474eab..34103ad98e3 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1320,6 +1320,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_config_value('html_add_permalinks', UNSET, 'html') app.add_config_value('html_permalinks', True, 'html') app.add_config_value('html_permalinks_icon', 'ΒΆ', 'html') + app.add_config_value('html_signaturereturn_icon', '→', 'html') app.add_config_value('html_use_index', True, 'html') app.add_config_value('html_split_index', False, 'html') app.add_config_value('html_copy_source', True, 'html') diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index e670c402bda..9fd9fe71526 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -174,7 +174,9 @@ def depart_desc_type(self, node: Element) -> None: pass def visit_desc_returns(self, node: Element) -> None: - self.body.append(' ') + self.body.append(' ') + self.body.append(self.config.html_signaturereturn_icon) + self.body.append(' ') def depart_desc_returns(self, node: Element) -> None: self.body.append('') diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py index 5db75764236..1df9bb46698 100644 --- a/sphinx/writers/html5.py +++ b/sphinx/writers/html5.py @@ -145,7 +145,9 @@ def depart_desc_type(self, node: Element) -> None: pass def visit_desc_returns(self, node: Element) -> None: - self.body.append(' ') + self.body.append(' ') + self.body.append(self.config.html_signaturereturn_icon) + self.body.append(' ') def depart_desc_returns(self, node: Element) -> None: self.body.append('')