forked from RockefellerArchiveCenter/rac_schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_docs.py
30 lines (22 loc) · 1000 Bytes
/
generate_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Generates HTML documentation from JSONSchema files.
Assumes JSONSchema files are located in a directory named `/rac_schemas/schemas`.
HTML documentation will be created in a directory called `/docs`.
This script requires the Python package [json_schema_for_humans](https://pypi.org/project/json-schema-for-humans/).
"""
import os
from pathlib import Path
from json_schema_for_humans.generate import generate_from_filename
def main():
project_directory = Path(__file__).parent.absolute()
json_directory = os.path.join(
project_directory, "rac_schemas", "schemas")
html_directory = os.path.join(project_directory, "docs")
for schema in [f for f in os.listdir(
json_directory) if f.endswith(".json")]:
html_file = "{}.html".format(schema.split(".")[0])
generate_from_filename(
os.path.join(
json_directory, schema), os.path.join(
html_directory, html_file))
if __name__ == "__main__":
main()