Skip to content

Commit 892558a

Browse files
committed
Create a prepublish script to fix the graph on PyPI
1 parent e7f6c69 commit 892558a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ jobs:
2424
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2525
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2626
run: |
27+
python prepublish.py
2728
python setup.py sdist bdist_wheel
2829
twine upload dist/*

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ master ]
66
pull_request:
7-
branches: [ master, tests ]
7+
branches: [ master ]
88

99
jobs:
1010
test:

prepublish.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import re
2+
3+
if __name__ == "__main__":
4+
mermaid_snippet_pattern = r"^```mermaid[\s\S]+?```"
5+
mermaid_snippet_svg_url = (
6+
# Initially was uploaded to GitHub
7+
"https://user-images.githubusercontent.com/44609997/"
8+
"205437148-4fb3d7bd-1fe9-4ce8-8321-d7aef9488e37.svg"
9+
)
10+
html_replacement = "<p align=\"center\"><img src=\"%s\" height=\"400\" /></p>" % mermaid_snippet_svg_url
11+
with open("README.md", "r") as fp:
12+
readme = fp.read()
13+
readme = re.sub(mermaid_snippet_pattern, html_replacement, readme, flags=re.M)
14+
15+
with open("README.md", "w") as fp:
16+
fp.write(readme)

0 commit comments

Comments
 (0)