如何使用 doxygen 从 C++ 创建 UML 类图来源
我一直在寻找一些描述如何使用 doxygen 生成简单类图的材料,但找不到。
我需要从一组 C++ 文件创建如下所示的 UML 类图:
任何人都可以帮我调整 doxygen 到生成这样的图?
I have been searching for some material that describes how to generate simple class diagrams with doxygen, but couldn't find one.
I need to create UML class diagrams as shown below from a set of C++ files:
Can anybody help me tweak doxygen to generate such graphs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
得票最高的 2 个答案是正确的。截至今天,我唯一需要更改的(默认设置)是使用点而不是内置生成器启用生成。
一些重要注意事项:
html/inherits.html
或(从网站导航)classes => 中找到。类层次结构 => “转到文本类层次结构”。T
。foo
继承自T
并且T
模板类型参数具有默认值,则将采用该默认值。如果有一个继承自foo
的类型bar
,其中U
与默认值不同,则bar
将有一个foo
父级。foo<>
和bar
将没有共同的父级。variant
实例化都将显示为继承自variant
。<...>
字符串,表示没有默认值的类型和非类型参数。The 2 highest upvoted answers are correct. As of today, the only thing I needed to change (from default settings) was to enable generation using dot instead of the built-in generator.
Some important notes:
html/inherits.html
or (from the website navigation) classes => class hierarchy => "Go to the textual class hierarchy".T
.foo
inherits fromT
and theT
template type parameter has a default, such default will be assumed. If there is a typebar
which inherits fromfoo<U>
whereU
is different than the default,bar
will have afoo<U>
parent.foo<>
andbar<U>
will not have a common parent.variant
instantiation will be displayed to inherit fromvariant<Ts...>
.<...>
string in their name representing type and non-type parameters which did not have defaults.我认为您需要编辑 doxys 文件并将 GENERATE_UML (类似的东西)设置为 true。并且您需要安装 dot/graphviz。
I think you will need to edit the doxys file and set GENERATE_UML (something like that) to true. And you need to have dot/graphviz installed.
嗯,这似乎是一个老问题了,但是由于我最近几天一直在摆弄 Doxygen 配置,而我的脑子里仍然充满了当前的信息,让我们来尝试一下 -
我认为之前的答案几乎已经it:
缺少的选项是在 Doxyfile 中添加
COLLABORATION_GRAPH = YES
。我假设你可以在 doxywizard GUI 中的某个地方做同样的事情(我不使用 doxywizard)。因此,作为一个更完整的示例,我倾向于使用的与 UML 输出相关的典型“Doxyfile”选项是:
这些设置将生成“继承”(
CLASS_GRAPH=YES
) 和“协作”(<代码>COLLABORATION_GRAPH=YES)图表。根据 doxygen 输出“部署”的目标,设置 DOT_IMAGE_FORMAT = svg 也可能有用。使用 svg 输出,图表是“可缩放的”,而不是像 .png 这样的位图格式的固定分辨率。显然,如果在 IE 以外的浏览器中查看输出,还有 INTERACTIVE_SVG = YES ,这将允许生成的 svg 图表“交互式缩放和平移”。我前段时间确实尝试过,svg 输出在视觉上非常有吸引力,但当时浏览器对 svg 的支持仍然有点不一致,所以希望这种情况最近可能有所改善。
正如其他评论所提到的,其中一些设置(特别是 DOT_GRAPH_MAX_NODES)确实具有潜在的性能影响,所以 YMMV。
我倾向于讨厌“RTFM”风格的答案,所以对这句话表示歉意,但在这种情况下,Doxygen 文档确实是你的朋友,所以请查看有关上述设置的 Doxygen 文档 - 上次我查看时,你可以在以下位置找到详细信息: http://www.doxygen.nl/manual/config.html。
Hmm, this seems to be a bit of an old question, but since I've been messing about with Doxygen configuration last few days, while my head's still full of current info let's have a stab at it -
I think the previous answers almost have it:
The missing option is to add
COLLABORATION_GRAPH = YES
in the Doxyfile. I assume you can do the equivalent thing somewhere in the doxywizard GUI (I don't use doxywizard).So, as a more complete example, typical "Doxyfile" options related to UML output that I tend to use are:
These settings will generate both "inheritance" (
CLASS_GRAPH=YES
) and "collaboration" (COLLABORATION_GRAPH=YES
) diagrams.Depending on your target for "deployment" of the doxygen output, setting
DOT_IMAGE_FORMAT = svg
may also be of use. With svg output the diagrams are "scalable" instead of the fixed resolution of bitmap formats such as .png. Apparently, if viewing the output in browsers other than IE, there is alsoINTERACTIVE_SVG = YES
which will allow "interactive zooming and panning" of the generated svg diagrams. I did try this some time ago, and the svg output was very visually attractive, but at the time, browser support for svg was still a bit inconsistent, so hopefully that situation may have improved lately.As other comments have mentioned, some of these settings (
DOT_GRAPH_MAX_NODES
in particular) do have potential performance impacts, so YMMV.I tend to hate "RTFM" style answers, so apologies for this sentence, but in this case the Doxygen documentation really is your friend, so check out the Doxygen docs on the above mentioned settings- last time I looked you can find the details at http://www.doxygen.nl/manual/config.html.
Doxygen 创建继承图,但我认为它不会创建整个类层次结构。它确实允许您使用 GraphViz 工具。如果您使用 Doxygen GUI 前端工具,您将在 Step2: -> 中找到相关选项。向导选项卡 ->图表。 DOT 关系选项位于“专家”选项卡下。
Doxygen creates inheritance diagrams but I dont think it will create an entire class hierachy. It does allow you to use the GraphViz tool. If you use the Doxygen GUI frontend tool you will find the relevant options in
Step2: -> Wizard tab -> Diagrams
. The DOT relation options are under the Expert Tab.引用这篇文章(由doxygen作者本人撰写):
Quote from this post (it's written by the author of doxygen himself) :