Skip to content

Format Application Service schema #2131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

V02460
Copy link
Contributor

@V02460 V02460 commented Apr 9, 2025

Minor formatting of the Application Service schema files. This PR

  • removes spurious line breaks in the descriptions by switching from literal strip (|-) to folded strip (>-) YAML string representation (https://yaml-multiline.info/)
  • Keeps a line length of 80+10% characters (similar to how black does it)
  • Ensures trailing newlines

Pull Request Checklist

V02460 added 3 commits April 9, 2025 10:24
Signed-off-by: Kai A. Hiller <[email protected]>
Signed-off-by: Kai A. Hiller <[email protected]>
Signed-off-by: Kai A. Hiller <[email protected]>
@V02460 V02460 requested a review from a team as a code owner April 9, 2025 08:33
@@ -19,10 +19,13 @@ items:
properties:
regex:
type: string
description: A POSIX regular expression defining which values this namespace includes.
description: >-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes spurious line breaks in the descriptions by switching from literal strip (|-) to folded strip (>-) YAML string representation (https://yaml-multiline.info/)

The descriptions are written using Markdown (just like most of the spec) so we don't really care about "spurious" line breaks, they should be removed by the Markdown parser.

In my opinion, switching to the folded strip is worse, because the text does not behave as Markdown. For example we need to put 2 empty lines between paragraphs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element-hq/synapse#17892 (comment) is relevant to this discussion. I expect whatever solution we end up using there, can be useful here.

Copy link
Member

@richvdh richvdh Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I've read the thread at element-hq/synapse#17892 (comment) and am still not really clear why this is an improvement.

That thread appears to cite "tools handling the descriptions as plaintext" as a reason to prefer the >- style (complete with triple-linebreaks), but what tools do we have that do so? The thread includes a screenshot of "literal style with additional line breaks" which does indeed look awful, but where would that actually appear?

In this instance: our primary tooling is the spec, and https://playground.matrix.org, both of which treat the description as markdown. https://swagger.io/specification/#rich-text-formatting again says that the description is markdown.

So, could someone explain like I'm 5: what exactly goes wrong if we use |- style here?

/cc @anoadragon453 @V02460

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry to have caused such confusion 😅 I hope this explanation will clear things up.

Take as a motivational example the editing of a registration file in VS Code. Additional IDE support is available when providing its schema file. Hovering over a key will give you a popup with its description string rendered in plain text. You can see that the flow of the text is borked because of the additional newline in the description.

schema-popup

To support both Markdown and plain text descriptions in tools, I propose restricting the description texts to a subset of Markdown: Markdown, but without any newlines in paragraphs.

Up to this point, nothing is specific to the different ways YAML can express one and the same string – but of course we have to choose one of them in the end. Here is the same description string expressed in three different YAML format styles:

styles:
    quote: "The first paragraph without any linebreaks inside.\n\nThe second paragraph that is separated by two linebreaks from the first."
    literal: |-
        The first paragraph \
        without any \
        linebreaks inside.

        The second paragraph \
        that is separated by \
        two linebreaks from \
        the first.
    folded: >-
        The first paragraph
        without any
        linebreaks inside.


        The second paragraph
        that is separated by
        two linebreaks from
        the first.

Quoted style is just a very long line without any formatting, but with noisy escape characters. Literal style gets either very long lines or these annoying backslashes (when requiring no linebreaks in paragraphs). Folded style gets the additional line break between paragraphs.

Copy link
Member

@richvdh richvdh Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I see; thanks for the explanation.

My feeling is that having to remember to use triple-linebreaks for paragraph breaks is a high price to pay for compatibility with VSCode, and I'm reluctant.

FWIW, I tried the same things in a JetBrains IDE, and it copes fine with |- with linebreaks.

Maybe we could make an exception in cases where we think it is particularly likely that we think people will be hand-writing YAML using the schema, but that seems unlikely for all the API endpoints.

So, -0.5 from me. If other SCT members and regular contributors are strongly in favour, I'll not insist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in agreement with @richvdh.

Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, other than the outstanding discussion at https://github.com/matrix-org/matrix-spec/pull/2131/files#r2038004161

@richvdh richvdh requested review from richvdh and removed request for richvdh June 4, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants