From 75e7d09fc82258f104d7b938e8ce0722321d47d9 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 20 May 2015 12:41:25 +0100 Subject: [PATCH] Remove newlines from json: move line wrapping to the template files. --- event-schemas/schema/v1/m.room.aliases | 2 +- event-schemas/schema/v1/m.room.create | 2 +- event-schemas/schema/v1/m.room.join_rules | 2 +- event-schemas/schema/v1/m.room.member | 2 +- event-schemas/schema/v1/m.room.message | 2 +- event-schemas/schema/v1/m.room.message.feedback | 4 ++-- event-schemas/schema/v1/m.room.name | 2 +- event-schemas/schema/v1/m.room.power_levels | 2 +- event-schemas/schema/v1/m.room.redaction | 2 +- event-schemas/schema/v1/m.room.topic | 2 +- templating/build.py | 5 +++++ templating/templates/events.tmpl | 4 ++-- 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/event-schemas/schema/v1/m.room.aliases b/event-schemas/schema/v1/m.room.aliases index 1c86183f..03842221 100644 --- a/event-schemas/schema/v1/m.room.aliases +++ b/event-schemas/schema/v1/m.room.aliases @@ -2,7 +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\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.", + "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 c1cd1a39..53bb1a45 100644 --- a/event-schemas/schema/v1/m.room.create +++ b/event-schemas/schema/v1/m.room.create @@ -2,7 +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\nas the root of all other events.", + "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 ec430ff7..7c8189b2 100644 --- a/event-schemas/schema/v1/m.room.join_rules +++ b/event-schemas/schema/v1/m.room.join_rules @@ -2,7 +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\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.", + "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 22be8218..5cd8d297 100644 --- a/event-schemas/schema/v1/m.room.member +++ b/event-schemas/schema/v1/m.room.member @@ -2,7 +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\nthe membership APIs (``/rooms//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.", + "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" }], diff --git a/event-schemas/schema/v1/m.room.message b/event-schemas/schema/v1/m.room.message index 58e929e6..e5a109f7 100644 --- a/event-schemas/schema/v1/m.room.message +++ b/event-schemas/schema/v1/m.room.message @@ -2,7 +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\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.", + "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 062581e7..62c75e32 100644 --- a/event-schemas/schema/v1/m.room.message.feedback +++ b/event-schemas/schema/v1/m.room.message.feedback @@ -1,8 +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\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.", + "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 cc27c84b..3d70fa16 100644 --- a/event-schemas/schema/v1/m.room.name +++ b/event-schemas/schema/v1/m.room.name @@ -1,7 +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\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.", + "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 0e8e3946..5db1f961 100644 --- a/event-schemas/schema/v1/m.room.power_levels +++ b/event-schemas/schema/v1/m.room.power_levels @@ -2,7 +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\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.", + "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" }], diff --git a/event-schemas/schema/v1/m.room.redaction b/event-schemas/schema/v1/m.room.redaction index f036500b..fb6dd997 100644 --- a/event-schemas/schema/v1/m.room.redaction +++ b/event-schemas/schema/v1/m.room.redaction @@ -2,7 +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\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.", + "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 5847fa65..b3fc4574 100644 --- a/event-schemas/schema/v1/m.room.topic +++ b/event-schemas/schema/v1/m.room.topic @@ -2,7 +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\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.", + "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 35fde617..40115370 100755 --- a/templating/build.py +++ b/templating/build.py @@ -45,6 +45,7 @@ from argparse import ArgumentParser, FileType import json import os import sys +import textwrap import internal.units import internal.sections @@ -81,6 +82,9 @@ def main(file_stream=None, out_dir=None): def indent(input, indent): return input.replace("\n", ("\n" + " "*indent)) + def wrap(input, wrap=80): + return '\n'.join(textwrap.wrap(input, wrap)) + # make Jinja aware of the templates and filters env = Environment( loader=FileSystemLoader("templates"), @@ -88,6 +92,7 @@ def main(file_stream=None, out_dir=None): ) env.filters["jsonify"] = jsonify env.filters["indent"] = indent + env.filters["wrap"] = wrap # 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 diff --git a/templating/templates/events.tmpl b/templating/templates/events.tmpl index 80a751e0..1bb721b4 100644 --- a/templating/templates/events.tmpl +++ b/templating/templates/events.tmpl @@ -1,10 +1,10 @@ ``{{event.type}}`` Summary: - {{event.summary}} + {{event.summary | wrap(76) | indent(4)}} Type: {{event.typeof}} Description: - {{event.desc | indent(4)}} + {{event.desc | wrap(76) | indent(4)}} Required Keys: ``{{event.required_keys | jsonify}}``