python_uml_class 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57d9b2f9c5e9a33f0ddad879342573239dfd191c4f157db560cc65288478c6ad
4
- data.tar.gz: 16108c011929af51026809c24ff5d75647109869b43aa1d5cac02b1a1008cf55
3
+ metadata.gz: d435129de73a27c2496f0a9e11a842eafa98e207992a60bec4ccbdfdceba5317
4
+ data.tar.gz: c270fe9e35fec84ec6dc785be1b144d9539a9e0b2d8ed99feec47b0b6ff7066f
5
5
  SHA512:
6
- metadata.gz: ae1adf4ebc0faefebd3a64a81b259453a4c6ba2adca2ced788371cc901416c5f90703653f7c6479cb82ee30684c0a969e5862b82b3db8f3fa3a69468ea6cd2a9
7
- data.tar.gz: 4b8ccf75957dae5936bf478b915cfa45e6b7b9deccadfbec7c97613b4d70091d3016030b47c0876544ba09213b56e79c793a81d084225bc55521991d4431b631
6
+ metadata.gz: 12db394eab5180b1085d411bba1750b46b3c90448b93ef54f984b5d1f6538e5782d4bfaf4cf3c5c1efdee0eaccc0b575edaa225ecca38078f67ba8625c8e3ac9
7
+ data.tar.gz: cef0a8ba1f172ba4f0545a61f7745d9d1b28deaae211dc2e0ecef9549b1c7990b1ffbed614c66a616f685b4151b1eb605d5dedc681e7f1006d502b9244842bdb
data/.rspec_status ADDED
@@ -0,0 +1,13 @@
1
+ example_id | status | run_time |
2
+ -------------------------------------- | ------ | --------------- |
3
+ ./spec/PythonUmlClass_spec.rb[1:1] | passed | 0.00068 seconds |
4
+ ./spec/create_uml_class_spec.rb[1:1:1] | passed | 0.00038 seconds |
5
+ ./spec/create_uml_class_spec.rb[1:1:2] | passed | 0.00008 seconds |
6
+ ./spec/create_uml_class_spec.rb[1:2:1] | passed | 0.00007 seconds |
7
+ ./spec/create_uml_class_spec.rb[1:2:2] | passed | 0.00006 seconds |
8
+ ./spec/create_uml_class_spec.rb[1:3:1] | passed | 0.00819 seconds |
9
+ ./spec/create_uml_class_spec.rb[1:3:2] | passed | 0.00183 seconds |
10
+ ./spec/create_uml_class_spec.rb[1:3:3] | passed | 0.00176 seconds |
11
+ ./spec/create_uml_class_spec.rb[1:3:4] | passed | 0.00141 seconds |
12
+ ./spec/test_vars_spec.rb[1:1] | passed | 0.00508 seconds |
13
+ ./spec/test_vars_spec.rb[1:2] | passed | 0.00081 seconds |
data/Gemfile CHANGED
@@ -8,3 +8,6 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
+
12
+ gem "rack", ">= 3.0"
13
+ gem "rackup"
data/Gemfile.lock CHANGED
@@ -1,86 +1,101 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- python_uml_class (0.1.0)
4
+ python_uml_class (0.2.1)
5
5
  browser_app_base (~> 0.1)
6
6
  facter (~> 4.2)
7
+ rack (>= 3.0)
8
+ rackup
9
+ webrick
7
10
 
8
11
  GEM
9
12
  remote: https://rubygems.org/
10
13
  specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- base64 (0.2.0)
14
- browser_app_base (0.1.7)
15
- facter
14
+ addressable (2.8.9)
15
+ public_suffix (>= 2.0.2, < 8.0)
16
+ base64 (0.3.0)
17
+ browser_app_base (0.2.0)
16
18
  json
17
19
  sinatra
18
20
  sinatra-contrib
19
21
  sinatra-websocket
20
22
  thin
21
23
  daemons (1.4.1)
22
- diff-lcs (1.5.0)
24
+ diff-lcs (1.6.2)
23
25
  em-websocket (0.3.8)
24
26
  addressable (>= 2.1.1)
25
27
  eventmachine (>= 0.12.9)
