from pathlib import Path MARKDOWN_SUFFIXES = {".md", ".markdown"} def load_project_description(path: Path) -> str: if path.suffix.lower() not in MARKDOWN_SUFFIXES: raise ValueError(f"Project description must be a Markdown file: {path}") try: description = path.read_text(encoding="utf-8").strip() except OSError as error: raise ValueError(f"Could not read project description: {path}") from error if not description: raise ValueError(f"Project description is empty: {path}") return description