Doxygen:可以控制依赖图的方向吗?

问题描述 投票:5回答:2

直到今天,我一直在使用doxygen(+点)的“古老”版本(1.4.7),它通常绘制垂直方向的图形,例如enter image description here

..但有一个较新的版本(通过Ubuntu发布的1.8.6),这些图似乎是水平的,即enter image description here

水平方向的问题是,许多图形在窗口右边缘的位置都很好,因此您必须进行“ 2D”滚动才能看到数据。

我看过doxygen网页,但看不到是否有任何选项可以告诉点以垂直方向绘制它们。有人知道这样的选择是否存在吗?

doxygen dot
2个回答
5
投票

[2014年有一个类似的问题,我重复回答:Flip doxygen's graphs from top-to-bottom orientation to left-to-right

[自己寻找相同对象,却一无所获后,我能提供的最好方法是使用图形属性rankdir进行黑客攻击。

步骤1)确保Doxygen保留点文件。将DOT_CLEANUP = NO放入您的配置文件中。

[步骤2)查找Doxygen生成的点文件。应采用* __ incl.dot的形式。对于以下步骤,我将此文件称为<source>.dot

[步骤3a]假定点文件未显式指定rankdir(默认情况下通常为TB“,请使用此命令重新生成输出。

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

[步骤3b]如果由于某种原因在点文件中指定了rankdir,请进入该文件并添加rankdir="LR"(默认情况下,它们是rankdir设置为"TB")。

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

然后使用以下命令重新生成输出:

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

每次运行Doxygen后,您都需要重做一次。批处理文件可能很方便,特别是如果您要处理所有文件。对于步骤3b,批量替换文本不在此答案的范围内:)。但这似乎是一个很好的答案:

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


0
投票

[参考迈克尔的答案,我写了一些python3脚本来对点图,使其变为LR。这对我来说非常方便,也许对某人有用。调整输出路径"../../doxygen_output"以指向您的氧气输出,然后只需使用当前工作目录=脚本路径运行脚本即可。

#!/usr/bin/python3
# -*- coding: utf-8 -*-

""" This script postprocesses a doxygen output to change the dot graphs having rankdir="LR"."""
import os

for path,dirs,files in os.walk("../../doxygen_output"):
    for f in files:
        if len(f) > 5: # prevent index out of range error
            if f[-4:] == ".dot":
                source = os.path.join(path,f.replace(".dot",""))
                cmdTpl = 'dot -Grankdir="LR" -Tpng -o<source>.png -Tcmapx -o<source>.map <source>.dot'
                cmd = cmdTpl.replace("<source>",source)
                os.system(cmd)

© www.soinside.com 2019 - 2024. All rights reserved.