@@ -59,7 +59,7 @@ def _setup_output_directories(base_dir):
5959 return build_dir , dist_dir
6060
6161
62- def _resolve_document_paths (base_dir , documents ):
62+ def _get_document_paths (base_dir , documents ):
6363 """Resolve document paths to absolute paths."""
6464 document_paths = {}
6565
@@ -77,23 +77,20 @@ def _resolve_document_paths(base_dir, documents):
7777 return document_paths
7878
7979
80- def _validate_document (doc_name , doc_path ):
80+ def _validate_document_path (doc_name , doc_path ):
8181 """Validate that a document has all required files."""
8282 if not doc_path .is_dir ():
83- print (
84- f'Warning: Directory missing for document "{ doc_name } " '
85- f"at { doc_path } - skipping"
86- )
83+ print (f'Warning: Directory missing for document "{ doc_name } " ' f"at { doc_path } " )
8784 return False
8885
8986 bake_path = doc_path / "bake.py"
9087 if not bake_path .exists ():
91- print (f'Warning: bake.py missing for document "{ doc_name } " - skipping ' )
88+ print (f'Warning: bake.py missing for document "{ doc_name } "' )
9289 return False
9390
9491 config_yml_path = doc_path / "config.yml"
9592 if not config_yml_path .exists ():
96- print (f'Warning: config.yml missing for document "{ doc_name } " - skipping ' )
93+ print (f'Warning: config.yml missing for document "{ doc_name } "' )
9794 return False
9895
9996 return bake_path , config_yml_path
@@ -109,14 +106,13 @@ def _load_document_bake_module(doc_name, bake_path):
109106 return module
110107
111108
112- def _setup_document_directories (build_dir , dist_dir , doc_name ):
109+ def _setup_document_output_directories (build_dir , dist_dir , doc_name ):
113110 """Set up and clean document-specific build and dist directories."""
114111 doc_build_dir = build_dir / doc_name
115112 doc_dist_dir = dist_dir / doc_name
116113 os .makedirs (doc_build_dir , exist_ok = True )
117114 os .makedirs (doc_dist_dir , exist_ok = True )
118115
119- # Clean document-specific output directories
120116 for dir_path in [doc_build_dir , doc_dist_dir ]:
121117 for file in os .listdir (dir_path ):
122118 file_path = dir_path / file
@@ -128,8 +124,9 @@ def _setup_document_directories(build_dir, dist_dir, doc_name):
128124
129125def _process_document (doc_name , doc_path , config , build_dir , dist_dir ):
130126 """Process an individual document."""
131- validation_result = _validate_document (doc_name , doc_path )
127+ validation_result = _validate_document_path (doc_name , doc_path )
132128 if not validation_result :
129+ print (f'Warning: Document "{ doc_name } " at { doc_path } is invalid - skipping' )
133130 return
134131
135132 print (f'Processing document "{ doc_name } " from { doc_path } ...' )
@@ -138,7 +135,7 @@ def _process_document(doc_name, doc_path, config, build_dir, dist_dir):
138135 with open (config_yml_path , encoding = "utf-8" ) as f :
139136 doc_config = yaml .safe_load (f )
140137
141- doc_build_dir , doc_dist_dir = _setup_document_directories (
138+ doc_build_dir , doc_dist_dir = _setup_document_output_directories (
142139 build_dir , dist_dir , doc_name
143140 )
144141 paths = {
@@ -164,16 +161,14 @@ def main(config_path=None):
164161 return 1
165162
166163 config = _load_config (config_path )
167-
168164 base_dir = config_path .parent
165+ document_paths = _get_document_paths (base_dir , config .get ("documents" , []))
169166 build_dir , dist_dir = _setup_output_directories (base_dir )
170167
171- documents = config .get ("documents" , [])
172- document_paths = _resolve_document_paths (base_dir , documents )
173-
174168 for doc_name , doc_path in document_paths .items ():
175169 _process_document (doc_name , doc_path , config , build_dir , dist_dir )
176170
171+ print ("Done." )
177172 return 0
178173
179174
0 commit comments