@@ -140,6 +140,11 @@ def find_xls_documents(root_dir: Path) -> List[XLSDocument]:
140140 for folder in xls_folders :
141141 readme_path = folder / "README.md"
142142 if readme_path .exists ():
143+ # Skip symlinked README files
144+ if readme_path .is_symlink ():
145+ print (f"Skipping symlinked document: { folder .name } " )
146+ continue
147+
143148 try :
144149 with open (readme_path , "r" , encoding = "utf-8" ) as f :
145150 content = f .read ()
@@ -158,6 +163,48 @@ def find_xls_documents(root_dir: Path) -> List[XLSDocument]:
158163 return xls_docs
159164
160165
166+ def validate_symlinks (root_dir : Path ) -> bool :
167+ """Validate that all symlinked XLS documents point to correct targets.
168+
169+ Args:
170+ root_dir: Root directory containing XLS folders
171+
172+ Returns:
173+ True if all symlinks are valid, False otherwise
174+ """
175+ symlink_errors = []
176+ xls_folders = [
177+ d for d in root_dir .iterdir () if d .is_dir () and d .name .startswith ("XLS-" )
178+ ]
179+
180+ for folder in xls_folders :
181+ readme_path = folder / "README.md"
182+ if readme_path .exists () and readme_path .is_symlink ():
183+ # Extract XLS numbers from folder names
184+ source_match = re .match (r"XLS-(\d+)([d]?)" , folder .name )
185+ if source_match :
186+ number = source_match .group (1 )
187+ suffix = source_match .group (2 )
188+
189+ if suffix == "d" :
190+ # This is a "d" version that should point to the non-d version
191+ target = str (readme_path .resolve ())
192+ # The symlink should resolve to the non-d version
193+ # Check if target contains the XLS number but not the "d" suffix
194+ if f"XLS-{ number } -" in target and f"XLS-{ number } d-" not in target :
195+ print (f"Validated symlink: { folder .name } -> correct target" )
196+ else :
197+ symlink_errors .append (
198+ f"Error: { folder .name } /README.md symlink points to wrong target"
199+ )
200+
201+ if symlink_errors :
202+ for error in symlink_errors :
203+ print (error )
204+ return False
205+ return True
206+
207+
161208def validate_xls_documents (root_dir : Path ) -> bool :
162209 """Validate that all XLS documents can be parsed correctly.
163210
@@ -168,6 +215,11 @@ def validate_xls_documents(root_dir: Path) -> bool:
168215 True if all documents parse successfully, False otherwise
169216 """
170217 try :
218+ # First validate symlinks
219+ if not validate_symlinks (root_dir ):
220+ print ("Symlink validation failed" )
221+ return False
222+
171223 docs = find_xls_documents (root_dir )
172224
173225 # Basic validation checks
0 commit comments