Skip to content

Commit

Permalink
Use schema title in file link
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Dec 7, 2023
1 parent 4886550 commit afcf31c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tools/github_pages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from pathlib import Path


Expand All @@ -18,23 +19,24 @@ def main():
<h2><a href="htmlcov/index.html">Coverage report</a></h2>
<h2>JSON schema</h2>
<ul>
<schema_list>
</ul>
</body>
</html>
"""

json_schemas = [
path.name
schema_paths = [
path
for path in Path("_site").iterdir()
if path.is_file() and path.suffix == ".json"
]
json_schemas.sort()
for schema in json_schemas:
html += f"<li><a href='{schema}'>{schema}</a></li>"

html += """
</ul>
</body>
</html>
"""

schema_paths.sort(key=lambda p: p.name)
schema_list_html = ""
for schema_path in schema_paths:
with schema_path.open(encoding="utf-8") as f:
schema_data = json.load(f)
schema_list_html += f"<li><a href='{schema_path.name}'>{schema_data.get('title')}</a></li>"
html = html.replace("<schema_list>", schema_list_html)
with open("_site/index.html", "w", encoding="utf-8") as f:
f.write(html)

Expand Down

0 comments on commit afcf31c

Please sign in to comment.