Skip to content

Commit

Permalink
content/static/html/doc/body.tmpl: move decl doc to sub-template
Browse files Browse the repository at this point in the history
Make a separate template for the actual docs of consts, vars, funcs
and types.

This makes way for rendering deprecated decls separately.

For golang/go#40850

Change-Id: I4f5331b897325c35b67d195d168f7d3fc93a8a8c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/313032
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
  • Loading branch information
jba committed Apr 23, 2021
1 parent 4f92ee5 commit e0d7aa7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
39 changes: 22 additions & 17 deletions content/static/html/doc/body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@
</section>
{{- end -}}

{{template "decls" .}}

{{- end -}}

{{- if .Notes -}}
<h3 tabindex="-1" id="pkg-notes" class="Documentation-notesHeader">Notes <a href="#pkg-notes">¶</a></h3>{{"\n"}}
<section class="Documentation-notes">
{{- range $marker, $content := .Notes -}}
<div class="Documentation-note">
<h3 tabindex="-1" id="{{(index $.NoteHeaders $marker).SafeIdentifier}}" class="Documentation-noteHeader">{{(index $.NoteHeaders $marker).Label}}s <a href="#pkg-note-{{$marker}}">¶</a></h3>
<ul class="Documentation-noteList" style="padding-left: 20px; list-style: initial;">{{"\n" -}}
{{- range $v := $content -}}
<li style="margin: 6px 0 6px 0;">{{render_doc $v.Body}}</li>
{{- end -}}
</ul>{{"\n" -}}
</div>
{{- end -}}
</section>
{{- end -}}
</div> {{/* End documentation content container */}}

{{- define "decls" -}}
<h3 tabindex="-1" id="pkg-constants" class="Documentation-constantsHeader">Constants <a href="#pkg-constants">¶</a></h3>{{"\n"}}
<section class="Documentation-constants">
{{- if .Consts -}}
Expand Down Expand Up @@ -155,20 +177,3 @@
{{- end -}}
</section>
{{- end -}}

{{- if .Notes -}}
<h3 tabindex="-1" id="pkg-notes" class="Documentation-notesHeader">Notes <a href="#pkg-notes">¶</a></h3>{{"\n"}}
<section class="Documentation-notes">
{{- range $marker, $content := .Notes -}}
<div class="Documentation-note">
<h3 tabindex="-1" id="{{(index $.NoteHeaders $marker).SafeIdentifier}}" class="Documentation-noteHeader">{{(index $.NoteHeaders $marker).Label}}s <a href="#pkg-note-{{$marker}}">¶</a></h3>
<ul class="Documentation-noteList" style="padding-left: 20px; list-style: initial;">{{"\n" -}}
{{- range $v := $content -}}
<li style="margin: 6px 0 6px 0;">{{render_doc $v.Body}}</li>
{{- end -}}
</ul>{{"\n" -}}
</div>
{{- end -}}
</section>
{{- end -}}
</div> {{/* End documentation content container */}}
1 change: 0 additions & 1 deletion internal/godoc/dochtml/testdata/deprecated.golden
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
</div>

</div></div></section></div>

----

<ul role="group" id="doc-outline">
Expand Down
1 change: 0 additions & 1 deletion internal/godoc/dochtml/testdata/everydecl.golden
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ BUG(uid): this verifies that notes are rendered
</div><p>this verifies that notes are rendered
</p></li></ul>
</div></section></div>

----

<ul role="group" id="doc-outline">
Expand Down

0 comments on commit e0d7aa7

Please sign in to comment.