33import sys
44from pathlib import Path
55
6- DOCS_ROOT = Path (__file__ ).parent .parent .parent / 'comfyui_embedded_docs' / 'docs'
6+ # Try to find the docs directory relative to the script location first
7+ # If that fails, try relative to current working directory
8+ script_based_docs = Path (__file__ ).parent .parent .parent / 'comfyui_embedded_docs' / 'docs'
9+ cwd_based_docs = Path .cwd () / 'comfyui_embedded_docs' / 'docs'
10+
11+ if script_based_docs .exists ():
12+ DOCS_ROOT = script_based_docs
13+ elif cwd_based_docs .exists ():
14+ DOCS_ROOT = cwd_based_docs
15+ else :
16+ # Fallback: search for the docs directory
17+ current = Path .cwd ()
18+ while current != current .parent : # Stop at filesystem root
19+ potential_docs = current / 'comfyui_embedded_docs' / 'docs'
20+ if potential_docs .exists ():
21+ DOCS_ROOT = potential_docs
22+ break
23+ current = current .parent
24+ else :
25+ DOCS_ROOT = script_based_docs # Default to original logic
726
827# Supported file extensions
928doc_exts = {'.md' , '.mdx' }
@@ -30,6 +49,12 @@ def find_links_in_line(line):
3049 return links
3150
3251def check_links ():
52+ if not DOCS_ROOT .exists ():
53+ print (f"ERROR: DOCS_ROOT directory does not exist: { DOCS_ROOT } " )
54+ print (f"Current working directory: { os .getcwd ()} " )
55+ print (f"Script location: { Path (__file__ )} " )
56+ sys .exit (1 )
57+
3358 errors = []
3459 for root , _ , files in os .walk (DOCS_ROOT ):
3560 for fname in files :
0 commit comments