Skip to content

Commit

Permalink
Fix bug of Sphinx's .. code:: directive not recognizing :class: option
Browse files Browse the repository at this point in the history
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``.
  • Loading branch information
latosha-maltba committed Oct 3, 2021
1 parent 50dd03d commit 9c53175
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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
--------
Expand Down
1 change: 1 addition & 0 deletions sphinx/directives/patches.py
Expand Up @@ -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', []),
Expand Down

0 comments on commit 9c53175

Please sign in to comment.