从Python源代码生成UML图的最佳方法是什么? [英] What's the best way to generate a UML diagram from Python source code?

查看:228
本文介绍了从Python源代码生成UML图的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一位同事正在寻找从Python源代码堆中生成UML类图的方法。
他主要对继承关系感兴趣,对组合关系也略有兴趣,并且不太在乎仅仅是Python原语的类属性。

A colleague is looking to generate UML class diagrams from heaps of Python source code. He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.

The源代码非常简单明了,并且没有太大的弊端-例如,它没有做任何花哨的元类魔术。 (主要是从Python 1.5.2时代起,还有一些现代 2.3ish的东西。)

The source code is pretty straightforward and not tremendously evil--it doesn't do any fancy metaclass magic, for example. (It's mostly from the days of Python 1.5.2, with some sprinklings of "modern" 2.3ish stuff.)

推荐的最佳现有解决方案是什么?

What's the best existing solution to recommend?

推荐答案

您可能听说过 Pylint 有助于静态检查Python代码。很少有人知道它带有一个名为 Pyreverse 的工具,该工具可以从读取的python代码中绘制UML图。 。 Pyreverse使用graphviz作为后端。

You may have heard of Pylint that helps statically checking Python code. Few people know that it comes with a tool named Pyreverse that draws UML diagrams from the python code it reads. Pyreverse uses graphviz as a backend.

它的用法如下:

pyreverse -o png -p yourpackage .

其中也可以是单个文件。

where the . can also be a single file.

这篇关于从Python源代码生成UML图的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