26
28
  eventmachine (1.2.7)
27
- facter (4.5.1)
29
+ facter (4.10.0)
28
30
  hocon (~> 1.3)
29
- thor (>= 1.0.1, < 2.0)
31
+ thor (>= 1.0.1, < 1.3)
30
32
  hocon (1.4.0)
31
- json (2.7.1)
32
- multi_json (1.15.0)
33
- mustermann (3.0.0)
33
+ json (2.19.3)
34
+ logger (1.7.0)
35
+ multi_json (1.19.1)
36
+ mustermann (3.0.4)
34
37
  ruby2_keywords (~> 0.0.1)
35
- public_suffix (5.0.4)
36
- rack (2.2.8)
37
- rack-protection (3.2.0)
38
+ public_suffix (7.0.5)
39
+ rack (3.2.5)
40
+ rack-protection (4.2.1)
38
41
  base64 (>= 0.1.0)
39
- rack (~> 2.2, >= 2.2.4)
40
- rake (13.1.0)
41
- rspec (3.12.0)
42
- rspec-core (~> 3.12.0)
43
- rspec-expectations (~> 3.12.0)
44
- rspec-mocks (~> 3.12.0)
45
- rspec-core (3.12.2)
46
- rspec-support (~> 3.12.0)
47
- rspec-expectations (3.12.3)
42
+ logger (>= 1.6.0)
43
+ rack (>= 3.0.0, < 4)
44
+ rack-session (2.1.1)
45
+ base64 (>= 0.1.0)
46
+ rack (>= 3.0.0)
47
+ rackup (2.3.1)
48
+ rack (>= 3)
49
+ rake (13.3.1)
50
+ rspec (3.13.2)
51
+ rspec-core (~> 3.13.0)
52
+ rspec-expectations (~> 3.13.0)
53
+ rspec-mocks (~> 3.13.0)
54
+ rspec-core (3.13.6)
55
+ rspec-support (~> 3.13.0)
56
+ rspec-expectations (3.13.5)
48
57
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.12.0)
50
- rspec-mocks (3.12.6)
58
+ rspec-support (~> 3.13.0)
59
+ rspec-mocks (3.13.8)
51
60
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.12.0)
53
- rspec-support (3.12.1)
61
+ rspec-support (~> 3.13.0)
62
+ rspec-support (3.13.7)
54
63
  ruby2_keywords (0.0.5)
55
- sinatra (3.2.0)
64
+ sinatra (4.2.1)
65
+ logger (>= 1.6.0)
56
66
  mustermann (~> 3.0)
57
- rack (~> 2.2, >= 2.2.4)
58
- rack-protection (= 3.2.0)
67
+ rack (>= 3.0.0, < 4)
68
+ rack-protection (= 4.2.1)
69
+ rack-session (>= 2.0.0, < 3)
59
70
  tilt (~> 2.0)
60
- sinatra-contrib (3.2.0)
71
+ sinatra-contrib (4.2.1)
61
72
  multi_json (>= 0.0.2)
62
73
  mustermann (~> 3.0)
63
- rack-protection (= 3.2.0)
64
- sinatra (= 3.2.0)
74
+ rack-protection (= 4.2.1)
75
+ sinatra (= 4.2.1)
65
76
  tilt (~> 2.0)
66
- sinatra-websocket (0.3.1)
77
+ sinatra-websocket (0.3.0)
67
78
  em-websocket (~> 0.3.6)
68
79
  eventmachine
69
- thin (>= 1.3.1, < 2.0.0)
70
- thin (1.8.2)
80
+ thin (>= 1.3.1)
81
+ thin (2.0.1)
71
82
  daemons (~> 1.0, >= 1.0.9)
72
83
  eventmachine (~> 1.0, >= 1.0.4)
73
- rack (>= 1, < 3)
74
- thor (1.3.0)
75
- tilt (2.3.0)
84
+ logger
85
+ rack (>= 1, < 4)
86
+ thor (1.2.2)
87
+ tilt (2.7.0)
88
+ webrick (1.9.2)
76
89
 
77
90
  PLATFORMS
78
91
  x86_64-linux
79
92
 
80
93
  DEPENDENCIES
81
94
  python_uml_class!
