You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
matrix-spec/templating/matrix_templates/sections.py

44 lines
1.4 KiB
Python

"""Contains all the sections for the spec."""
from batesian import AccessKeyStore
from batesian.sections import Sections
import inspect
import os
class MatrixSections(Sections):
def render_room_events(self):
template = self.env.get_template("events.tmpl")
examples = self.units.get("event_examples")
schemas = self.units.get("event_schemas")
sections = []
for event_name in sorted(schemas):
if not event_name.startswith("m.room"):
continue
sections.append(template.render(
example=examples[event_name],
event=schemas[event_name]
))
return "\n\n".join(sections)
# pass through git ver so it'll be dropped in the input file
def render_git_version(self):
return self.units.get("git_version")
def render_spec_version(self):
return "0.1.0"
def _render_ce_type(self, type):
template = self.env.get_template("common-event-fields.tmpl")
ce_types = self.units.get("common_event_fields")
return template.render(common_event=ce_types[type])
def render_common_event_fields(self):
return self._render_ce_type("event")
def render_common_room_event_fields(self):
return self._render_ce_type("room_event")
def render_common_state_event_fields(self):
return self._render_ce_type("state_event")