mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-25 14:40:22 -05:00
Remove `section_parents` (#13560)
Docutils revision r10129 [1] removes the member from the namespace. [1]: https://sourceforge.net/p/docutils/code/10129/
This commit is contained in:
1 parent
75400aff91
commit
0eae573102
3 files changed
+1
-32
No files matched your search
@@ -5,7 +5,6 @@ from os.path import relpath
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, cast
|
||||
|
||||
import docutils
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.parsers.rst.directives.misc import Class
|
||||
@@ -22,7 +21,7 @@ from sphinx.util.nodes import explicit_title_re
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, ClassVar, Final
|
||||
from typing import Any, ClassVar
|
||||
|
||||
from docutils.nodes import Element, Node
|
||||
|
||||
@@ -30,7 +29,6 @@ if TYPE_CHECKING:
|
||||
from sphinx.util.typing import ExtensionMetadata, OptionSpec
|
||||
|
||||
|
||||
DU_22_PLUS: Final = docutils.__version_info__ >= (0, 22, 0, 'alpha', 0)
|
||||
glob_re = re.compile(r'.*[*?\[].*')
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -332,14 +330,6 @@ class Only(SphinxDirective):
|
||||
surrounding_section_level = memo.section_level
|
||||
memo.title_styles = []
|
||||
memo.section_level = 0
|
||||
if DU_22_PLUS:
|
||||
# https://github.com/sphinx-doc/sphinx/issues/13539
|
||||
# https://sourceforge.net/p/docutils/code/10093/
|
||||
# https://sourceforge.net/p/docutils/patches/213/
|
||||
surrounding_section_parents = memo.section_parents
|
||||
memo.section_parents = []
|
||||
else:
|
||||
surrounding_section_parents = []
|
||||
try:
|
||||
self.state.nested_parse(
|
||||
self.content, self.content_offset, node, match_titles=True
|
||||
@@ -375,8 +365,6 @@ class Only(SphinxDirective):
|
||||
return []
|
||||
finally:
|
||||
memo.title_styles = surrounding_title_styles
|
||||
if DU_22_PLUS:
|
||||
memo.section_parents = surrounding_section_parents
|
||||
memo.section_level = surrounding_section_level
|
||||
|
||||
|
||||
|
||||
@@ -5,19 +5,15 @@ from __future__ import annotations
|
||||
import contextlib
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import docutils
|
||||
from docutils.nodes import Element
|
||||
from docutils.statemachine import StringList, string2lines
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
from typing import Final
|
||||
|
||||
from docutils.nodes import Node
|
||||
from docutils.parsers.rst.states import RSTState
|
||||
|
||||
DU_22_PLUS: Final = docutils.__version_info__ >= (0, 22, 0, 'alpha', 0)
|
||||
|
||||
|
||||
def nested_parse_to_nodes(
|
||||
state: RSTState,
|
||||
@@ -79,23 +75,15 @@ def _fresh_title_style_context(state: RSTState) -> Iterator[None]:
|
||||
memo = state.memo
|
||||
surrounding_title_styles: list[str | tuple[str, str]] = memo.title_styles
|
||||
surrounding_section_level: int = memo.section_level
|
||||
if DU_22_PLUS:
|
||||
surrounding_section_parents = memo.section_parents
|
||||
else:
|
||||
surrounding_section_parents = []
|
||||
# clear current title styles
|
||||
memo.title_styles = []
|
||||
memo.section_level = 0
|
||||
if DU_22_PLUS:
|
||||
memo.section_parents = []
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
# reset title styles
|
||||
memo.title_styles = surrounding_title_styles
|
||||
memo.section_level = surrounding_section_level
|
||||
if DU_22_PLUS:
|
||||
memo.section_parents = surrounding_section_parents
|
||||
|
||||
|
||||
def _text_to_string_list(
|
||||
|
||||
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import docutils
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst.languages import en as english # type: ignore[attr-defined]
|
||||
from docutils.parsers.rst.states import (
|
||||
@@ -45,16 +44,10 @@ def make_directive_and_state(
|
||||
reporter=document.reporter,
|
||||
language=english,
|
||||
title_styles=[],
|
||||
# section_parents=[], # Docutils 0.22+
|
||||
section_level=0,
|
||||
section_bubble_up_kludge=False,
|
||||
inliner=inliner,
|
||||
)
|
||||
if docutils.__version_info__ >= (0, 22, 0, 'alpha', 0):
|
||||
# https://github.com/sphinx-doc/sphinx/issues/13539
|
||||
# https://sourceforge.net/p/docutils/code/10093/
|
||||
# https://sourceforge.net/p/docutils/patches/213/
|
||||
state.memo.section_parents = []
|
||||
directive = SphinxDirective(
|
||||
name='test_directive',
|
||||
arguments=[],
|
||||
|
||||
Reference in new issue
Block a user