Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sphinx/directives/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives import images, tables
from docutils.parsers.rst.directives.misc import Meta
from docutils.parsers.rst.roles import set_classes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the old name for old versions of Docutils, which we still support

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I suspected that this needs to be version dependent. I'll add a checker, though first will need to sort out what goes wrong for the latest docutils where it should work

from docutils.parsers.rst.roles import normalize_options

from sphinx.directives import optional_int
from sphinx.locale import __
Expand Down Expand Up @@ -100,7 +100,7 @@ class Code(SphinxDirective):
def run(self) -> list[Node]:
self.assert_has_content()

set_classes(self.options)
normalize_options(self.options)
code = '\n'.join(self.content)
node = nodes.literal_block(
code,
Expand Down Expand Up @@ -215,7 +215,7 @@ class Rubric(SphinxDirective):
}

def run(self) -> list[nodes.rubric | nodes.system_message]:
set_classes(self.options)
normalize_options(self.options)
rubric_text = self.arguments[0]
textnodes, messages = self.parse_inline(rubric_text, lineno=self.lineno)
if 'heading-level' in self.options:
Expand Down
3 changes: 2 additions & 1 deletion sphinx/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,11 @@ def code_role(
options: dict[str, Any] | None = None,
content: Sequence[str] = (),
) -> tuple[list[Node], list[system_message]]:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, and this annoys Ruff, though I explicitly added the line as it was very difficult to see where the signature ends and the actual code starts.

if options is None:
options = {}
options = options.copy()
docutils.parsers.rst.roles.set_classes(options)
docutils.parsers.rst.roles.normalize_options(options)
language = options.get('language', '')
classes = ['code']
if language:
Expand Down
Loading