-
Notifications
You must be signed in to change notification settings - Fork 2
/
doc.py
30 lines (26 loc) · 931 Bytes
/
doc.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
#conding=utf8
import os
ignoreList = ['out', 'bin', 'README.md', 'img', 'target']
output = []
def fileTree(dir, depth):
if depth > 1:
return;
entries = os.scandir(dir)
for entry in entries:
name = entry.name
if (name not in ignoreList) and (entry.is_dir() and not name.startswith('.')):
output.append(render(depth, entry.name, dir))
if entry.is_dir() and (not name.startswith('.')):
fileTree(entry, depth+1)
def tab(depth):
return ' ' * depth;
def render(depth, name, dir):
if depth > 0:
return tab(depth) + "- [{}](https://github.com/linsheng9731/notebook/tree/master/{}/{})".format(name, dir.name, name)
else:
return tab(depth) + "- [{}](https://github.com/linsheng9731/notebook/tree/master/{})".format(name, name)
fileTree('./', 0)
fo = open("README.md", "w")
fo.write("# Catalog\n")
for e in output:
fo.write(e + "\n")