Skip to content

Commit

Permalink
Merge branch 'support-relative-path-to-dotfile' of https://github.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
vermeeren committed Mar 3, 2022
2 parents 20f892f + 625b211 commit 5b568ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ com_crashlytics_export_strings.xml

# modified by build process
examples/doxygen/example.tag
examples/specific/dot_graphs/xml/dotfile.dot
22 changes: 19 additions & 3 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sphinx

from breathe.parser import compound, compoundsuper, DoxygenCompoundParser
Expand Down Expand Up @@ -2369,11 +2370,26 @@ def visit_docdot(self, node) -> List[Node]:
def visit_docdotfile(self, node) -> List[Node]:
"""Translate node from doxygen's dotfile command to sphinx's graphviz directive."""
dotcode = ""
dot_file_path = node.name # type: str
# Doxygen v1.9.3+ uses a relative path to specify the dot file.
# Previously, Doxygen used an absolute path.
# This relative path is with respect to the XML_OUTPUT path.
# Furthermore, Doxygen v1.9.3+ will copy the dot file into the XML_OUTPUT
if not os.path.isabs(dot_file_path):
# Use self.project_info.project_path as the XML_OUTPUT path, and
# make it absolute with consideration to the conf.py path
project_path = self.project_info.project_path()
if os.path.isabs(project_path):
dot_file_path = os.path.abspath(project_path + os.sep + dot_file_path)
else:
dot_file_path = os.path.abspath(
self.app.confdir + os.sep + project_path + os.sep + dot_file_path
)
try:
with open(node.name, encoding="utf-8") as fp:
with open(dot_file_path, encoding="utf-8") as fp:
dotcode = fp.read()
if not dotcode.rstrip("\n"):
raise RuntimeError("%s found but without any content" % node.name)
raise RuntimeError("%s found but without any content" % dot_file_path)
except OSError as exc:
# doxygen seems to prevent this from triggering as a non-existant file
# generates no XML output for the corresponding `\dotfile` cmd
Expand All @@ -2382,7 +2398,7 @@ def visit_docdotfile(self, node) -> List[Node]:
self.state.document.reporter.warning(exc)
graph_node = graphviz()
graph_node["code"] = dotcode
graph_node["options"] = {"docname": node.name}
graph_node["options"] = {"docname": dot_file_path}
caption = "" if not node.content_ else node.content_[0].getValue()
if caption:
caption_node = nodes.caption(caption, "")
Expand Down

0 comments on commit 5b568ab

Please sign in to comment.