Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/update_directory_md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
from typing import Iterator
URL_BASE = "https://github.com/TheAlgorithms/Ruby/blob/master"
g_output = []

def good_filepaths(top_dir: str = ".") -> Iterator[str]:
for dirpath, dirnames, filenames in os.walk(top_dir):
dirnames[:] = [d for d in dirnames if d[0] not in "._"]
for filename in filenames:
if os.path.splitext(filename)[1].lower() == ".rb":
yield os.path.join(dirpath, filename).lstrip("./")

def md_prefix(i):
return f"{i * ' '}*" if i else "\n##"

def print_path(old_path: str, new_path: str) -> str:
global g_output
old_parts = old_path.split(os.sep)
Expand All @@ -32,7 +32,7 @@ jobs:
if new_part:
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}")
return new_path

def build_directory_md(top_dir: str = ".") -> str:
global g_output
old_path = ""
Expand All @@ -47,7 +47,7 @@ jobs:
return "\n".join(g_output)
with open("DIRECTORY.md", "w") as out_file:
out_file.write(build_directory_md(".") + "\n")

- name: Update DIRECTORY.md
run: |
cat DIRECTORY.md
Expand Down