From f646acdeb1e50cee05bedde26f63540956c0f8d3 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 30 Jul 2024 04:07:45 +0200 Subject: [PATCH] Update dependencies remove legacy code (#955) Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com> --- README.rst | 2 +- breathe/renderer/sphinxrenderer.py | 48 ++---------------------------- pyproject.toml | 8 ++--- tests/test_renderer.py | 30 +++++-------------- 4 files changed, 15 insertions(+), 73 deletions(-) diff --git a/README.rst b/README.rst index cbf010225..887daedc7 100644 --- a/README.rst +++ b/README.rst @@ -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 --------------------- diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index a87fe0f21..c2e4ffe95 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -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 @@ -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: @@ -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(), @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 1f21f7a56..d686bd5e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/tests/test_renderer.py b/tests/test_renderer.py index 0fd044a5c..b87699ac9 100644 --- a/tests/test_renderer.py +++ b/tests/test_renderer.py @@ -23,7 +23,6 @@ sphinx_test_tempdir, rootdir, ) -from sphinx.testing.path import path sphinx.locale.init([], "") @@ -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): @@ -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):