Produce valid JSON (escape \n), add indent filter

pull/977/head
Kegan Dougal 10 years ago
parent 2e5809a68e
commit 8f448a1764

@ -2,17 +2,7 @@
"$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.",
"description": "This event is sent by a homeserver directly to inform of changes\nto the list of aliases it knows about for that room. The\n``state_key`` for this event is set to the homeserver which\nowns the room alias. The entire set of known aliases for the\nroom is the union of all the ``m.room.aliases`` events, one\nfor each homeserver. Clients **should** check the validity\nof any room alias given in this list before presenting it to\nthe user as trusted fact. The lists given by this event\nshould be considered simply as advice on which aliases\nmight exist, for which the client can perform the lookup to\nconfirm whether it receives the correct room ID.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -2,8 +2,7 @@
"$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.",
"description": "This is the first event in a room and cannot be changed. It acts\nas the root of all other events.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -2,10 +2,7 @@
"$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.",
"description": "A room may be ``public`` meaning anyone can join the room without\nany prior action. Alternatively, it can be ``invite`` meaning that\na user who wishes to join the room must first receive an invite to\nthe room from someone already inside of the room.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -2,12 +2,7 @@
"$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/<room id>/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.",
"description": "Adjusts the membership state for a user in a room. It is preferable to use\nthe membership APIs (``/rooms/<room id>/invite`` etc) when performing\nmembership actions rather than adjusting the state directly as there are a\nrestricted set of valid transformations. For example, user A cannot force\nuser B to join a room, and trying to force this state change directly will\nfail.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -2,11 +2,7 @@
"$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.",
"description": "This event is used when sending messages in a room. Messages are\nnot limited to be text. The ``msgtype`` key outlines the type\nof message, e.g. text, audio, image, video, etc. The ``body`` key\nis text and MUST be used with every kind of ``msgtype`` as a \nfallback mechanism for when a client cannot render a message.",
"allOf": [{
"$ref": "core#/definitions/room_event"
}],

@ -1,13 +1,8 @@
{
"$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.",
"title": "A receipt for a message. N.B. not implemented in Synapse, and superceded in\nv2 CS API by the ``relates_to`` event field.",
"description": "Feedback events are events sent to acknowledge a message in some way. There\nare two supported acknowledgements: ``delivered`` (sent when the event has\nbeen received) and ``read`` (sent when the event has been observed by the\nend-user). The ``target_event_id`` should reference the ``m.room.message``\nevent being acknowledged.",
"allOf": [{
"$ref": "core#/definitions/room_event"
}],

@ -1,12 +1,7 @@
{
"$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.",
"description": "A room has an opaque room ID which is not human-friendly to read. A room\nalias is human-friendly, but not all rooms have room aliases. The room \nname is a human-friendly string designed to be displayed to the end-user.\nThe room name is not unique, as multiple rooms can have the same room name\nset. The room name can also be set when creating a room using ``/createRoom`` \nwith the ``name`` key.",
"type": "object",
"allOf": [{
"$ref": "core#/definitions/state_event"

@ -2,19 +2,7 @@
"$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.",
"description": "This event specifies the minimum level a user must have in order\nto perform a certain action. It also specifies the levels\nof each user in the room. If a ``user_id`` is in the\n``users`` list, then that ``user_id`` has the associated\npower level. Otherwise they have the default level\n``users_default``. If ``users_default`` is not supplied,\nit is assumed to be 0. The level required to send a\ncertain event is governed by ``events``, ``state_default``\nand ``events_default``. If an event type is specified in \n``events``, then the user must have at least the level\nspecified in order to send that event. If the event type is\nnot supplied, it defaults to ``events_default`` for Message\nEvents and ``state_default`` for State Events.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -2,14 +2,7 @@
"$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.",
"description": "Events can be redacted by either room or server admins. Redacting an event\nmeans that all keys not required by the protocol are stripped off, allowing\nadmins to remove offensive or illegal content that may have been attached\nto any event. This cannot be undone, allowing server owners to physically\ndelete the offending data. There is also a concept of a moderator hiding a\nmessage event, which can be undone, but cannot be applied to state\nevents. The event that has been redacted is specified in the ``redacts``\nevent level key.",
"allOf": [{
"$ref": "core#/definitions/room_event"
}],

@ -2,11 +2,7 @@
"$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.",
"description": "A topic is a short message detailing what is currently being discussed in\nthe room. It can also be used as a way to display extra information about\nthe room, which may not be suitable for the room name. The room topic can\nalso be set when creating a room using ``/createRoom`` with the ``topic``\nkey.",
"allOf": [{
"$ref": "core#/definitions/state_event"
}],

@ -78,12 +78,16 @@ def main(file_stream=None, out_dir=None):
return code
def indent(input, indent):
return input.replace("\n", ("\n" + " "*indent))
# make Jinja aware of the templates and filters
env = Environment(
loader=FileSystemLoader("templates"),
undefined=StrictUndefined
)
env.filters["jsonify"] = jsonify
env.filters["indent"] = indent
# load up and parse the lowest single units possible: we don't know or care
# which spec section will use it, we just need it there in memory for when

@ -63,7 +63,7 @@ def _load_schemas():
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(), strict=False)
json_schema = json.loads(f.read())
schema = {
"typeof": None,
"type": None,

@ -4,7 +4,7 @@
Type:
{{event.typeof}}
Description:
{{event.desc}}
{{event.desc | indent(4)}}
Required Keys:
``{{event.required_keys | jsonify}}``

Loading…
Cancel
Save