Doxygen: Is it possible to control the orientation of dependency graphs?

末鹿安然 提交于 2019-12-10 14:23:48

问题


Up until today, I'd been using an "ancient" version (1.4.7) of doxygen (+dot) and it typically drew graphs with a vertical orientation, e.g.

.. but with a more recent one (1.8.6 as distributed via Ubuntu), the graphs seem to be horizontal, i.e.

The problem with the horizontal orientation is that many of the graphs go well off the right edge of the window and so you have to do "2D" scrolling to see the data.

I've looked in the doxygen web pages but couldn't see if there was an option to tell dot to draw them with the vertical orientation. Does anyone know if such an option exists?


回答1:


There is a similar question asked in 2014 which I am duplicate answering: Flip doxygen's graphs from top-to-bottom orientation to left-to-right

After looking for the same myself and finding nothing, the best I can offer is a hack using the graph attribute rankdir.

Step 1) Make sure Doxygen keeps the dot files. Put DOT_CLEANUP=NO in your confige file.

Step 2) find your dot files that Doxygen generated. Should be in the form *__incl.dot. for steps below I will refer to this file as <source>.dot

Step 3a) Assuming the dot file did not explicitly specify rankdir (usually it is TB" by default), regenerate the output with this command.

dot -Grankdir="LR" -Tpng -o<source>.png -Tcmapx -o<source>.map <source>.dot 

Step 3b) If for some reason rankdir is specified in the dot file, go into the file and add the rankdir="LR" (by default they are rankdir is set to "TB").

digraph "AppMain"
{
  rankdir="LR";
...

Then regenerate the output with:

dot -Tpng -o<source>.png -Tcmapx -o<source>.map <source>.dot 

You need to redo this after every run of Doxygen. A batch file might be handy, especially if you want to process all files. For step 3b, batch replacing text is outside of the scope of this answer :). But here seems to be a good answer:

How can you find and replace text in a file using the Windows command-line environment?



来源:https://stackoverflow.com/questions/32967122/doxygen-is-it-possible-to-control-the-orientation-of-dependency-graphs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!