From dce9e69a35bdc991e0c902fd5b21e4376e02471e Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 11 Nov 2020 10:52:15 +0100 Subject: [PATCH] scripts: Improve update-toc --- Makefile | 2 +- scripts/update-toc | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b560bfd..02f6544 100755 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ tocupdate: while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r docs ; do \ sleep 0.2 ; \ make images ; \ - pipenv run ./scripts/update-toc ; \ + pipenv run ./scripts/update-toc $(DOCS_DIR) ; \ done $(BUILD_SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.md diff --git a/scripts/update-toc b/scripts/update-toc index e8c6f35..67c1da9 100755 --- a/scripts/update-toc +++ b/scripts/update-toc @@ -32,6 +32,7 @@ class TocBuilder: md_files = [] for root, dirs, files in os.walk(self.root_path): for fn in files: + print("Found {}".format(fn)) # compute absolute and relative path abs_path = os.path.join(root, fn) rel_path = os.path.relpath(abs_path, self.root_path) @@ -50,8 +51,10 @@ class TocBuilder: continue # keep only .md files + print("* keeping {}".format(rel_path)) if bname_split[1] == '.md': md_files.append(rel_path) + return md_files def format(self, md_files): @@ -115,9 +118,10 @@ class FileInjector: # save part before @click.command() -def build(): +@click.argument('docs_directory') +def build(docs_directory): root_path = Path(__file__).parent.parent - toc = TocBuilder(str(root_path / 'docs')) + toc = TocBuilder(docs_directory) md_files = toc.lookup() md_toc = toc.format(md_files) fi = FileInjector('MKDOCS-TOC')