Skip to content

Commit 603021b

Browse files
committed
✨ do not fail silently - fail build
- if a section is not found or contributing is missing, raise an error instead of continuing with a warning
1 parent 60f3ecf commit 603021b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/split_readme.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def clean_trailing_links(content):
8484

8585

8686
def 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

128128
if __name__ == "__main__":

0 commit comments

Comments
 (0)