33
44# Mapping section titles to their corresponding filenames
55SECTION_MAPPING = {
6- "" : "home_page.md" ,
6+ "" : "home_page.md" ,
77 "About the project" : "about.md" ,
88 "Installation" : "installation.md" ,
99 "Execution" : "execution.md" ,
@@ -84,7 +84,7 @@ def clean_trailing_links(content):
8484
8585
8686def process_readme (readme_path , output_dir ):
87- readme = Path (readme_path ).read_text ()
87+ readme = Path (readme_path ).read_text (encoding = "utf-8" )
8888
8989 # Extract links from README
9090 links = extract_links_from_readme (readme )
@@ -104,11 +104,11 @@ def process_readme(readme_path, output_dir):
104104 (output_dir / filename ).write_text (myst_content )
105105 print (f"Generated { filename } " )
106106 else :
107- print (f"Warning: Section '{ section_title } ' not found in README" )
107+ raise ValueError (f"Section '{ section_title } ' not found in README" )
108108
109109 # Include CONTRIBUTING.md with its own link references
110110 contrib_path = readme_path .parent / "CONTRIBUTING.md"
111- if contrib_path . exists () :
111+ try :
112112 raw_contrib = contrib_path .read_text ()
113113 contrib_links = extract_links_from_readme (raw_contrib )
114114
@@ -121,8 +121,8 @@ def process_readme(readme_path, output_dir):
121121 # Write output
122122 (output_dir / "contributing.md" ).write_text (contrib_converted )
123123 print ("Generated contributing.md" )
124- else :
125- print ( "Warning: CONTRIBUTING.md not found" )
124+ except FileNotFoundError as e :
125+ raise FileNotFoundError ( f" CONTRIBUTING.md not found at { contrib_path } " ) from e
126126
127127
128128if __name__ == "__main__" :
0 commit comments