From 1856ee638b08e39b568f9e983696d4302b48066d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 22 May 2022 16:02:43 +0900 Subject: [PATCH 1/3] Close #10461: doc: Add an explanation for :class: option of code-block directive --- doc/usage/restructuredtext/directives.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/usage/restructuredtext/directives.rst b/doc/usage/restructuredtext/directives.rst index 847f0372b87..4029b04e67b 100644 --- a/doc/usage/restructuredtext/directives.rst +++ b/doc/usage/restructuredtext/directives.rst @@ -592,6 +592,13 @@ __ https://pygments.org/docs/lexers .. versionadded:: 1.3 + .. rst:directive:option:: class: class names + :type: a list of class names separated by spaces + + The class name of the graph. + + .. versionadded:: 1.4 + .. rst:directive:option:: dedent: number :type: number or no value @@ -758,6 +765,9 @@ __ https://pygments.org/docs/lexers Added the ``diff``, ``lineno-match``, ``caption``, ``name``, and ``dedent`` options. + .. versionchanged:: 1.4 + Added the ``class`` option. + .. versionchanged:: 1.5 Added the ``start-at``, and ``end-at`` options. From 51c84e041f8e581eb04a041fb410341d152deafb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 23 May 2022 00:37:45 +0900 Subject: [PATCH 2/3] Fix #10104: gettext: Duplicated locations are output to pot file When 3rd party extension does not provide line number for each message, duplicated locations are output to pot file unexpectedly. This filters duplicated locations before generationg pot file. --- CHANGES | 2 ++ sphinx/builders/gettext.py | 3 ++- tests/test_build_gettext.py | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index ed47709e539..69e6fdd097a 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ Bugs fixed * #9648: autodoc: ``*args`` and ``**kwargs`` entries are duplicated when ``autodoc_typehints="description"`` * #10443: epub: EPUB builder can't detect the mimetype of .webp file +* #10104: gettext: Duplicated locations are shown if 3rd party extension does + not provide correct information * #10456: py domain: ``:meta:`` fields are displayed if docstring contains two or more meta-field * #9096: sphinx-build: the value of progress bar for paralle build is wrong diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index e8bc547b77f..0d7d0ac11d8 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -57,7 +57,8 @@ def add(self, msg: str, origin: Union[Element, "MsgOrigin"]) -> None: def __iter__(self) -> Generator[Message, None, None]: for message in self.messages: - positions = [(source, line) for source, line, uuid in self.metadata[message]] + positions = sorted(set((source, line) for source, line, uuid + in self.metadata[message])) uuids = [uuid for source, line, uuid in self.metadata[message]] yield Message(message, positions, uuids) diff --git a/tests/test_build_gettext.py b/tests/test_build_gettext.py index 3c4617e849c..cca6fab929b 100644 --- a/tests/test_build_gettext.py +++ b/tests/test_build_gettext.py @@ -8,9 +8,29 @@ import pytest +from sphinx.builders.gettext import Catalog, MsgOrigin from sphinx.util.osutil import cd +def test_Catalog_duplicated_message(): + catalog = Catalog() + catalog.add('hello', MsgOrigin('/path/to/filename', 1)) + catalog.add('hello', MsgOrigin('/path/to/filename', 1)) + catalog.add('hello', MsgOrigin('/path/to/filename', 2)) + catalog.add('hello', MsgOrigin('/path/to/yetanother', 1)) + catalog.add('world', MsgOrigin('/path/to/filename', 1)) + + assert len(list(catalog)) == 2 + + msg1, msg2 = list(catalog) + assert msg1.text == 'hello' + assert msg1.locations == [('/path/to/filename', 1), + ('/path/to/filename', 2), + ('/path/to/yetanother', 1)] + assert msg2.text == 'world' + assert msg2.locations == [('/path/to/filename', 1)] + + @pytest.mark.sphinx('gettext', srcdir='root-gettext') def test_build_gettext(app): # Generic build; should fail only when the builder is horribly broken. From 721bc00d2bd0a7956d4014459cb9a859ebdee24f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 28 May 2022 23:04:55 +0900 Subject: [PATCH 3/3] Update URL for requests --- EXAMPLES | 2 +- doc/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EXAMPLES b/EXAMPLES index 2df57de7418..72613e9baf0 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -36,7 +36,7 @@ Documentation using the alabaster theme * `pytest `__ (customized) * `python-apt `__ * `PyVisfile `__ -* `Requests `__ +* `Requests `__ * `searx `__ * `Spyder `__ (customized) * `Tablib `__ diff --git a/doc/conf.py b/doc/conf.py index a5563ad932c..281ca260500 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -108,7 +108,7 @@ intersphinx_mapping = { 'python': ('https://docs.python.org/3/', None), - 'requests': ('https://docs.python-requests.org/en/latest/', None), + 'requests': ('https://requests.readthedocs.io/en/latest/', None), 'readthedocs': ('https://docs.readthedocs.io/en/stable', None), }