Skip to content

Commit 1f5f2c4

Browse files
authored
Enforce consistent vertical spacing between paragraphs in endpoint definitions (#1969)
Use `p` elements to separate paragraphs instead of `br` and enforce single paragraphs to be wrapped in `p` for consistency. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent 32f41f8 commit 1f5f2c4

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

assets/scss/_styles_project.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ footer {
387387
border-top: 1px $table-border-color solid;
388388
}
389389

390+
td > p:last-child {
391+
// Avoid unnecessary space at the bottom of the cells.
392+
margin-bottom: 0;
393+
}
394+
390395
&.object-table, &.response-table, &.content-type-table {
391396
border: 1px $table-border-color solid;
392397

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enforce consistent vertical spacing between paragraphs in endpoint definitions.

layouts/partials/added-in.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{{ $ver := .v }}
2-
{{ $this := .this }}
1+
{{ $ver := .v -}}
2+
{{ $this := .this -}}
33

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

9-
{{ if $this }}
10-
**New in this version.**
11-
{{ else }}
12-
**Added in `v{{ $ver }}`**
13-
{{ end }}
9+
{{ if $this -}}
10+
<p><strong>New in this version.</strong></p>
11+
{{ else -}}
12+
<p><strong>Added in <code>v{{ $ver }}</code></strong></p>
13+
{{ end -}}

layouts/partials/changed-in.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
version -> details pairs.
77
*/ -}}
88
{{ range $ver, $details := .changes_dict -}}
9-
<br><br>
9+
<p>
1010
<strong>
1111
Changed in <code>v{{ $ver }}</code>:
1212
</strong>
1313
{{ $details | markdownify }}
14-
{{ end }}
14+
</p>
15+
{{ end -}}

layouts/partials/openapi/render-content-type.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
<tr>
2222
<td><code>{{ $mime }}</code></td>
2323
<td>
24-
{{ $body.schema.description | markdownify -}}
24+
{{/*
25+
Force the rendering as a block so the description is always inside a
26+
paragraph. This allows to always keep the same spacing between paragraphs
27+
when adding added-in and changed-in paragraphs.
28+
*/}}
29+
{{ $body.schema.description | page.RenderString (dict "display" "block") -}}
2530
{{ if (index $body.schema "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $body.schema "x-addedInMatrixVersion")) }}{{ end -}}
2631
{{ if (index $body.schema "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $body.schema "x-changedInMatrixVersion")) }}{{ end -}}
2732
</td>

layouts/partials/openapi/render-object-table.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,21 @@
306306
* `x-changedInMatrixVersion`: optional string indicating in which Matrix
307307
spec version this property was last changed.
308308
*/}}
309-
{{ define "partials/property-description" }}
310-
{{ if .required }}<strong>Required: </strong>{{end -}}
311-
{{ .property.description | markdownify -}}
309+
{{ define "partials/property-description" -}}
310+
{{ $description := .property.description -}}
311+
{{ if .required -}}
312+
{{/*
313+
Prepend "Required:" to make it part of the first paragraph of the
314+
description.
315+
*/}}
316+
{{- $description = printf "<strong>Required: </strong>%s" $description -}}
317+
{{ end -}}
318+
{{/*
319+
Force the rendering as a block so the description is always inside a
320+
paragraph. This allows to always keep the same spacing between paragraphs
321+
when adding added-in and changed-in paragraphs.
322+
*/}}
323+
{{ $description | page.RenderString (dict "display" "block") -}}
312324
{{ if .property.enum }}<p>One of: <code>[{{ delimit .property.enum ", " }}]</code>.</p>{{ end -}}
313325
{{ if (index .property "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index .property "x-addedInMatrixVersion")) }}{{ end -}}
314326
{{ if (index .property "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index .property "x-changedInMatrixVersion")) }}{{ end -}}

0 commit comments

Comments
 (0)