Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 0 additions & 17 deletions sphinx/util/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ def apply_source_workaround(node: Element) -> None:
elif isinstance(node, nodes.classifier) and not node.source:
# docutils-0.15 fills in rawsource attribute, but not in source.
node.source = node.parent.source
if isinstance(node, nodes.image) and node.source is None:
logger.debug(
'[i18n] PATCH: %r to have source, line: %s',
get_full_module_name(node),
repr_domxml(node),
)
node.source, node.line = node.parent.source, node.parent.line
if isinstance(node, nodes.title) and node.source is None:
logger.debug(
'[i18n] PATCH: %r to have source: %s',
Expand Down Expand Up @@ -177,12 +170,6 @@ def apply_source_workaround(node: Element) -> None:
)
node.source, node.line = node.parent.source, node.parent.line

# workaround: literal_block under bullet list
# See: https://github.com/sphinx-doc/sphinx/issues/4913
if isinstance(node, nodes.literal_block) and node.source is None:
with contextlib.suppress(ValueError):
node.source = get_node_source(node)

# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
if not node.rawsource:
node.rawsource = node.astext()
Expand All @@ -194,12 +181,8 @@ def apply_source_workaround(node: Element) -> None:
if isinstance(
node,
(
# https://github.com/sphinx-doc/sphinx/issues/1305 rubric directive
nodes.rubric,
# https://github.com/sphinx-doc/sphinx/issues/1477 line node
nodes.line,
# https://github.com/sphinx-doc/sphinx/issues/3093 image directive in substitution
nodes.image,
# https://github.com/sphinx-doc/sphinx/issues/3335 field list syntax
nodes.field_name,
),
Expand Down
21 changes: 0 additions & 21 deletions tests/test_util/test_util_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from sphinx.transforms import ApplySourceWorkaround
from sphinx.util.nodes import (
NodeMatcher,
apply_source_workaround,
clean_astext,
extract_messages,
make_id,
Expand Down Expand Up @@ -253,23 +252,3 @@ def test_make_id_sequential(app):
)
def test_split_explicit_target(title: str, expected: tuple[bool, str, str]) -> None:
assert split_explicit_title(title) == expected


def test_apply_source_workaround_literal_block_no_source() -> None:
"""Regression test for https://github.com/sphinx-doc/sphinx/issues/11091.

Test that apply_source_workaround doesn't raise.
"""
literal_block = nodes.literal_block('', '')
list_item = nodes.list_item('', literal_block)
bullet_list = nodes.bullet_list('', list_item)

assert literal_block.source is None
assert list_item.source is None
assert bullet_list.source is None

apply_source_workaround(literal_block)

assert literal_block.source is None
assert list_item.source is None
assert bullet_list.source is None
Loading