95
+ rack (>= 3.0)
96
+ rackup
82
97
  rake (~> 13.0)
83
98
  rspec (~> 3.0)
84
99
 
85
100
  BUNDLED WITH
86
- 2.4.21
101
+ 2.4.20
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # PythonUmlClass
2
2
  Create a python class diagram
3
3
 
4
+ Read this in other languages: [English](README.md), [日本語](README_JA.md)
5
+
4
6
  ## Setup
5
7
  for ubuntu
6
8
  $ sudo apt install plantuml
7
- $ apt install -y pip
9
+ $ sudo apt install python3.12-venv
10
+ $ python3 -m venv .venv
11
+ $ source .venv/bin/activate
8
12
  $ pip install astor
9
13
 
10
14
  install google-chrome
@@ -29,6 +33,59 @@ If bundler is not being used to manage dependencies, install the gem by executin
29
33
 
30
34
  ![class](img/class.png)
31
35
 
36
+ ## Release Notes
37
+
38
+ ### v0.2.1
39
+ - **Feature**: Added `python_path` setting in `setting.json` to allow specifying a custom Python path when executing the formatter script.
40
+ - **Feature**: Added `class_color` and `color_class_name` settings in `setting.json`. Classes matching the `color_class_name` regular expression will be displayed with the specified `class_color` along with their inheritance (`-|>`) and composition (`*--`) relationship lines.
41
+ - **Enhancement**: Improved the extraction of class compositions to properly detect class instantiations inside parentheses (e.g., `chat_history.append(HumanMessage(content=...))`).
42
+ - **Enhancement**: Modified class extraction to output fully qualified module names (e.g., `langchain_core.messages.HumanMessage`) when an alias or module path is specified via `from module import Class` or `import module as alias`.
43
+ - **Enhancement**: Filtered the extracted objects to include only the classes explicitly imported or defined locally within the parsed file.
44
+ - **Enhancement**: Updated `README.md` to include instructions for setting up a Python virtual environment (`python3 -m venv .venv`).
45
+ - **Bug Fix**: Addressed an issue where variables defined with `class_` prefix (like `class_var`) or variables without assignments but containing type hints (like `global_var: int`) were incorrectly identified.
46
+ - **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.
47
+ - **Bug Fix**: Fixed `uninitialized constant Rack::Server` error and improved Rack 3 support by unifying the server usage to `Rackup::Server` while maintaining backward compatibility with `Rack::Server` for older Rack 2 environments.
48
+ - **Bug Fix**: Fixed an issue where the WebSocket connection URL in `main.js` was missing or updating to the wrong port.
49
+ - **Bug Fix**: Resolved `SinatraWebsocket::Error::ConfigurationError` by explicitly passing `:server => 'thin'` to ensure websockets work smoothly in async environments.
50
+ - **Bug Fix**: Handled an `Encoding::CompatibilityError` where incoming WebSocket messages from the browser were incorrectly interpreted as `US-ASCII`. They are now correctly parsed as `UTF-8`.
51
+ - **Bug Fix**: Fixed a crash `no implicit conversion of nil into String` in `create_uml_class.rb` which occurred when `@config` was `nil`.
52
+
53
+ ## Testing with Docker
54
+
55
+ You can use Docker to set up a development and testing environment for Ubuntu 22.04 and 24.04.
56
+
57
+ 1. Move to `test/docker/ubuntu`.
58
+ ```bash
59
+ $ cd test/docker/ubuntu
60
+ ```
61
+
62
+ 2. Build and start the container using docker compose.
63
+ - For Ubuntu 22.04:
64
+ ```bash
65
+ $ docker compose up -d --build
66
+ ```
67
+ - For Ubuntu 24.04:
68
+ ```bash
69
+ $ docker compose -f docker-compose-24.04.yml up -d --build
70
+ ```
71
+
72
+ 3. Log in to the container to run tests or the application. (The source code is mounted at `/work` inside the container)
73
+ - For Ubuntu 22.04:
74
+ ```bash
75
+ $ docker exec -it ubuntu bash
76
+ ```
77
+ - For Ubuntu 24.04:
78
+ ```bash
79
+ $ docker exec -it ubuntu-24.04 bash
80
+ ```
81
+
82
+ 4. Run tests inside the container.
83
+ ```bash
84
+ $ cd /work
85
+ $ bundle install
86
+ $ bundle exec rspec
87
+ ```
88
+
32
89
  ## Development
