Skip to content

Commit 8c99fcc

Browse files
committedSep 16, 2024·
Fold directories to hide contents if they have too many files
1 parent 0dd5ea6 commit 8c99fcc

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed
 

‎create_requirement_images.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def make_line(
163163
)
164164

165165
def make_header(position, project_files, files_and_libs):
166-
# pylint: disable=too-many-locals
166+
# pylint: disable=too-many-locals, too-many-branches
167167
# Static files
168168
make_line(
169169
"CIRCUITPY",
@@ -198,8 +198,7 @@ def make_header(position, project_files, files_and_libs):
198198
icon=file_icon,
199199
)
200200

201-
# TODO: Add settings.toml if it's needed
202-
201+
# Add settings.toml if it's needed
203202
if settings_required(files_and_libs):
204203
make_line(
205204
"settings.toml",
@@ -247,6 +246,10 @@ def make_header(position, project_files, files_and_libs):
247246

248247
extra_rows = 0
249248
for i, file in enumerate(sorted(project_folders_to_draw.keys())):
249+
if len(project_folders_to_draw[file]) > 0:
250+
triangle_to_use = down_triangle
251+
else:
252+
triangle_to_use = right_triangle
250253
make_line(
251254
file,
252255
(
@@ -257,7 +260,7 @@ def make_header(position, project_files, files_and_libs):
257260
* (begin_y_offset + i + len(project_files_to_draw) + extra_rows)
258261
),
259262
),
260-
triangle_icon=down_triangle,
263+
triangle_icon=triangle_to_use,
261264
)
262265
rows_added += 1
263266
for sub_file in sorted(project_folders_to_draw[file]):

‎get_imports.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
BUNDLE_DATA = "latest_bundle_data.json"
1717
BUNDLE_TAG = "latest_bundle_tag.json"
1818

19+
SUBDIRECTORY_FILECOUNT_LIMIT = 10
20+
1921
LEARN_GUIDE_REPO = os.environ.get(
2022
"LEARN_GUIDE_REPO", "../Adafruit_Learning_System_Guides/"
2123
)
@@ -141,8 +143,9 @@ def get_files_for_project(project_name):
141143
if cur_tuple[0].split("/")[-1] == _dir:
142144
for _sub_dir in cur_tuple[1]:
143145
dir_tuple = (dir_tuple[0], dir_tuple[1] + (_sub_dir,))
144-
for _sub_file in cur_tuple[2]:
145-
dir_tuple = (dir_tuple[0], dir_tuple[1] + (_sub_file,))
146+
if len(cur_tuple[2]) < SUBDIRECTORY_FILECOUNT_LIMIT:
147+
for _sub_file in cur_tuple[2]:
148+
dir_tuple = (dir_tuple[0], dir_tuple[1] + (_sub_file,))
146149

147150
# e.g. ("dir_name", ("file_1.txt", "file_2.txt"))
148151
found_files.add(dir_tuple)

0 commit comments

Comments
 (0)
Please sign in to comment.