doc: improve update-toc output

This commit is contained in:
Glenn Y. Rolland 2021-06-27 21:34:12 +02:00
parent afad220f09
commit 1e7c0ed279

View file

@ -31,6 +31,7 @@ class TocBuilder:
def is_masked(self, rel_path): def is_masked(self, rel_path):
parts = rel_path.split('/')[::-1] parts = rel_path.split('/')[::-1]
for part in parts: for part in parts:
# print(" * Testing for '_' {}".format(part))
if part[0] == '_': if part[0] == '_':
return True return True
@ -40,7 +41,7 @@ class TocBuilder:
md_files = [] md_files = []
for root, dirs, files in os.walk(self.root_path): for root, dirs, files in os.walk(self.root_path):
for fn in files: for fn in files:
print("Found {}".format(fn)) print("Found {}".format(fn), end='\r')
# compute absolute and relative path # compute absolute and relative path
abs_path = os.path.join(root, fn) abs_path = os.path.join(root, fn)
rel_path = os.path.relpath(abs_path, self.root_path) rel_path = os.path.relpath(abs_path, self.root_path)
@ -50,17 +51,19 @@ class TocBuilder:
bname_split = os.path.splitext(bname) bname_split = os.path.splitext(bname)
dname = os.path.dirname(rel_path) dname = os.path.dirname(rel_path)
# skip files in docs/ root
if dname == "":
continue
# skip files starting with '_' # skip files starting with '_'
#if bname_split[0][0] == '_': #if bname_split[0][0] == '_':
if self.is_masked(rel_path): if self.is_masked(rel_path):
print("Found {} which is masked. Ignoring".format(fn))
continue continue
# skip files in docs/ root
# if dname == "":
# continue
# skip index files # skip index files
if bname_split[0] == 'index': if bname_split[0] == 'index':
print("Found {} which is an index file. Ignoring".format(fn))
continue continue
# keep only .md files # keep only .md files
@ -68,6 +71,8 @@ class TocBuilder:
if bname_split[1] == '.md': if bname_split[1] == '.md':
md_files.append(rel_path) md_files.append(rel_path)
print("Found {}. Keeping".format(fn))
return md_files return md_files
def format(self, md_files): def format(self, md_files):