Skip to content

Commit

Permalink
Fix toc script
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlGao4 committed Aug 17, 2024
1 parent f43ff9d commit 5894292
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/generate-toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ jobs:
if: ${{ steps.generate-toc.outputs.continue_commit != 'false' }}
with:
commit-message: ${{ steps.generate-toc.outputs.commit_message }}

trigger-gh-pages-update:
needs: generate-instrument-toc
uses: ./.github/workflows/update-gh-page.yml
5 changes: 1 addition & 4 deletions .github/workflows/update-gh-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ on:
- "*.md"
- "*.py"
workflow_dispatch:
workflow_run:
workflows: ["Generate Instrument Table of Contents"]
types:
- completed
workflow_call:

concurrency:
group: ${{ github.workflow }}
Expand Down
7 changes: 5 additions & 2 deletions gh-actions-generate-toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
name = name.split(".", 1)[0]
if catagory not in instruments:
instruments[catagory] = {}
if catagory not in download_size:
download_size[catagory] = {}
if name not in instruments[catagory]:
instruments[catagory][name] = {}
if name not in download_size[catagory]:
Expand Down Expand Up @@ -142,8 +144,8 @@ def human_readable_size(size):
with open("instruments.md", mode="wt", encoding="utf-8") as f:
f.write(markdown)
# Find out what instrument changed to set commit message
old_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[(.*)\].*\r?\n( - .*\r?\n?)*)", old_markdown))
new_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[(.*)\].*\r?\n( - .*\r?\n?)*)", markdown))
old_markdown_insts = dict((i[1], i[2]) for i in re.findall(r"(- \[?([^\[\]`\r\n]+)\]?.*\r?\n( - .*\r?\n?)*)", old_markdown))
new_markdown_insts = dict((i[1], i[2]) for i in re.findall(r"(- \[?([^\[\]`\r\n]+)\]?.*\r?\n( - .*\r?\n?)*)", markdown))
added = set(new_markdown_insts.keys()) - set(old_markdown_insts.keys())
removed = set(old_markdown_insts.keys()) - set(new_markdown_insts.keys())
modified = {}
Expand All @@ -168,6 +170,7 @@ def human_readable_size(size):
message += " Removed: " + modified[i][0][j] + "\n"
elif modified[i][0][j] != modified[i][1][j]:
message += f" Renamed: {modified[i][0][j]} -> {modified[i][1][j]}\n"
message = message.replace("\_", "_").replace("\\\\", "\\")
print("-" * 80)
print("Commit message:")
print(message)
Expand Down

0 comments on commit 5894292

Please sign in to comment.