Skip to content
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

Enforce consistent vertical spacing between paragraphs in endpoint definitions #1969

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ footer {
border-top: 1px $table-border-color solid;
}

td > p:last-child {
// Avoid unnecessary space at the bottom of the cells.
margin-bottom: 0;
}

&.object-table, &.response-table, &.content-type-table {
border: 1px $table-border-color solid;

Expand Down
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/1969.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enforce consistent vertical spacing between paragraphs in endpoint definitions.
14 changes: 7 additions & 7 deletions layouts/partials/added-in.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{ $ver := .v }}
{{ $this := .this }}
{{ $ver := .v -}}
{{ $this := .this -}}

{{/*
This differs from the shortcode added-in by wanting to be a block instead of inline
and by slightly altering the rendered text as a result.
*/}}

{{ if $this }}
**New in this version.**
{{ else }}
**Added in `v{{ $ver }}`**
{{ end }}
{{ if $this -}}
<p><strong>New in this version.</strong></p>
{{ else -}}
<p><strong>Added in <code>v{{ $ver }}</code></strong></p>
{{ end -}}
5 changes: 3 additions & 2 deletions layouts/partials/changed-in.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
version -> details pairs.
*/ -}}
{{ range $ver, $details := .changes_dict -}}
<br><br>
<p>
<strong>
Changed in <code>v{{ $ver }}</code>:
</strong>
{{ $details | markdownify }}
{{ end }}
</p>
{{ end -}}
7 changes: 6 additions & 1 deletion layouts/partials/openapi/render-content-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
<tr>
<td><code>{{ $mime }}</code></td>
<td>
{{ $body.schema.description | markdownify -}}
{{/*
Force the rendering as a block so the description is always inside a
paragraph. This allows to always keep the same spacing between paragraphs
when adding added-in and changed-in paragraphs.
*/}}
{{ $body.schema.description | page.RenderString (dict "display" "block") -}}
{{ if (index $body.schema "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $body.schema "x-addedInMatrixVersion")) }}{{ end -}}
{{ if (index $body.schema "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $body.schema "x-changedInMatrixVersion")) }}{{ end -}}
</td>
Expand Down
18 changes: 15 additions & 3 deletions layouts/partials/openapi/render-object-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,21 @@
* `x-changedInMatrixVersion`: optional string indicating in which Matrix
spec version this property was last changed.
*/}}
{{ define "partials/property-description" }}
{{ if .required }}<strong>Required: </strong>{{end -}}
{{ .property.description | markdownify -}}
{{ define "partials/property-description" -}}
{{ $description := .property.description -}}
{{ if .required -}}
{{/*
Prepend "Required:" to make it part of the first paragraph of the
description.
*/}}
{{- $description = printf "<strong>Required: </strong>%s" $description -}}
{{ end -}}
{{/*
Force the rendering as a block so the description is always inside a
paragraph. This allows to always keep the same spacing between paragraphs
when adding added-in and changed-in paragraphs.
*/}}
{{ $description | page.RenderString (dict "display" "block") -}}
{{ if .property.enum }}<p>One of: <code>[{{ delimit .property.enum ", " }}]</code>.</p>{{ end -}}
{{ if (index .property "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index .property "x-addedInMatrixVersion")) }}{{ end -}}
{{ if (index .property "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index .property "x-changedInMatrixVersion")) }}{{ end -}}
Expand Down