From 9c53175528ceb0268a18867522dc2425bf99912a Mon Sep 17 00:00:00 2001 From: Latosha Maltba <79100569+latosha-maltba@users.noreply.github.com> Date: Sun, 3 Oct 2021 21:18:17 +0000 Subject: [PATCH 1/2] Fix bug of Sphinx's .. code:: directive not recognizing :class: option Sphinx's own .. code:: directive (but not docutils') does not recognise the :class: option but only the :classes: option. This is probably due to an oversight that the user-visible option is called ``:class:`` while the Python attribute is called ``classes`` (to not collide with the keyword ``class``). Fix it by checking for the option ``class`` instead of ``classes``. --- CHANGES | 1 + sphinx/directives/patches.py | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 56bb70001e6..cc7c314dd4b 100644 --- a/CHANGES +++ b/CHANGES @@ -41,6 +41,7 @@ Bugs fixed * #9649: HTML search: when objects have the same name but in different domains, return all of them as result instead of just one. * #9678: linkcheck: file extension was shown twice in warnings +* Fix bug ``.. code::`` recognising ``:classes:`` option instead of ``:class:`` option. The new behaviour is to only accept the ``:class:`` option. Testing -------- diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 9a3034daea5..428ae0ba4ee 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -152,6 +152,7 @@ class Code(SphinxDirective): def run(self) -> List[Node]: self.assert_has_content() + set_classes(self.options) code = '\n'.join(self.content) node = nodes.literal_block(code, code, classes=self.options.get('classes', []), From bbccb4968065747c791e0d3e83d7770a69abab0b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Oct 2021 15:27:44 +0900 Subject: [PATCH 2/2] Fix #9688: ImportError for set_classes() --- sphinx/directives/patches.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 0a076ad4ff6..dd01cb34a81 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -15,6 +15,7 @@ from docutils.nodes import Node, make_id, system_message from docutils.parsers.rst import directives from docutils.parsers.rst.directives import images, tables +from docutils.parsers.rst.roles import set_classes from sphinx import addnodes from sphinx.deprecation import RemovedInSphinx60Warning