-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from Bananapus/repo-layout-script
add repo layout script for writing READMEs
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |