forked from ir-engine/ir-engine-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexportToMdTree.py
38 lines (33 loc) · 1.08 KB
/
exportToMdTree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import os
from directory_tree import DisplayTree
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
dirs.sort()
level = root.replace(startpath, '').count(os.sep)
if(level == 0):
continue
indent = ' ' * 2 * (level - 1)
basename = os.path.basename(root)
relpath = os.path.relpath(root, start=startpath)
if "d_" in root:
continue
if not os.path.exists(root+"/index.md"):
continue
print('{}- [{}]({}/index.md) '.format(indent, basename, relpath, basename))
subindent = ' ' * 2 * (level)
files.sort()
for f in files:
if "d_" == f[:2]:
continue
if "index.md" in f:
continue
if ".md" not in f:
continue
print('{}- [{}]({}/{}) '.format(subindent, f, relpath, f))
def main() -> int:
# print("Any Header content\n")
list_files('./docs')
return 0
if __name__ == '__main__':
sys.exit(main()) # next section explains the use of sys.exit