internal/godoc/dochtml: add content for empty sections
Text is added which is displayed when a documentation section is empty.
Change-Id: I783ab7ac9947abbef754a01f58c6b60118a59d19
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/259006
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/godoc/dochtml/template_body.go b/internal/godoc/dochtml/template_body.go
index 56bda15..18b4a8b 100644
--- a/internal/godoc/dochtml/template_body.go
+++ b/internal/godoc/dochtml/template_body.go
@@ -62,49 +62,55 @@
{{- end -}}
<h3 tabindex="-1" id="pkg-constants" class="Documentation-constantsHeader">Constants <a href="#pkg-constants">¶</a></h3>{{"\n"}}
- {{- if .Consts -}}
<section class="Documentation-constants">
+ {{- if .Consts -}}
{{- range .Consts -}}
{{- $out := render_decl .Doc .Decl -}}
{{- $out.Decl -}}
{{- $out.Doc -}}
{{"\n"}}
{{- end -}}
- </section>
+ {{- else -}}
+ <div>There are no constants in this package.</div>
{{- end -}}
+ </section>
<h3 tabindex="-1" id="pkg-variables" class="Documentation-variablesHeader">Variables <a href="#pkg-variables">¶</a></h3>{{"\n"}}
- {{- if .Vars -}}
<section class="Documentation-variables">
+ {{- if .Vars -}}
{{- range .Vars -}}
{{- $out := render_decl .Doc .Decl -}}
{{- $out.Decl -}}
{{- $out.Doc -}}
{{"\n"}}
{{- end -}}
- </section>
+ {{- else -}}
+ <div>There are no variables in this package.</div>
{{- end -}}
+ </section>
<h3 tabindex="-1" id="pkg-functions" class="Documentation-functionsHeader">Functions <a href="#pkg-functions">¶</a></h3>{{"\n"}}
- {{- if .Funcs -}}
<section class="Documentation-functions">
- {{- range .Funcs -}}
- <div class="Documentation-function">
- {{- $id := safe_id .Name -}}
- <h3 tabindex="-1" id="{{$id}}" data-kind="function" class="Documentation-functionHeader">func {{source_link .Name .Decl}} <a href="#{{$id}}">¶</a></h3>{{"\n"}}
- {{- $out := render_decl .Doc .Decl -}}
- {{- $out.Decl -}}
- {{- $out.Doc -}}
- {{"\n"}}
- {{- template "example" (index $.Examples.Map .Name) -}}
- </div>
- {{- end -}}
- </section>
+ {{- if .Funcs -}}
+ {{- range .Funcs -}}
+ <div class="Documentation-function">
+ {{- $id := safe_id .Name -}}
+ <h3 tabindex="-1" id="{{$id}}" data-kind="function" class="Documentation-functionHeader">func {{source_link .Name .Decl}} <a href="#{{$id}}">¶</a></h3>{{"\n"}}
+ {{- $out := render_decl .Doc .Decl -}}
+ {{- $out.Decl -}}
+ {{- $out.Doc -}}
+ {{"\n"}}
+ {{- template "example" (index $.Examples.Map .Name) -}}
+ </div>
+ {{- end -}}
+ {{- else -}}
+ <div>There are no functions in this package.</div>
{{- end -}}
+ </section>
<h3 tabindex="-1" id="pkg-types" class="Documentation-typesHeader">Types <a href="#pkg-types">¶</a></h3>{{"\n"}}
- {{- if .Types -}}
<section class="Documentation-types">
+ {{- if .Types -}}
{{- range .Types -}}
<div class="Documentation-type">
{{- $tname := .Name -}}
@@ -160,8 +166,10 @@
{{- end -}}
</div>
{{- end -}}
- </section>
+ {{- else -}}
+ <div>There are no types in this package.</div>
{{- end -}}
+ </section>
{{- end -}}
{{- if .Notes -}}