Skip to content

Commit

Permalink
add dot2svg function to the pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Jun 25, 2024
1 parent 6c5aa01 commit 243fb52
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
10 changes: 5 additions & 5 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Release Notes

---

## [0.1.1](https://github.com/osl-incubator/umlizer/compare/0.1.0...0.1.1) (2024-01-18)


### Bug Fixes

* Fix initial code ([#8](https://github.com/osl-incubator/umlizer/issues/8)) ([de02fb0](https://github.com/osl-incubator/umlizer/commit/de02fb0df74e1c1b6ccf1302154ef6145c068730))
* Fix Release Job on CI ([#9](https://github.com/osl-incubator/umlizer/issues/9)) ([70ec6ce](https://github.com/osl-incubator/umlizer/commit/70ec6ce2072366ca624a965249f6f95e1263578d))
* Fix replace configuration in the Release workflow ([#10](https://github.com/osl-incubator/umlizer/issues/10)) ([367b83e](https://github.com/osl-incubator/umlizer/commit/367b83e34e30b835e5f09540e97ad937587488ec))
* Fix replace configuration in the Release workflow ([#11](https://github.com/osl-incubator/umlizer/issues/11)) ([dec6d29](https://github.com/osl-incubator/umlizer/commit/dec6d2927eddbed173df369c7abb2f3c4c390e71))
- Fix initial code ([#8](https://github.com/osl-incubator/umlizer/issues/8)) ([de02fb0](https://github.com/osl-incubator/umlizer/commit/de02fb0df74e1c1b6ccf1302154ef6145c068730))
- Fix Release Job on CI ([#9](https://github.com/osl-incubator/umlizer/issues/9)) ([70ec6ce](https://github.com/osl-incubator/umlizer/commit/70ec6ce2072366ca624a965249f6f95e1263578d))
- Fix replace configuration in the Release workflow ([#10](https://github.com/osl-incubator/umlizer/issues/10)) ([367b83e](https://github.com/osl-incubator/umlizer/commit/367b83e34e30b835e5f09540e97ad937587488ec))
- Fix replace configuration in the Release workflow ([#11](https://github.com/osl-incubator/umlizer/issues/11)) ([dec6d29](https://github.com/osl-incubator/umlizer/commit/dec6d2927eddbed173df369c7abb2f3c4c390e71))

# Release Notes

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ testpaths = [
[tool.bandit]
exclude_dirs = ["tests"]
targets = "./"
skips = ["B602"]

[tool.vulture]
exclude = ["tests"]
Expand Down
3 changes: 2 additions & 1 deletion src/umlizer/class_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def _get_dataclass_structure(
klass: Type[Any],
) -> ClassDef:
fields = {
k: v.type.__name__ for k, v in klass.__dataclass_fields__.items()
k: getattr(v.type, '__name__', 'Any')
for k, v in klass.__dataclass_fields__.items()
}
return ClassDef(
name='',
Expand Down
26 changes: 26 additions & 0 deletions src/umlizer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import os
import subprocess

from pathlib import Path

Expand All @@ -16,6 +17,29 @@
app = typer.Typer()


def dot2svg(target: Path) -> None:
"""
Run the `dot` command to convert a Graphviz file to SVG format.
Parameters
----------
target : str
The target Graphviz file to be converted.
"""
command = f'dot -Tsvg {target} -o {target}.svg'
try:
result = subprocess.run(
command,
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
print(result.stdout.decode())
except subprocess.CalledProcessError as e:
print(f'Error occurred: {e.stderr.decode()}')


def make_absolute(relative_path: Path) -> Path:
"""
Convert a relative Path to absolute, relative to the current cwd.
Expand Down Expand Up @@ -97,6 +121,8 @@ def class_(
g.format = 'png'
g.render(target)

dot2svg(target)


if __name__ == '__main__':
app()

0 comments on commit 243fb52

Please sign in to comment.