问题
Doxygen can generate class diagrams with graphiz.
For example:
class A {...};
class B extends A {...};
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?
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";
}
}
And generate a picture of 2 classes A and B with reference between them.
I've tried to search through documentation but can't find any suitable examples or explanation about custom drawing in javadoc+doxygen+graphviz.
回答1:
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";
}
}
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"
note that I had to use @cond
... @endcond
to let doxygen skip the @OrAnotationToDrawLink
line.
来源:https://stackoverflow.com/questions/25610378/doxygen-dot-draw-link-between-classes-by-annotation