Optimations for makefile and iframes

This commit is contained in:
2025-03-20 12:37:41 +01:00
parent 6680f64e50
commit 6868b0d8ba
9 changed files with 31 additions and 18 deletions

View File

@@ -29,8 +29,8 @@ def add_local_file_headings(app, pagename, templatename, context, doctree):
files = [f for f in os.listdir(abs_dir) if f.endswith('.md') or f.endswith('.rst')]
# If an index file is present, remove any readme files (case-insensitive).
files_lower = [f.lower() for f in files]
if 'index.md' in files_lower or 'index.rst' in files_lower:
files = [f for f in files if f.lower() not in ['readme.md', 'readme.rst']]
if 'index.rst' in files_lower:
files = [f for f in files if f.lower() not in ['readme.md']]
file_items = []
for file in files:

View File

@@ -4,6 +4,8 @@ from .nav_utils import extract_headings_from_file, MAX_HEADING_LEVEL
logger = logging.getLogger(__name__)
CANDIDATES = ['index.rst', 'readme.md', 'main.rst']
def collect_folder_tree(dir_path, base_url):
"""
Recursively collects the folder tree starting from the given directory.
@@ -28,7 +30,7 @@ def collect_folder_tree(dir_path, base_url):
# Find representative file for folder title using index or readme
rep_file = None
for candidate in ['index.rst', 'index.md', 'readme.md', 'readme.rst']:
for candidate in CANDIDATES:
for f in files:
if f.lower() == candidate:
rep_file = f
@@ -48,7 +50,7 @@ def collect_folder_tree(dir_path, base_url):
# Remove the representative file from the list to avoid duplication,
# and filter out any additional "readme.md" or "index.rst" files.
files.remove(rep_file)
files = [f for f in files if f.lower() not in ['readme.md', 'index.rst']]
files = [f for f in files if f.lower() not in CANDIDATES]
# Process the remaining files in the current directory
file_items = []