-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Use normalize_options()
from Docutils in preference to set_classes()
#13844
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
Open
bsipocz
wants to merge
3
commits into
sphinx-doc:master
Choose a base branch
from
bsipocz:MAINT_update_deprecated_docutils_usage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
"""Handlers for additional ReST roles.""" | ||
|
||
from __future__ import annotations | ||
|
||
import re | ||
from packaging.version import Version | ||
from typing import TYPE_CHECKING | ||
|
||
import docutils.parsers.rst.directives | ||
import docutils.parsers.rst.roles | ||
import docutils.parsers.rst.states | ||
from docutils import nodes, utils | ||
|
||
from sphinx import addnodes | ||
from sphinx.locale import _, __ | ||
from sphinx.util import ws_re | ||
from sphinx.util.docutils import ReferenceRole, SphinxRole | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Sequence | ||
|
@@ -584,10 +585,14 @@ | |
options: dict[str, Any] | None = None, | ||
content: Sequence[str] = (), | ||
) -> tuple[list[Node], list[system_message]]: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
if Version(docutils.__version__) < Version('0.22'): | ||
docutils.parsers.rst.roles.set_classes(options) | ||
else: | ||
docutils.parsers.rst.roles.normalize_options(options) | ||
language = options.get('language', '') | ||
classes = ['code'] | ||
if language: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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