Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tools/score_report_doc_quality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from pathlib import Path
import sys

SCORING_SECTIONS = {
"## Purpose": 25,
"## Starter Mapping": 25,
"## Future Opportunities": 25,
"## Conclusion": 25,
}


def calculate_score(file_path: Path) -> int:
if not file_path.exists():
print(f"Fail. File not found: {file_path}")
return 0

content = file_path.read_text(encoding="utf-8")
lines = [
line.strip().rstrip("#").strip()
for line in content.splitlines()
]
score = 0

for section, points in SCORING_SECTIONS.items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse headings instead of exact stripped-line equality

The section check uses exact string equality (if section in lines), so valid Markdown ATX headings with optional closing hashes (for example, ## Purpose ##) are scored as missing even when all required sections are present. This produces false negatives and causes the CLI to return a non-zero exit code for compliant documents whenever authors use alternate-but-valid heading syntax.

Useful? React with 👍 / 👎.

if section in lines:
score += points
print(f"Pass. Found {section} (+{points})")
else:
print(f"Miss. Missing {section} (+0)")

print(f"\nDocumentation Score: {score}/100")
return score


def main() -> int:
if len(sys.argv) != 2:
print("Usage: python tools/score_report_doc_quality.py <markdown-file-path>")
return 1

score = calculate_score(Path(sys.argv[1]))

return 0 if score == 100 else 1


if __name__ == "__main__":
raise SystemExit(main())
Loading