From eed1085b3ad11a23ca975c17856763e8294983bc Mon Sep 17 00:00:00 2001 From: Latosha Maltba <79100569+latosha-maltba@users.noreply.github.com> Date: Thu, 30 Sep 2021 16:58:04 +0000 Subject: [PATCH] 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 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 56bb70001e6..6802ba2e79c 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::`` not recognising ``:classes:`` option instead of ``:class:`` option. The new behaviour is only to accept ``:class:``. Testing -------- diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 9a3034daea5..f2cb631f07e 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -154,7 +154,7 @@ def run(self) -> List[Node]: code = '\n'.join(self.content) node = nodes.literal_block(code, code, - classes=self.options.get('classes', []), + classes=self.options.get('class', []), force='force' in self.options, highlight_args={}) self.add_name(node)