Skip to content

Commit

Permalink
Merge pull request #87 from UM-Bridge/fix-issue18
Browse files Browse the repository at this point in the history
check only one level 1 header
  • Loading branch information
annereinarz authored Jun 17, 2024
2 parents 0cf47bd + 88217d2 commit 23d062a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/test_benchmark_readmes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob
import marko
import re
from argparse import ArgumentParser

for filename in glob.glob('../benchmarks/*/README.md') + glob.glob('../models/*/README.md'):
Expand All @@ -22,6 +23,19 @@
del undefined_headings[heading_text]

print(f"Missing headings: {len(undefined_headings)} ({undefined_headings})")

h1_count = 0
errors = []
lines = test_file_content.splitlines()
for i, line in enumerate(lines):
if re.match(r'^# ', line):
h1_count += 1
if h1_count > 1:
errors.append(f"Line {i+1}: More than one H1 header found: {line.strip()}")

if errors:
print("\n".join(errors))

assert len(undefined_headings) == 0
print("Test passed!")
print("")

0 comments on commit 23d062a

Please sign in to comment.