From 93894ebbbe9a55675a89e0a3625d23661b1a5079 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 13 Oct 2016 17:23:11 +0100 Subject: [PATCH] Fix spurious "None" in non-room events Events like m.direct and m.tag don't inherit from either Message event or State event, and were getting a "None" where there should have been a type. --- templating/matrix_templates/templates/events.tmpl | 4 ++++ templating/matrix_templates/units.py | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/templating/matrix_templates/templates/events.tmpl b/templating/matrix_templates/templates/events.tmpl index f7a8263e..95edff57 100644 --- a/templating/matrix_templates/templates/events.tmpl +++ b/templating/matrix_templates/templates/events.tmpl @@ -2,9 +2,13 @@ ``{{event.type}}`` {{(4 + event.type | length) * title_kind}} + +{% if (event.typeof | length) %} *{{event.typeof}}* {{event.typeof_info}} +{% endif -%} + {{event.desc | wrap(80)}} {% for table in event.content_fields %} {{"``"+table.title+"``" if table.title else "" }} diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index 1eb465a3..7fbaee45 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -680,7 +680,7 @@ class MatrixUnits(Units): json_schema = yaml.load(f) schema = { - "typeof": None, + "typeof": "", "typeof_info": "", "type": None, "title": None, @@ -703,11 +703,9 @@ class MatrixUnits(Units): STATE_EVENT: "State Event" } if type(json_schema.get("allOf")) == list: - schema["typeof"] = base_defs.get( - json_schema["allOf"][0].get("$ref") - ) - elif json_schema.get("title"): - schema["typeof"] = json_schema["title"] + firstRef = json_schema["allOf"][0]["$ref"] + if firstRef in base_defs: + schema["typeof"] = base_defs[firstRef] json_schema = resolve_references(filepath, json_schema)