Skip to content

Commit

Permalink
Enforce consistent vertical spacing between paragraphs in endpoint de…
Browse files Browse the repository at this point in the history
…finitions (#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 <[email protected]>
  • Loading branch information
zecakeh authored Oct 29, 2024
1 parent 32f41f8 commit 1f5f2c4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
5 changes: 5 additions & 0 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,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

0 comments on commit 1f5f2c4

Please sign in to comment.