1717]
1818
1919# Additional exclusion patterns.
20- ADDITIONAL_EXCLUDE_PATTERNS = [
20+ EXCLUDE_DIR_PATTERNS = [
2121 "build/*" ,
2222 "*/build/*" ,
2323 "*/ThirdParty/*" ,
2828 "*/__pycache__/*"
2929]
3030
31- def should_exclude (rel_dir ):
31+ EXLUDED_FILES = [
32+ "DiligentCore/ReleaseHistory.md" ,
33+ "DiligentSamples/ReleaseHistory.md"
34+ ]
35+
36+ def should_exclude_dir (rel_dir ):
3237 """
3338 Return True if the given relative directory (relative to the project root)
3439 should be excluded based on explicit directories, additional patterns,
@@ -43,12 +48,27 @@ def should_exclude(rel_dir):
4348 return True
4449
4550 # Check additional patterns.
46- for pattern in ADDITIONAL_EXCLUDE_PATTERNS :
51+ for pattern in EXCLUDE_DIR_PATTERNS :
4752 if fnmatch .fnmatch (norm_rel_dir , pattern ) or fnmatch .fnmatch (norm_rel_dir + '/' , pattern ):
4853 return True
4954
5055 return False
5156
57+ def should_exclude_file (rel_file ):
58+ """
59+ Return True if the given relative file (relative to the project root)
60+ should be excluded based on explicit files or additional patterns.
61+ """
62+ # Normalize to forward slashes.
63+ norm_rel_file = rel_file .replace (os .sep , '/' )
64+
65+ # Check explicit exclusions.
66+ for ex in EXLUDED_FILES :
67+ if norm_rel_file == ex :
68+ return True
69+
70+ return False
71+
5272def build_md_tree (root_dir , rel_dir = "" ):
5373 """
5474 Recursively build a tree structure starting at root_dir.
@@ -67,7 +87,7 @@ def build_md_tree(root_dir, rel_dir=""):
6787 current_path = os .path .join (root_dir , rel_dir )
6888
6989 # Skip if the current relative directory should be excluded.
70- if rel_dir and should_exclude (rel_dir ):
90+ if rel_dir and should_exclude_dir (rel_dir ):
7191 return None
7292
7393 try :
@@ -81,7 +101,9 @@ def build_md_tree(root_dir, rel_dir=""):
81101 for entry in entries :
82102 full_path = os .path .join (current_path , entry )
83103 if os .path .isfile (full_path ) and entry .lower ().endswith ('.md' ):
84- files .append (entry )
104+ child_rel = os .path .join (rel_dir , entry ) if rel_dir else entry
105+ if not should_exclude_file (child_rel ):
106+ files .append (entry )
85107 elif os .path .isdir (full_path ):
86108 subdirs .append (entry )
87109
0 commit comments