Skip to content

Commit 4ad719a

Browse files
committed
Dependencies: Add compatibility with docutils 0.21
1 parent 33d5625 commit 4ad719a

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
## Unreleased
4+
- Dependencies: Added compatibility with docutils 0.21
45

56
## v0.4.0 - 2024-06-27
67
- Dependencies: Update to sphinx-design 0.6.0

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ dynamic = [
8282
]
8383
dependencies = [
8484
"beautifulsoup4",
85+
"docutils<0.22",
8586
"myst-parser",
8687
"sphinx<7.2",
8788
"sphinx-design==0.6.1",
@@ -93,7 +94,7 @@ optional-dependencies.develop = [
9394
"poethepoet<1",
9495
"pyproject-fmt<3",
9596
"ruff<0.15",
96-
"types-docutils==0.20.0.3",
97+
"types-docutils<0.22",
9798
"validate-pyproject<1",
9899
]
99100
optional-dependencies.docs = [

sphinx_design_elements/gridtable.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ def run(self) -> List[nodes.Node]:
104104
self.state.nested_parse(self.content, self.content_offset, grid_row)
105105

106106
# Apply widths.
107-
widths = self.state_machine.document.attributes.get("widths")
107+
widths = t.cast("t.Iterable[str]", self.state_machine.document.attributes.get("widths"))
108108
for column, width in zip(grid_row.children, widths):
109-
column.update_basic_atts({"classes": item_columns_option(width)})
109+
element = t.cast("nodes.Element", column)
110+
element.update_basic_atts({"classes": item_columns_option(width)})
110111

111112
return [grid_row]
112113

sphinx_design_elements/hyper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ def __call__(
141141

142142
else:
143143
error = ValueError("Unable to resolve reference")
144-
msg = inliner.reporter.warning(error) # type: ignore[union-attr]
145-
prb = inliner.problematic(rawtext, rawtext, msg) # type: ignore[union-attr]
144+
msg = inliner.reporter.warning(error)
145+
prb = inliner.problematic(rawtext, rawtext, msg)
146146
return [prb], [msg]
147147

148148
return SphinxRole.__call__(self, name, rawtext, text, lineno, inliner, options, content) # type: ignore[arg-type]
@@ -158,7 +158,7 @@ def resolve_page_title(self) -> str:
158158
except Exception:
159159
return self.target
160160
elif self.srh.is_traditional_intersphinx_reference():
161-
document = self.inliner.document # type: ignore[attr-defined]
161+
document = self.inliner.document
162162
ref = resolve_reference(env=self.app.env, document=document, target=self.target)
163163
elif self.srh.is_myst_reference():
164164
link = f"[]({self.target})"
@@ -308,7 +308,7 @@ def render_snippet(self, snippet: str) -> Tuple[List[nodes.Node], List[nodes.sys
308308
Render a MyST snippet.
309309
"""
310310
directive_nodes, _ = self.inliner.parse_block( # type: ignore[attr-defined]
311-
text=snippet, lineno=self.lineno, memo=self, parent=self.inliner.parent, with_container=self.with_container # type: ignore[attr-defined]
311+
text=snippet, lineno=self.lineno, memo=self, parent=self.inliner.parent, with_container=self.with_container
312312
)
313313
if not directive_nodes:
314314
return [], self.system_messages

sphinx_design_elements/infocard.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, List, Tuple
1+
from typing import List, Tuple, cast
22

33
from docutils import nodes
44
from docutils.statemachine import StringList
@@ -49,7 +49,7 @@ def create_grid(self) -> Tuple[nodes.container, nodes.container]:
4949
grid_container += grid_row
5050
return grid_container, grid_row
5151

52-
def create_card(self) -> Tuple[nodes.container, nodes.container]:
52+
def create_card(self) -> Tuple[nodes.Element, nodes.Element]:
5353
"""
5454
Create a sphinx-design "card" component.
5555
@@ -74,7 +74,7 @@ def create_card(self) -> Tuple[nodes.container, nodes.container]:
7474

7575
card_body = card_node.children[0]
7676
self.set_source_info(card_body)
77-
return card_node, card_body
77+
return cast("nodes.Element", card_node), cast("nodes.Element", card_body)
7878

7979

8080
class InfoCardDirective(GridBuilderDirective):
@@ -89,7 +89,6 @@ class InfoCardDirective(GridBuilderDirective):
8989
has_content = True
9090
required_arguments = 0
9191
optional_arguments = 1
92-
option_spec: Dict[str, str] = {}
9392

9493
def run(self) -> List[nodes.Node]:
9594
# Create a canvas grid.

sphinx_design_elements/shield.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from docutils import nodes
44
from docutils.parsers.rst import directives
5+
from docutils.statemachine import StringList
56
from myst_parser.mocking import MockState
67
from sphinx.application import Sphinx
78
from sphinx.util.docutils import SphinxDirective
@@ -62,7 +63,7 @@ def run(self):
6263
logo = self.options.get("logo")
6364
logo_color = self.options.get("logo-color")
6465
link = self.options.get("link")
65-
link_title = self.options.get("link-title") or message # TODO: Optionally add label?
66+
link_title = self.options.get("link-title") or str(message) # TODO: Optionally add label?
6667
link_alt = self.options.get("link-alt") or link_title
6768

6869
# Sanity checks.
@@ -106,7 +107,7 @@ def parse_nested(self, content: str):
106107
When using MyST, parse reference within the same parsing context.
107108
"""
108109
node_ = nodes.Element()
109-
self.state.nested_parse(content.splitlines(), self.content_offset, node_)
110+
self.state.nested_parse(StringList(content.splitlines()), self.content_offset, node_)
110111
return node_.children
111112

112113

sphinx_design_elements/tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run(self) -> t.Tuple[t.List[nodes.Node], t.List[nodes.system_message]]:
4949
"""
5050
Run the role, rendering multiple "badge" nodes.
5151
"""
52-
elements = []
52+
elements: t.List[nodes.Node] = []
5353

5454
# Enumerate multiple items.
5555
for text in self.decode_input_text():
@@ -69,5 +69,4 @@ def run(self) -> t.Tuple[t.List[nodes.Node], t.List[nodes.system_message]]:
6969
# Remove last spacer again.
7070
if elements:
7171
elements.remove(elements[-1])
72-
7372
return elements, []

sphinx_design_elements/util/role.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def parse_block_myst(
102102
ref = container.next_node()
103103
else:
104104
ref = container.next_node().next_node()
105-
return [ref], []
105+
if ref:
106+
return [ref], []
107+
else:
108+
return [], []
106109

107110

108111
def parse_block_rst( # pragma: nocover

0 commit comments

Comments
 (0)