From e70c6e8331a84af21955ec8c2589b143c7154663 Mon Sep 17 00:00:00 2001 From: matchy233 Date: Wed, 10 Jul 2024 16:07:49 -0400 Subject: [PATCH] fix(toc): pytoc correctly handles empty subdir --- scripts/autogen-toc.py | 4 ++++ src/23fs/mham/mobile_health_and_activity_monitoring.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/autogen-toc.py b/scripts/autogen-toc.py index 0c8fbb2..44573bf 100644 --- a/scripts/autogen-toc.py +++ b/scripts/autogen-toc.py @@ -71,6 +71,7 @@ def titlize(word, fname): def generate_toc(dir, sub_dir): toc = "" + main_file = "" for file in os.listdir(os.path.join(dir, sub_dir)): if file[0].isdigit(): fname = [x for x in file[2:].replace('.md', '').split('_') if x] @@ -83,6 +84,9 @@ def generate_toc(dir, sub_dir): main_file = file else: continue + # do nothing if main_file is not found (i.e. no file needs TOC) + if main_file == "": + return main_file_path = os.path.join(dir, sub_dir, main_file) with open(main_file_path, "r") as f: content = f.read() diff --git a/src/23fs/mham/mobile_health_and_activity_monitoring.md b/src/23fs/mham/mobile_health_and_activity_monitoring.md index 4708f83..c0afc78 100644 --- a/src/23fs/mham/mobile_health_and_activity_monitoring.md +++ b/src/23fs/mham/mobile_health_and_activity_monitoring.md @@ -1 +1 @@ -# Mobile Health and Activity Monitoring +# Mobile Health and Activity Monitoring