问题描述
Doxygen可以使用graphiz生成类图.
Doxygen can generate class diagrams with graphiz.
例如:
class A {...};
class B extends A {...};
从这段代码中,我可以生成一张图片,其中doxygen可以证明一个类是另一个的父类.
From this code I can generate a picture where doxygen can show that one class it the parent of an other.
但是,有没有一种方法可以通过在类之间进行手动引用的代码来生成图片呢?
But is there a way to generate a picture from code with manual references between classes?
例如,当我描述数据库方案并使用合同类时( http://developer.android.com/training/basics/data-storage/databases.html#DefineContract )我想执行以下操作:
For example when I describe DB scheme and use contract classes (http://developer.android.com/training/basics/data-storage/databases.html#DefineContract) I want to perform smth like this:
class MainClass {
class A {
String COLUMN_ID = "id_a";
}
/**
* {@dotlinkto MainClass.A}
**/
@OrAnotationToDrawLink(A.class)
class B {
String COLUMN_ID = "id_b";
String COLUMN_FOREIGN_KEY_TO_A = "id_a_key";
}
}
并生成两个类别A和B的图片,并在它们之间进行引用.
And generate a picture of 2 classes A and B with reference between them.
我尝试搜索文档,但找不到任何合适的示例或有关javadoc + doxygen + graphviz中的自定义绘图的说明.
I've tried to search through documentation but can't find any suitable examples or explanation about custom drawing in javadoc+doxygen+graphviz.
推荐答案
我能想到的最接近的事情是定义一个自定义命令,该命令可扩展为一个内联点图,即
The closest thing I can think of is to define a custom command that expands to an inline dot graph, i.e.
class MainClass {
public class A {
String COLUMN_ID = "id_a";
}
/**
* @dotlinkbetween{A,B}
* @cond
**/
@OrAnotationToDrawLink(A.class)
/** @endcond */
public class B {
String COLUMN_ID = "id_b";
String COLUMN_FOREIGN_KEY_TO_A = "id_a_key";
}
}
在doxygen的配置文件中具有以下ALIAS定义:
with the following ALIAS definition in doxygen's configuration file:
ALIASES = dotlinkbetween{2}="@dot digraph { node [shape=record ]; \1 [ URL=\"\ref \1\" ]; \2 [ URL=\"\ref \2\" ]; \2 -> \1; } @enddot"
请注意,我必须使用@cond
... @endcond
来使doxygen跳过@OrAnotationToDrawLink
行.
note that I had to use @cond
... @endcond
to let doxygen skip the @OrAnotationToDrawLink
line.
这篇关于氧点.通过注释在类之间绘制链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!