33
90
 
34
91
  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](https://pythongems.org).
@@ -39,4 +96,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/kuwaya
39
96
 
40
97
  ## License
41
98
 
42
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
99
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/README_JA.md ADDED
@@ -0,0 +1,99 @@
1
+ # PythonUmlClass
2
+ Pythonのクラス図を作成します。
3
+
4
+ 他の言語で読む: [English](README.md), [日本語](README_JA.md)
5
+
6
+ ## セットアップ
7
+ Ubuntuの場合
8
+ $ sudo apt install plantuml
9
+ $ sudo apt install python3.12-venv
10
+ $ python3 -m venv .venv
11
+ $ source .venv/bin/activate
12
+ $ pip install astor
13
+
14
+ Google Chromeのインストール
15
+ $ echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
16
+ $ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
17
+ $ apt update
18
+ $ apt -y install google-chrome-stable
19
+
20
+ ## インストール
21
+
22
+ アプリケーションのGemfileに以下を追加してインストールします:
23
+
24
+ $ bundle add python_uml_class
25
+
26
+ bundlerを使用していない場合は、以下のコマンドでgemをインストールします:
27
+
28
+ $ gem install python_uml_class
29
+
30
+ ## 使用方法
31
+
32
+ $ start_python_uml_class.rb
33
+
34
+ ![class](img/class.png)
35
+
36
+ ## リリースノート
37
+
38
+ ### v0.2.1
39
+ - **機能追加**: `setting.json` に `python_path` 設定を追加し、フォーマッターのスクリプトを実行する際の Python のパスを指定可能にしました。
40
+ - **機能追加**: `setting.json` に `class_color` と `color_class_name` 設定を追加。`color_class_name` の正規表現に部分一致するクラスは、PlantUML出力時にクラス自体の背景色と、そのクラスへ繋がる継承 (`-|>`) やコンポジション (`*--`) の矢印線の色が `class_color` で指定した色になります。
41
+ - **改善**: コンポジション関係の抽出処理(クラスの初期化)を強化し、括弧内の呼び出し(例: `chat_history.append(HumanMessage(content=...))`)であってもクラスのインスタンス化を正しく検出できるようにしました。
42
+ - **改善**: `from ... import ...` や `import ... as ...` などでインポートされたクラスを利用する際、元の完全修飾名(例: `langchain_core.messages.HumanMessage`)を復元してUMLに正しく出力するように修正しました。
43
+ - **改善**: クラスの初期化(コンポジション)において、同じファイル内で定義されたクラスか、明示的にインポートされたクラスのみを対象とするようにフィルタリング処理を強化しました。
44
+ - **改善**: `README.md` に Pythonの仮想環境(venv)のセットアップ手順を追記しました。
45
+ - **バグ修正**: `class_var` のように名前に `class` を含む変数が誤ってクラス宣言として認識される問題や、型ヒントのみ(`global_var: int` など)で代入を伴わないクラス変数・外部変数が正しく抽出されない問題を修正しました。
46
+ - **バグ修正**: クラス内の関数(メソッド)に空白のみの空行や、マルチライン文字列(`"""` や `'''`)が含まれる場合、インデントレベルが誤認されて以降のローカル変数が「クラス変数」や「外部変数(グローバル)」として誤って抽出・出力されるバグを修正しました。
47
+ - **バグ修正**: Rack 3環境での `uninitialized constant Rack::Server` エラーを修正。サーバー起動処理を `Rackup::Server` に統一し、古いRack 2環境でも動作するように後方互換性を持たせました。
48
+ - **バグ修正**: `main.js` 内の WebSocket 接続URLのポート番号が正しく書き換わらない問題を修正しました。
49
+ - **バグ修正**: 非同期サーバーである Thin を明示的に指定することで、WebSocket接続時の `SinatraWebsocket::Error::ConfigurationError` を解決しました。
50
+ - **バグ修正**: WebSocket通信において、ブラウザから受信した文字列が `US-ASCII` として解釈されてしまうことで起きるエンコーディングエラー(`Encoding::CompatibilityError`)を修正し、`UTF-8` として処理するようにしました。
51
+ - **バグ修正**: `create_uml_class.rb` において、`@config` が `nil` の時に `no implicit conversion of nil into String` エラーが発生してクラッシュする問題を修正しました。
52
+
53
+ ## Dockerでのテスト環境構築
54
+
55
+ Dockerを使用して開発・テスト環境(Ubuntu 22.04、および24.04)を構築できます。
56
+
57
+ 1. `test/docker/ubuntu` に移動します。
58
+ ```bash
59
+ $ cd test/docker/ubuntu
60
+ ```
61
+
62
+ 2. docker composeを使用してコンテナをビルド・起動します。
63
+ - Ubuntu 22.04 の場合:
64
+ ```bash
65
+ $ docker compose up -d --build
66
+ ```
67
+ - Ubuntu 24.04 の場合:
68
+ ```bash
69
+ $ docker compose -f docker-compose-24.04.yml up -d --build
70
+ ```
71
+
72
+ 3. コンテナにログインしてテストやアプリケーションの実行を行います。(ソースコードはコンテナ内の `/work` にマウントされています)
73
+ - Ubuntu 22.04 の場合:
74
+ ```bash
75
+ $ docker exec -it ubuntu bash
76
+ ```
77
+ - Ubuntu 24.04 の場合:
78
+ ```bash
79
+ $ docker exec -it ubuntu-24.04 bash
80
+ ```
81
+
82
+ 4. コンテナ内でテストを実行します。
83
+ ```bash
84
+ $ cd /work
85
+ $ bundle install
86
+ $ bundle exec rspec
87
+ ```
88
+
89
+ ## 開発
90
+
91
+ このgemをローカルマシンにインストールするには、`bundle exec rake install`を実行します。新しいバージョンをリリースするには、`version.rb`のバージョン番号を更新してから、`bundle exec rake release`を実行します。これにより、バージョンのgitタグが作成され、コミットとタグがプッシュされ、`.gem`ファイルが[pythongems.org](https://pythongems.org)にプッシュされます。
92
+
93
+ ## コントリビューション
94
+
95
+ バグレポートとプルリクエストはGitHub https://github.com/kuwayama1971/PythonUmlClass で歓迎します。
96
+
97
+ ## ライセンス
98
+
99
+ このgemは[MIT License](https://opensource.org/licenses/MIT)の条件の下でオープンソースとして利用可能です。
data/img/class.png CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 0.1,
2
+ "version": 0.2,
3
3
  "setting_list": [
4
4
  {
5
5
  "name": "plantuml",
@@ -8,6 +8,13 @@
8
8
  "select": "",
9
9
  "description": "PlantUMLコマンド"
10
10
  },
11
+ {
12
+ "name": "python_path",
13
+ "value": " ~/.python3_venv/bin/python3",
14
+ "type": "input",
15
+ "select": "",
16
+ "description": "pythonのパス"
17
+ },
11
18
  {
12
19
  "name": "formatter_path",
13
20
  "value": "./del_comment.py",
@@ -38,10 +45,24 @@
38
45
  },
39
46
  {
40
47
  "name": "exclude_path",
41
- "value": "",
48
+ "value": "/venv/",
42
49
  "type": "input",
43
50
  "select": "",
44
51
  "description": "除外するパス(正規表現)"
52
+ },
53
+ {
54
+ "name": "class_color",
55
+ "value": "LightBlue",
56
+ "type": "input",
57
+ "select": "",
58
+ "description": "特定クラスの色"
59
+ },
60
+ {
61
+ "name": "color_class_name",
62
+ "value": "(langchain)",
63
+ "type": "input",
64
+ "select": "",
65
+ "description": "色を付けるクラスの正規表現"
45
66
  }
46
67
  ]
47
68
  }
data/lib/config.ru CHANGED
@@ -102,6 +102,4 @@ configure do
102
102
 
103
103
  end
104
104
 
105
- #\ --port 37583
106
-
107
105
  run Sinatra::Application