Generate class diagrams
Class diagrams are really useful for people who will be contributing to the project. They will also help people who know how to program know what classes and methods are available.
If you have pylint installed, it comes with pyreverse
to generate the class diagram make sure you have mesa installed (e.g., via pip)
go into the base mesa folder (e.g. /home/dchen/git/forks/mesa) and run:
pyreverse -o png -p mesa mesa
It will call pyreverse, create a png file, using the package mesa, and look in the mesa directory for all the files.
It will generate something like below:

You will need to add the following files to .gitignore:
classes_mesa.png
packages_mesa.png
@chendaniely Ty for these notes! This is very helpful! @dmasad -- ideas on where to put this? / how to integrate into the project?
This is a wonderful tool that produces very valuable documents. maybe these two images could be included in the docs? maybe they could be stored in a resources folder within the docs folder? maybe they could be automatically generated and replace old ones each time a pull request is made?
@jackiekazil @dmasad There's continuous integration setup on this repo, we could have CI re-generate these images every time a PR is made and stick it in somewhere in the documentation
Or if you'd like I can submit a PR and we can deal with CI another time..
@chendaniely :-) Hey! It's been awhile. Still interested? Either works. I think I would prefer it to be added to the documentation, but if not, if you could write instructions on how to create it that would be great to.
Since the documentation is a part of the repo itself, it is not possible to put in the regenerated class diagram without forcing anyone to regenerate it every time. It would make more sense to regenerate for each release (after putting the step into the release checklist, of course).
if you could write instructions on how to create it that would be great to.
It is exactly as @chendaniely wrote: pyreverse -o png -p mesa mesa.
On another note, I reran pyreverse and the diagram has grown even wider since https://github.com/projectmesa/mesa/issues/152#issue-94509732.
More another optional note, pyreverse has option to output svg, which is lossless. But I'm not sure if rtd can read svg.
@rht - do you know of a project that separates the docs from the main repo? (Just wondering since you said that.)
RE: Location -- Where do you suggest to store and link from?
IIRC usually this would be the projects with implementations in several languages. It's all sewn in in 1 repo for cpython, Django, numpy. There is no precedence to draw from. This is possibly to make sure that the doc is never out of sync with the code.
The safest option for now is to put in the diagram of the latest stable release into the doc.
Hi, I tried to run pyreverse -o png -p mesa mesa command, but it complains The output format 'png' is currently not available. Please install 'Graphviz' to have other output formats than 'dot' or 'vcg'. . So I installed Graphviz by using pip install Graphviz, and it still complains. Does anyone get the same problem?
@GHWHG conda install graphviz could solve your issue