Skip to content

Commit

Permalink
Update dependencies remove legacy code (#955)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
  • Loading branch information
Rotzbua and AA-Turner authored Jul 30, 2024
1 parent 571240c commit f646acd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ branch.
Requirements
------------

Breathe requires Python 3.8+, Sphinx 5.0+ and Doxygen 1.8+.
Breathe requires Python 3.8+, Sphinx 5.0+ and Doxygen 1.9+.

Mailing List Archives
---------------------
Expand Down
48 changes: 2 additions & 46 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,6 @@ def content(contentnode):
n = declarator[0]
newStyle = True
# the new style was introduced in Sphinx v4
if sphinx.version_info[0] < 4:
newStyle = False
# but only for the C and C++ domains
if self.get_domain() and self.get_domain() not in ("c", "cpp"):
newStyle = False
Expand Down Expand Up @@ -909,47 +907,6 @@ def pullup(node, typ, dest):
fieldList.extend(fl)
fieldLists = [fieldList]

# collapse retvals into a single return field
if len(fieldLists) != 0 and sphinx.version_info[0:2] < (4, 3):
others: List[nodes.field] = []
retvals: List[nodes.field] = []
f: nodes.field
fn: nodes.field_name
fb: nodes.field_body
for f in fieldLists[0]:
fn, fb = f
assert len(fn) == 1
if fn.astext().startswith("returns "):
retvals.append(f)
else:
others.append(f)
if len(retvals) != 0:
items: List[nodes.paragraph] = []
for fn, fb in retvals:
# we created the retvals before, so we made this prefix
assert fn.astext().startswith("returns ")
val = nodes.strong("", fn.astext()[8:])
# assumption from visit_docparamlist: fb is a single paragraph or nothing
assert len(fb) <= 1, fb
bodyNodes = [val, nodes.Text(" -- ")]
if len(fb) == 1:
assert isinstance(fb[0], nodes.paragraph)
bodyNodes.extend(fb[0])
items.append(nodes.paragraph("", "", *bodyNodes))
# only make a bullet list if there are multiple retvals
body: Node
if len(items) == 1:
body = items[0]
else:
body = nodes.bullet_list()
for i in items:
body.append(nodes.list_item("", i))
fRetvals = nodes.field(
"", nodes.field_name("", "returns"), nodes.field_body("", body)
)
fl = nodes.field_list("", *others, fRetvals)
fieldLists = [fl]

if self.app.config.breathe_order_parameters_first:
return detailed + fieldLists + admonitions
else:
Expand Down Expand Up @@ -2248,7 +2205,7 @@ def visit_templateparam(
dom = "cpp"
appendDeclName = True
if insertDeclNameByParsing:
if dom == "cpp" and sphinx.version_info >= (4, 1, 0):
if dom == "cpp":
parser = cpp.DefinitionParser(
"".join(n.astext() for n in nodelist),
location=self.state.state_machine.get_source_and_line(),
Expand Down Expand Up @@ -2313,8 +2270,7 @@ def visit_docparamlist(self, node) -> List[Node]:
"param": "param",
"exception": "throws",
"templateparam": "tparam",
# retval support available on Sphinx >= 4.3
"retval": "returns" if sphinx.version_info[0:2] < (4, 3) else "retval",
"retval": "retval",
}

# https://docutils.sourceforge.io/docs/ref/doctree.html#field-list
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ classifiers = [
]
dependencies = [
"Sphinx>=5.0.2",
"docutils>=0.12",
"Jinja2>=2.7.3",
"MarkupSafe>=0.23",
"Pygments>=1.6",
"docutils>=0.16",
"Jinja2>=2.10",
"MarkupSafe>=2.0",
"Pygments>=2.0",
]
dynamic = ["version"]

Expand Down
30 changes: 8 additions & 22 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
sphinx_test_tempdir,
rootdir,
)
from sphinx.testing.path import path

sphinx.locale.init([], "")

Expand Down Expand Up @@ -330,21 +329,15 @@ def test_render_func(app):
)
signature = find_node(render(app, member_def), "desc_signature")
assert signature.astext().startswith("void")
if sphinx.version_info[0] < 4:
assert find_node(signature, "desc_name")[0] == "foo"
else:
n = find_node(signature, "desc_name")[0]
assert isinstance(n, sphinx.addnodes.desc_sig_name)
assert len(n) == 1
assert n[0] == "foo"
n = find_node(signature, "desc_name")[0]
assert isinstance(n, sphinx.addnodes.desc_sig_name)
assert len(n) == 1
assert n[0] == "foo"
params = find_node(signature, "desc_parameterlist")
assert len(params) == 1
param = params[0]
if sphinx.version_info[0] < 4:
assert param[0] == "int"
else:
assert isinstance(param[0], sphinx.addnodes.desc_sig_keyword_type)
assert param[0][0] == "int"
assert isinstance(param[0], sphinx.addnodes.desc_sig_keyword_type)
assert param[0][0] == "int"


def test_render_typedef(app):
Expand Down Expand Up @@ -373,15 +366,8 @@ def test_render_c_function_typedef(app):
)
signature = find_node(render(app, member_def, domain="c"), "desc_signature")
assert signature.astext().startswith("typedef void *")
if sphinx.version_info[0] < 4:
params = find_node(signature, "desc_parameterlist")
assert len(params) == 2
assert params[0].astext() == "float"
assert params[1].astext() == "int"
else:
# the use of desc_parameterlist in this case was not correct,
# it should only be used for a top-level function
pass
# the use of desc_parameterlist in this case was not correct,
# it should only be used for a top-level function


def test_render_using_alias(app):
Expand Down

0 comments on commit f646acd

Please sign in to comment.