Skip to content

Commit 0bd3409

Browse files
authored
Fix build_directory_md.py so it works again on Linux
Revert #1161 because it broke our output: https://travis-ci.org/TheAlgorithms/Python/builds/592863893#L805
1 parent 390feb0 commit 0bd3409

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/build_directory_md.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def good_filepaths(top_dir: str = ".") -> Iterator[str]:
1414
continue
1515
if os.path.splitext(filename)[1] in (".py", ".ipynb"):
1616
yield os.path.join(dirpath, filename).lstrip("./")
17-
17+
1818

1919
def md_prefix(i):
2020
return f"{i * ' '}*" if i else "##"
@@ -25,7 +25,7 @@ def print_path(old_path: str, new_path: str) -> str:
2525
for i, new_part in enumerate(new_path.split(os.sep)):
2626
if i + 1 > len(old_parts) or old_parts[i] != new_part:
2727
if new_part:
28-
print(f"{md_prefix(i-1)} {new_part.replace('_', ' ').title()}")
28+
print(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}")
2929
return new_path
3030

3131

@@ -36,7 +36,7 @@ def print_directory_md(top_dir: str = ".") -> None:
3636
if filepath != old_path:
3737
old_path = print_path(old_path, filepath)
3838
indent = (filepath.count(os.sep) + 1) if filepath else 0
39-
url = "/".join((URL_BASE, filepath.split(os.sep)[1], filename)).replace(" ", "%20")
39+
url = "/".join((URL_BASE, filepath, filename)).replace(" ", "%20")
4040
filename = os.path.splitext(filename.replace("_", " "))[0]
4141
print(f"{md_prefix(indent)} [{filename}]({url})")
4242

0 commit comments

Comments
 (0)