PythonUmlClass
Create a python class diagram
Read this in other languages: English, 日本語
Setup
for ubuntu
$ sudo apt install plantuml
$ sudo apt install python3.12-venv
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install astor
install google-chrome
$ echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
$ apt update
$ apt -y install google-chrome-stable
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add python_uml_class
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install python_uml_class
Usage
$ start_python_uml_class.rb
Release Notes
v0.2.1
-
Feature: Added
python_pathsetting insetting.jsonto allow specifying a custom Python path when executing the formatter script. -
Feature: Added
class_colorandcolor_class_namesettings insetting.json. Classes matching thecolor_class_nameregular expression will be displayed with the specifiedclass_coloralong with their inheritance (-|>) and composition (*--) relationship lines. -
Enhancement: Improved the extraction of class compositions to properly detect class instantiations inside parentheses (e.g.,
chat_history.append(HumanMessage(content=...))). -
Enhancement: Modified class extraction to output fully qualified module names (e.g.,
langchain_core.messages.HumanMessage) when an alias or module path is specified viafrom module import Classorimport module as alias. - Enhancement: Filtered the extracted objects to include only the classes explicitly imported or defined locally within the parsed file.
-
Enhancement: Updated
README.mdto include instructions for setting up a Python virtual environment (python3 -m venv .venv). -
Bug Fix: Addressed an issue where variables defined with
class_prefix (likeclass_var) or variables without assignments but containing type hints (likeglobal_var: int) were incorrectly identified. -
Bug Fix: Fixed a bug where multi-line strings (
"""or''') or empty lines containing whitespace only within class functions caused indentation miscalculations, leading to local variables being improperly recognized as class or global variables. -
Bug Fix: Fixed
uninitialized constant Rack::Servererror and improved Rack 3 support by unifying the server usage toRackup::Serverwhile maintaining backward compatibility withRack::Serverfor older Rack 2 environments. -
Bug Fix: Fixed an issue where the WebSocket connection URL in
main.jswas missing or updating to the wrong port. -
Bug Fix: Resolved
SinatraWebsocket::Error::ConfigurationErrorby explicitly passing:server => 'thin'to ensure websockets work smoothly in async environments. -
Bug Fix: Handled an
Encoding::CompatibilityErrorwhere incoming WebSocket messages from the browser were incorrectly interpreted asUS-ASCII. They are now correctly parsed asUTF-8. -
Bug Fix: Fixed a crash
no implicit conversion of nil into Stringincreate_uml_class.rbwhich occurred when@configwasnil.
Testing with Docker
You can use Docker to set up a development and testing environment for Ubuntu 22.04 and 24.04.
-
Move to
test/docker/ubuntu.$ cd test/docker/ubuntu -
Build and start the container using docker compose.
- For Ubuntu 22.04:
$ docker compose up -d --build
- For Ubuntu 24.04:
$ docker compose -f docker-compose-24.04.yml up -d --build
- For Ubuntu 22.04:
-
Log in to the container to run tests or the application. (The source code is mounted at
/workinside the container)- For Ubuntu 22.04:
$ docker exec -it ubuntu bash - For Ubuntu 24.04:
$ docker exec -it ubuntu-24.04 bash
- For Ubuntu 22.04:
-
Run tests inside the container.
$ cd /work $ bundle install $ bundle exec rspec
Development
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to pythongems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/PythonUmlClass.
License
The gem is available as open source under the terms of the MIT License.
