Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug of Sphinx's .. code:: directive not recognizing :class: option #9688

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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