Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes "double friend" issue #918

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
21 changes: 10 additions & 11 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1975,27 +1975,26 @@ def visit_function(self, node) -> List[Node]:
)
else:
elements = [self.create_template_prefix(node)]
# TODO: handle constexpr when parser has been updated
# but Doxygen seems to leave it in the type anyway
typ = "".join(n.astext() for n in self.render(node.get_type()))
# Doxygen sometimes leaves 'static' in the type,
# e.g., for "constexpr static auto f()"
typ = typ.replace("static ", "")
if node.static == "yes":
elements.append("static")
if node.inline == "yes":
elements.append("inline")
if node.kind == "friend":
# In Doxygen up to somewhere between 1.8.17 to exclusive 1.9.1
# the 'friend' part is also left in the type.
# See also: #767, #916
typ = re.sub(r"(^|\s+)friend(\s+)", r"\1\2", typ)
elements.append("friend")
if node.virt in ("virtual", "pure-virtual"):
elements.append("virtual")
if node.explicit == "yes":
elements.append("explicit")
# TODO: handle constexpr when parser has been updated
# but Doxygen seems to leave it in the type anyway
typ = "".join(n.astext() for n in self.render(node.get_type()))
# Doxygen sometimes leaves 'static' in the type,
# e.g., for "constexpr static auto f()"
typ = typ.replace("static ", "")
# In Doxygen up to somewhere between 1.8.17 to exclusive 1.9.1
# the 'friend' part is also left in the type.
# See also #767.
if typ.startswith("friend "):
typ = typ[7:]
elements.append(typ)
elements.append(name)
elements.append(node.get_argsstring())
Expand Down
15 changes: 15 additions & 0 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,18 @@ def test_ellipsis(app):
# Verify that parsing an ellipsis works
ast_param = cls._parse_args(argsstrings[0])
ret = cls._resolve_function(matches, ast_param, None)


def test_render_constexpr_friend_func(app):
member_def = WrappedMemberDef(
kind="function",
definition="constexpr friend bool operator==",
type_="constexpr friend bool",
name="operator==",
argsstring="(cat const x, int const y)",
virt="non-virtual",
const="no",
)
rendered = render(app, member_def)
signature = find_node(rendered, "desc_signature")
assert signature.astext().startswith("friend constexpr bool")