Completely split up the templating system from the Matrix Spec template code.
The two are now linked together in build.py by specifying the input module. Updated gendoc.py to specify the right module.
This commit is contained in:
parent
8e1d6899c2
commit
5b31c442f5
11 changed files with 196 additions and 114 deletions
40
templating/matrix_templates/sections.py
Normal file
40
templating/matrix_templates/sections.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
"""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_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")
|
Loading…
Add table
Add a link
Reference in a new issue