Skip to content

Commit

Permalink
Merge pull request #9688 from latosha-maltba/class-option-for-code-di…
Browse files Browse the repository at this point in the history
…rective

Fix bug of Sphinx's .. code:: directive not recognizing :class: option
  • Loading branch information
tk0miya committed Oct 9, 2021
2 parents c09f28e + d412acd commit 15df183
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -64,6 +64,8 @@ Bugs fixed
* #9697: py domain: An index entry with parens was registered for ``py:method``
directive with ``:property:`` option
* #9708: needs_extension failed to check double-digit version correctly
* Fix bug ``.. code::`` recognising ``:classes:`` option instead of ``:class:``
option. The new behaviour is to only accept the ``:class:`` option.

Testing
--------
Expand Down
2 changes: 2 additions & 0 deletions sphinx/directives/patches.py
Expand Up @@ -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
Expand Down Expand Up @@ -161,6 +162,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 15df183

Please sign in to comment.