Skip to content

Commit

Permalink
Merge pull request #153 from Bananapus/repo-layout-script
Browse files Browse the repository at this point in the history
add repo layout script for writing READMEs
  • Loading branch information
filipviz authored Jun 4, 2024
2 parents 036b7dd + 152bff9 commit d38d73e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils/repo-layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

ignored = [".git/", "node_modules/", ".env", "lib/", "broadcast/", "out/", "cache/"]

def generate_diagram(path: str, prefix=""):
contents = os.listdir(path)
contents.sort()
for index, content in enumerate(contents):
content_path = os.path.join(path, content)
if os.path.isdir(content_path):
content += "/" # Add trailing slash for directories
if index == len(contents) - 1:
connector = "└── "
new_prefix = prefix + " "
else:
connector = "├── "
new_prefix = prefix + "│ "

print(prefix + connector + content)
if os.path.isdir(content_path) and content not in ignored:
generate_diagram(content_path, new_prefix)

if __name__ == "__main__":
root_dir = "."
print(os.path.basename(os.path.abspath(root_dir)) + "/")
generate_diagram(root_dir)

0 comments on commit d38d73e

Please sign in to comment.