From 958246a8e63b3c271d642993071ef7e4e57e3563 Mon Sep 17 00:00:00 2001 From: ouhammou rachid <93659459+ouhammmourachid@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:47:27 +0100 Subject: [PATCH 1/2] Add new diagram types to README.md (#195) * Add new diagram types to README.md * Refactor configuration and style classes to use string concatenation instead of multiple if statements --- README.md | 2 ++ mermaid/configuration.py | 26 ++++++++++++++------------ mermaid/reqdiagram/requirement.py | 18 ++++++++++-------- mermaid/style.py | 24 +++++++++++++----------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index b62c9da..87ac4cf 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,8 @@ diagram - [ ] [Sankey](https://mermaid.js.org/syntax/sankey.html) - [ ] [XYChart 🔥](https://mermaid.js.org/syntax/xyChart.html) - [ ] [Block Diagram 🔥](https://mermaid.js.org/syntax/block.html) +- [ ] [Packet 🔥](https://mermaid.js.org/syntax/packet.html) +- [ ] [Architecture 🔥](https://mermaid.js.org/syntax/architecture.html) ## License diff --git a/mermaid/configuration.py b/mermaid/configuration.py index 7da6b47..954a56c 100644 --- a/mermaid/configuration.py +++ b/mermaid/configuration.py @@ -74,18 +74,20 @@ def __str__(self) -> str: string: str = "%%{\n\tinit: {\n" string += f'\t\t"theme": "{self.theme.value}",\n\t\t"themeVariables": ' + "{\n" - if self.primary_color: - string += f'\t\t\t"primaryColor": "{self.primary_color}",\n' - if self.primary_text_color: - string += f'\t\t\t"primaryTextColor": "{self.primary_text_color}",\n' - if self.primary_border_color: - string += f'\t\t\t"primaryBorderColor": "{self.primary_border_color}",\n' - if self.line_color: - string += f'\t\t\t"lineColor": "{self.line_color}",\n' - if self.secondary_color: - string += f'\t\t\t"secondaryColor": "{self.secondary_color}",\n' - if self.tertiary_color: - string += f'\t\t\t"tertiaryColor": "{self.tertiary_color}",\n' + string += "".join( + [ + f'\t\t\t"{style}": "{value}",\n' + for style, value in [ + ("primaryColor", self.primary_color), + ("primaryTextColor", self.primary_text_color), + ("primaryBorderColor", self.primary_border_color), + ("lineColor", self.line_color), + ("secondaryColor", self.secondary_color), + ("tertiaryColor", self.tertiary_color), + ] + if value + ] + ) if string.endswith(",\n"): string = string[:-2] + "\n" string += "\t\t}\n" diff --git a/mermaid/reqdiagram/requirement.py b/mermaid/reqdiagram/requirement.py index f51b702..eb7d092 100644 --- a/mermaid/reqdiagram/requirement.py +++ b/mermaid/reqdiagram/requirement.py @@ -83,11 +83,13 @@ def __init__( ) def __str__(self) -> str: - string: str = "" - string += f"{self.type_} {self.name} {{\n" - string += f"\tid: {self.id_}\n" - string += f"\ttext: {self.text}\n" - string += f"\trisk: {self.risk}\n" - string += f"\tverifymethod: {self.verifymethod}\n" - string += "}\n" - return string + return "".join( + [ + f"{self.type_} {self.name} {{\n", + f"\tid: {self.id_}\n", + f"\ttext: {self.text}\n", + f"\trisk: {self.risk}\n", + f"\tverifymethod: {self.verifymethod}\n", + "}\n", + ] + ) diff --git a/mermaid/style.py b/mermaid/style.py index ed07f31..a0166bd 100644 --- a/mermaid/style.py +++ b/mermaid/style.py @@ -29,19 +29,21 @@ class Style: def __str__(self) -> str: """Return the string representation of the style definition.""" string: str = f"classDef {self.name} " - if self.fill: - string += f",fill:{self.fill}" - if self.color: - string += f",color:{self.color}" - if self.font_weight: - string += f",font-weight:{self.font_weight}" - if self.stroke_width: - string += f",stroke-width:{self.stroke_width}" - if self.stroke: - string += f",stroke:{self.stroke}" + string += "".join( + [ + f",{style}:{value}" + for style, value in [ + ("fill", self.fill), + ("color", self.color), + ("font-weight", self.font_weight), + ("stroke-width", self.stroke_width), + ("stroke", self.stroke), + ] + if value is not None + ] + ) if self.other: string += f",{self.other}" - return string def __hash__(self) -> int: From 9a5c87289daa313438a7926b8c70c5d717c68680 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:51:45 +0100 Subject: [PATCH 2/2] chore(deps-dev): bump ruff from 0.6.2 to 0.6.7 (#194) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.2 to 0.6.7. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.2...0.6.7) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ouhammou rachid <93659459+ouhammmourachid@users.noreply.github.com> --- poetry.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9ee41d7..6aed080 100644 --- a/poetry.lock +++ b/poetry.lock @@ -507,29 +507,29 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.6.2" +version = "0.6.7" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.6.2-py3-none-linux_armv6l.whl", hash = "sha256:5c8cbc6252deb3ea840ad6a20b0f8583caab0c5ef4f9cca21adc5a92b8f79f3c"}, - {file = "ruff-0.6.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:17002fe241e76544448a8e1e6118abecbe8cd10cf68fde635dad480dba594570"}, - {file = "ruff-0.6.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3dbeac76ed13456f8158b8f4fe087bf87882e645c8e8b606dd17b0b66c2c1158"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:094600ee88cda325988d3f54e3588c46de5c18dae09d683ace278b11f9d4d534"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:316d418fe258c036ba05fbf7dfc1f7d3d4096db63431546163b472285668132b"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d72b8b3abf8a2d51b7b9944a41307d2f442558ccb3859bbd87e6ae9be1694a5d"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2aed7e243be68487aa8982e91c6e260982d00da3f38955873aecd5a9204b1d66"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d371f7fc9cec83497fe7cf5eaf5b76e22a8efce463de5f775a1826197feb9df8"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8f310d63af08f583363dfb844ba8f9417b558199c58a5999215082036d795a1"}, - {file = "ruff-0.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7db6880c53c56addb8638fe444818183385ec85eeada1d48fc5abe045301b2f1"}, - {file = "ruff-0.6.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1175d39faadd9a50718f478d23bfc1d4da5743f1ab56af81a2b6caf0a2394f23"}, - {file = "ruff-0.6.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5b939f9c86d51635fe486585389f54582f0d65b8238e08c327c1534844b3bb9a"}, - {file = "ruff-0.6.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d0d62ca91219f906caf9b187dea50d17353f15ec9bb15aae4a606cd697b49b4c"}, - {file = "ruff-0.6.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7438a7288f9d67ed3c8ce4d059e67f7ed65e9fe3aa2ab6f5b4b3610e57e3cb56"}, - {file = "ruff-0.6.2-py3-none-win32.whl", hash = "sha256:279d5f7d86696df5f9549b56b9b6a7f6c72961b619022b5b7999b15db392a4da"}, - {file = "ruff-0.6.2-py3-none-win_amd64.whl", hash = "sha256:d9f3469c7dd43cd22eb1c3fc16926fb8258d50cb1b216658a07be95dd117b0f2"}, - {file = "ruff-0.6.2-py3-none-win_arm64.whl", hash = "sha256:f28fcd2cd0e02bdf739297516d5643a945cc7caf09bd9bcb4d932540a5ea4fa9"}, - {file = "ruff-0.6.2.tar.gz", hash = "sha256:239ee6beb9e91feb8e0ec384204a763f36cb53fb895a1a364618c6abb076b3be"}, + {file = "ruff-0.6.7-py3-none-linux_armv6l.whl", hash = "sha256:08277b217534bfdcc2e1377f7f933e1c7957453e8a79764d004e44c40db923f2"}, + {file = "ruff-0.6.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:c6707a32e03b791f4448dc0dce24b636cbcdee4dd5607adc24e5ee73fd86c00a"}, + {file = "ruff-0.6.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:533d66b7774ef224e7cf91506a7dafcc9e8ec7c059263ec46629e54e7b1f90ab"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:17a86aac6f915932d259f7bec79173e356165518859f94649d8c50b81ff087e9"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b3f8822defd260ae2460ea3832b24d37d203c3577f48b055590a426a722d50ef"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9ba4efe5c6dbbb58be58dd83feedb83b5e95c00091bf09987b4baf510fee5c99"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:525201b77f94d2b54868f0cbe5edc018e64c22563da6c5c2e5c107a4e85c1c0d"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8854450839f339e1049fdbe15d875384242b8e85d5c6947bb2faad33c651020b"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2f0b62056246234d59cbf2ea66e84812dc9ec4540518e37553513392c171cb18"}, + {file = "ruff-0.6.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b1462fa56c832dc0cea5b4041cfc9c97813505d11cce74ebc6d1aae068de36b"}, + {file = "ruff-0.6.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:02b083770e4cdb1495ed313f5694c62808e71764ec6ee5db84eedd82fd32d8f5"}, + {file = "ruff-0.6.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c05fd37013de36dfa883a3854fae57b3113aaa8abf5dea79202675991d48624"}, + {file = "ruff-0.6.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f49c9caa28d9bbfac4a637ae10327b3db00f47d038f3fbb2195c4d682e925b14"}, + {file = "ruff-0.6.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a0e1655868164e114ba43a908fd2d64a271a23660195017c17691fb6355d59bb"}, + {file = "ruff-0.6.7-py3-none-win32.whl", hash = "sha256:a939ca435b49f6966a7dd64b765c9df16f1faed0ca3b6f16acdf7731969deb35"}, + {file = "ruff-0.6.7-py3-none-win_amd64.whl", hash = "sha256:590445eec5653f36248584579c06252ad2e110a5d1f32db5420de35fb0e1c977"}, + {file = "ruff-0.6.7-py3-none-win_arm64.whl", hash = "sha256:b28f0d5e2f771c1fe3c7a45d3f53916fc74a480698c4b5731f0bea61e52137c8"}, + {file = "ruff-0.6.7.tar.gz", hash = "sha256:44e52129d82266fa59b587e2cd74def5637b730a69c4542525dfdecfaae38bd5"}, ] [[package]]