Update the gendoc script to load the core event schema from

separate files.
pull/977/head
Mark Haines 9 years ago
parent 6147562d14
commit 2cf8da6b20

@ -283,17 +283,25 @@ class MatrixUnits(Units):
def load_common_event_fields(self): def load_common_event_fields(self):
path = "../event-schemas/schema/v1/core" path = "../event-schemas/schema/v1/core"
event_types = {} event_types = {}
with open(path, "r") as f:
core_json = json.loads(f.read()) for (root, dirs, files) in os.walk(path):
for event_type in core_json["definitions"]: for filename in files:
if not filename.endswith(".json"):
continue
event_type = filename[:-5] # strip the ".json"
with open(os.path.join(root, filename)) as f:
event_info = json.loads(f.read())
if "event" not in event_type: if "event" not in event_type:
continue # filter ImageInfo and co continue # filter ImageInfo and co
event_info = core_json["definitions"][event_type]
table = { table = {
"title": event_info["title"], "title": event_info["title"],
"desc": event_info["description"], "desc": event_info["description"],
"rows": [] "rows": []
} }
for prop in sorted(event_info["properties"]): for prop in sorted(event_info["properties"]):
row = { row = {
"key": prop, "key": prop,
@ -301,6 +309,7 @@ class MatrixUnits(Units):
"desc": event_info["properties"][prop].get("description","") "desc": event_info["properties"][prop].get("description","")
} }
table["rows"].append(row) table["rows"].append(row)
event_types[event_type] = table event_types[event_type] = table
return event_types return event_types

Loading…
Cancel
Save