Skip to content
Closed
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
5 changes: 4 additions & 1 deletion sphinx_design/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ class DropdownHtmlTransform(SphinxPostTransform):

def run(self):
"""Run the transform"""
for node in self.document.traverse(lambda node: is_component(node, "dropdown")):
# Can just use "findall" once docutils 0.18.1+ is required
for node in getattr(self.document, "findall", self.document.traverse)(
lambda node: is_component(node, "dropdown")
):
Comment on lines +145 to +148
Copy link

Choose a reason for hiding this comment

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

Suggested change
# Can just use "findall" once docutils 0.18.1+ is required
for node in getattr(self.document, "findall", self.document.traverse)(
lambda node: is_component(node, "dropdown")
):
# use this instead once docutils>=0.18.1 is min supported version:
# _dropdowns = list(self.document.findall(lambda node: is_component(node, "dropdown")))
_meth = getattr(self.document, "findall", self.document.traverse)
_dropdowns = list(_meth(lambda node: is_component(node, "dropdown")))
for node in _dropdowns:


# TODO option to not have card css (but requires more formatting)
use_card = True
Expand Down
4 changes: 3 additions & 1 deletion sphinx_design/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ def get_unique_key(self):

def run(self) -> None:
"""Run the transform."""
for tab_set in self.document.traverse(
# Can just use "findall" once docutils 0.18.1+ is required
meth = "findall" if hasattr(self.document, "findall") else "traverse"
for tab_set in getattr(self.document, meth)(
lambda node: is_component(node, "tab-set")
):
Comment on lines +216 to 220
Copy link

Choose a reason for hiding this comment

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

Suggested change
# Can just use "findall" once docutils 0.18.1+ is required
meth = "findall" if hasattr(self.document, "findall") else "traverse"
for tab_set in getattr(self.document, meth)(
lambda node: is_component(node, "tab-set")
):
# use this instead once docutils>=0.18.1 is min supported version:
# _tab_sets = list(self.document.findall(lambda node: is_component(node, "tab-set")))
_meth = getattr(self.document, "findall", self.document.traverse)
_tab_sets = list(_meth(lambda node: is_component(node, "tab-set")))
for tab_set in _tab_sets:

tab_set_identity = self.get_unique_key()
Expand Down