diff --git a/event-schemas/examples/v1/m.room.member b/event-schemas/examples/v1/m.room.member index abfd89ce..b9cd2671 100644 --- a/event-schemas/examples/v1/m.room.member +++ b/event-schemas/examples/v1/m.room.member @@ -1,7 +1,9 @@ { "age": 242352, "content": { - "membership": "join" + "membership": "join", + "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto", + "displayname": "Alice Margatroid" }, "state_key": "@alice:localhost", "origin_server_ts": 1431961217939, diff --git a/event-schemas/examples/v1/m.room.redaction b/event-schemas/examples/v1/m.room.redaction index dd56e97c..2e8260ea 100644 --- a/event-schemas/examples/v1/m.room.redaction +++ b/event-schemas/examples/v1/m.room.redaction @@ -1,6 +1,8 @@ { "age": 242352, - "content": {}, + "content": { + "reason": "Spamming" + }, "origin_server_ts": 1431961217939, "event_id": "$WLGTSEFSEF:localhost", "type": "m.room.redaction", diff --git a/event-schemas/schema/v1/m.room.aliases b/event-schemas/schema/v1/m.room.aliases index 6c91eed7..25f62876 100644 --- a/event-schemas/schema/v1/m.room.aliases +++ b/event-schemas/schema/v1/m.room.aliases @@ -1,6 +1,18 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "Informs the room about what room aliases it has been given.", + "description": "This event is sent by a homeserver directly to inform of changes + to the list of aliases it knows about for that room. The + ``state_key`` for this event is set to the homeserver which + owns the room alias. The entire set of known aliases for the + room is the union of all the ``m.room.aliases`` events, one + for each homeserver. Clients **should** check the validity + of any room alias given in this list before presenting it to + the user as trusted fact. The lists given by this event + should be considered simply as advice on which aliases + might exist, for which the client can perform the lookup to + confirm whether it receives the correct room ID.", "allOf": [{ "$ref": "core#/definitions/state_event" }], diff --git a/event-schemas/schema/v1/m.room.create b/event-schemas/schema/v1/m.room.create index 9e6e83bd..bfb4a6a9 100644 --- a/event-schemas/schema/v1/m.room.create +++ b/event-schemas/schema/v1/m.room.create @@ -1,6 +1,9 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "The first event in the room.", + "description": "This is the first event in a room and cannot be changed. It acts + as the root of all other events.", "allOf": [{ "$ref": "core#/definitions/state_event" }], diff --git a/event-schemas/schema/v1/m.room.join_rules b/event-schemas/schema/v1/m.room.join_rules index 3954a962..a9c6eb58 100644 --- a/event-schemas/schema/v1/m.room.join_rules +++ b/event-schemas/schema/v1/m.room.join_rules @@ -1,6 +1,11 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "Describes how users are allowed to join the room.", + "description": "A room may be ``public`` meaning anyone can join the room without + any prior action. Alternatively, it can be ``invite`` meaning that + a user who wishes to join the room must first receive an invite to + the room from someone already inside of the room.", "allOf": [{ "$ref": "core#/definitions/state_event" }], diff --git a/event-schemas/schema/v1/m.room.member b/event-schemas/schema/v1/m.room.member index 76b4c360..71b1fe67 100644 --- a/event-schemas/schema/v1/m.room.member +++ b/event-schemas/schema/v1/m.room.member @@ -1,6 +1,13 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "The current membership state of a user in the room.", + "description": "Adjusts the membership state for a user in a room. It is preferable to use + the membership APIs (``/rooms//invite`` etc) when performing + membership actions rather than adjusting the state directly as there are a + restricted set of valid transformations. For example, user A cannot force + user B to join a room, and trying to force this state change directly will + fail.", "allOf": [{ "$ref": "core#/definitions/state_event" }], @@ -11,6 +18,12 @@ "membership": { "type": "string", "enum": ["invite","join","knock","leave","ban"] + }, + "avatar_url": { + "type": "string" + }, + "displayname": { + "type": "string" } }, "required": ["membership"] diff --git a/event-schemas/schema/v1/m.room.message b/event-schemas/schema/v1/m.room.message index 2b00dfd0..42dc7439 100644 --- a/event-schemas/schema/v1/m.room.message +++ b/event-schemas/schema/v1/m.room.message @@ -1,6 +1,12 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "A human-readable message in the room.", + "description": "This event is used when sending messages in a room. Messages are + not limited to be text. The ``msgtype`` key outlines the type + of message, e.g. text, audio, image, video, etc. The ``body`` key + is text and MUST be used with every kind of ``msgtype`` as a + fallback mechanism for when a client cannot render a message.", "allOf": [{ "$ref": "core#/definitions/room_event" }], diff --git a/event-schemas/schema/v1/m.room.message.feedback b/event-schemas/schema/v1/m.room.message.feedback index 392e630d..5784d9fd 100644 --- a/event-schemas/schema/v1/m.room.message.feedback +++ b/event-schemas/schema/v1/m.room.message.feedback @@ -1,6 +1,13 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "A receipt for a message. N.B. not implemented in Synapse, and superceded in + v2 CS API by the ``relates_to`` event field.", + "description": "Feedback events are events sent to acknowledge a message in some way. There + are two supported acknowledgements: ``delivered`` (sent when the event has + been received) and ``read`` (sent when the event has been observed by the + end-user). The ``target_event_id`` should reference the ``m.room.message`` + event being acknowledged.", "allOf": [{ "$ref": "core#/definitions/room_event" }], diff --git a/event-schemas/schema/v1/m.room.name b/event-schemas/schema/v1/m.room.name index 6dca3b14..56fdca9a 100644 --- a/event-schemas/schema/v1/m.room.name +++ b/event-schemas/schema/v1/m.room.name @@ -1,5 +1,12 @@ { "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Set the human-readable name for the room.", + "description": "A room has an opaque room ID which is not human-friendly to read. A room + alias is human-friendly, but not all rooms have room aliases. The room + name is a human-friendly string designed to be displayed to the end-user. + The room name is not unique, as multiple rooms can have the same room name + set. The room name can also be set when creating a room using ``/createRoom`` + with the ``name`` key.", "type": "object", "allOf": [{ "$ref": "core#/definitions/state_event" diff --git a/event-schemas/schema/v1/m.room.power_levels b/event-schemas/schema/v1/m.room.power_levels index 91621149..4104bab7 100644 --- a/event-schemas/schema/v1/m.room.power_levels +++ b/event-schemas/schema/v1/m.room.power_levels @@ -1,6 +1,20 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "Defines the power levels (privileges) of users in the room.", + "description": "This event specifies the minimum level a user must have in order + to perform a certain action. It also specifies the levels + of each user in the room. If a ``user_id`` is in the + ``users`` list, then that ``user_id`` has the associated + power level. Otherwise they have the default level + ``users_default``. If ``users_default`` is not supplied, + it is assumed to be 0. The level required to send a + certain event is governed by ``events``, ``state_default`` + and ``events_default``. If an event type is specified in + ``events``, then the user must have at least the level + specified in order to send that event. If the event type is + not supplied, it defaults to ``events_default`` for Message + Events and ``state_default`` for State Events.", "allOf": [{ "$ref": "core#/definitions/state_event" }], @@ -28,7 +42,7 @@ } }, "required": ["ban","events","events_default","kick","redact", - "state_default","users","users_default"] + "state_default","users"] }, "state_key": { "type": "string", diff --git a/event-schemas/schema/v1/m.room.redaction b/event-schemas/schema/v1/m.room.redaction index 5b5dd6db..910e3215 100644 --- a/event-schemas/schema/v1/m.room.redaction +++ b/event-schemas/schema/v1/m.room.redaction @@ -1,6 +1,15 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "Indicates a previous event has been redacted.", + "description": "Events can be redacted by either room or server admins. Redacting an event + means that all keys not required by the protocol are stripped off, allowing + admins to remove offensive or illegal content that may have been attached + to any event. This cannot be undone, allowing server owners to physically + delete the offending data. There is also a concept of a moderator hiding a + message event, which can be undone, but cannot be applied to state + events. The event that has been redacted is specified in the ``redacts`` + event level key.", "allOf": [{ "$ref": "core#/definitions/room_event" }], diff --git a/event-schemas/schema/v1/m.room.topic b/event-schemas/schema/v1/m.room.topic index 80ae1191..86f4c97b 100644 --- a/event-schemas/schema/v1/m.room.topic +++ b/event-schemas/schema/v1/m.room.topic @@ -1,6 +1,12 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "title": "Set a topic for the room.", + "description": "A topic is a short message detailing what is currently being discussed in + the room. It can also be used as a way to display extra information about + the room, which may not be suitable for the room name. The room topic can + also be set when creating a room using ``/createRoom`` with the ``topic`` + key.", "allOf": [{ "$ref": "core#/definitions/state_event" }], diff --git a/templating/build.py b/templating/build.py index 7752f309..ebf4ac18 100755 --- a/templating/build.py +++ b/templating/build.py @@ -66,8 +66,8 @@ def check_unaccessed(name, store): def main(): # add a template filter to produce pretty pretty JSON - def jsonify(input, pre_whitespace=0): - code = json.dumps(input, indent=4) + def jsonify(input, indent=None, pre_whitespace=0): + code = json.dumps(input, indent=indent) if pre_whitespace: code = code.replace("\n", ("\n" +" "*pre_whitespace)) diff --git a/templating/internal/sections.py b/templating/internal/sections.py index 9a6d3bfc..ad408642 100644 --- a/templating/internal/sections.py +++ b/templating/internal/sections.py @@ -8,6 +8,8 @@ def _render_section_room_events(env, units): schemas = units.get("event-schemas") sections = [] for event_name in schemas: + if not event_name.startswith("m.room"): + continue sections.append(template.render( example=examples[event_name], event=schemas[event_name] diff --git a/templating/internal/units.py b/templating/internal/units.py index aff48a2b..be669ea7 100644 --- a/templating/internal/units.py +++ b/templating/internal/units.py @@ -62,14 +62,16 @@ def _load_schemas(): for filename in os.listdir(path): if not filename.startswith("m."): continue + print "Reading %s" % os.path.join(path, filename) with open(os.path.join(path, filename), "r") as f: - json_schema = json.loads(f.read()) + json_schema = json.loads(f.read(), strict=False) schema = { "typeof": None, "type": None, "summary": None, "desc": None, - "json_format": None + "json_format": None, + "required_keys": None } # add typeof @@ -94,6 +96,12 @@ def _load_schemas(): if content_props: schema["json_format"] = format_for_obj(content_props) + # add required_keys + schema["required_keys"] = prop( + json_schema, "properties/content/required" + ) + + schemata[filename] = schema return schemata diff --git a/templating/templates/events.tmpl b/templating/templates/events.tmpl index 602aa108..7520701c 100644 --- a/templating/templates/events.tmpl +++ b/templating/templates/events.tmpl @@ -5,11 +5,13 @@ {{event.typeof}} Description: {{event.desc}} + Required Keys: + ``{{event.required_keys | jsonify}}`` JSON Format:: - {{event.json_format | jsonify(4)}} + {{event.json_format | jsonify(4, 4)}} Example:: - {{example.content | jsonify(4)}} + {{example.content | jsonify(4, 4)}}