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

Improve includes list #763

Merged
merged 12 commits into from
Jan 27, 2022
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Inspired by `Keepachangelog.com <http://keepachangelog.com/>`__.
- Change the way directives are added to adhere to the interface,
e.g., avoiding myst-parser to crash.
`#780 <https://github.com/michaeljones/breathe/pull/780>`__
- Improved list of included files (with cross-references for local includes)
`#763 <https://github.com/michaeljones/breathe/pull/763>`_


- 2021-09-14 - **Breathe v4.31.0**

Expand Down
18 changes: 11 additions & 7 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,8 @@ def visit_sectiondef(self, node) -> List[Node]:

def visit_docreftext(self, node) -> List[Node]:
nodelist = self.render_iterable(node.content_)
nodelist.extend(self.render_iterable(node.para))
if hasattr(node, "para"):
nodelist.extend(self.render_iterable(node.para))

refid = self.get_refid(node.refid)

Expand Down Expand Up @@ -1706,18 +1707,21 @@ def visit_verbatim(self, node) -> List[Node]:

return [rst_node]

def visit_inc(self, node) -> List[Node]:
def visit_inc(self, node: compoundsuper.incType) -> List[nodes.container]:
if not self.app.config.breathe_show_include:
return []

if node.local == u"yes":
text = '#include "%s"' % node.content_[0].getValue()
compound_link = [nodes.Text("", node.content_[0].getValue())]
if node.get_refid():
compound_link = self.visit_docreftext(node)
if node.local == "yes":
text = [nodes.Text('#include "'), *compound_link, nodes.Text('"')]
else:
text = "#include <%s>" % node.content_[0].getValue()
text = [nodes.Text("#include <"), *compound_link, nodes.Text(">")]

return [nodes.emphasis(text=text)]
return [nodes.container("", nodes.emphasis("", *text))]

def visit_ref(self, node) -> List[Node]:
def visit_ref(self, node: compoundsuper.refType) -> List[Node]:
def get_node_info(file_data):
name = node.content_[0].getValue()
name = name.rsplit("::", 1)[-1]
Expand Down