internal/godoc/dochtml: delete legacyExampleTmpl
Interactive playgrounds have been live for a while, so legacyExampleTmpl
and EnableInteractivePlayground is removed.
Change-Id: I09c03162cfc7fb52a74f21e08ff9b4ef83f4e8c5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/319149
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/godoc/dochtml/dochtml.go b/internal/godoc/dochtml/dochtml.go
index f9f36d6..5dcdcef 100644
--- a/internal/godoc/dochtml/dochtml.go
+++ b/internal/godoc/dochtml/dochtml.go
@@ -281,9 +281,8 @@
}
return "/" + versionedPath
},
- DisableHotlinking: true,
- EnableCommandTOC: true,
- EnableInteractivePlayground: true,
+ DisableHotlinking: true,
+ EnableCommandTOC: true,
})
fileLink := func(name string) safehtml.HTML {
diff --git a/internal/godoc/dochtml/internal/render/linkify_test.go b/internal/godoc/dochtml/internal/render/linkify_test.go
index c199ffe..438c72d 100644
--- a/internal/godoc/dochtml/internal/render/linkify_test.go
+++ b/internal/godoc/dochtml/internal/render/linkify_test.go
@@ -314,11 +314,12 @@
b := 2 /* another comment */
`,
`
-<pre class="Documentation-exampleCode">
+<textarea class="Documentation-exampleCode" spellcheck="false">
a := 1
-<span class="comment">// a comment</span>
-b := 2 <span class="comment">/* another comment */</span>
-</pre>`,
+// a comment
+b := 2 /* another comment */
+</textarea>
+`,
},
{
"trailing newlines",
@@ -327,9 +328,10 @@
`,
`
-<pre class="Documentation-exampleCode">
+<textarea class="Documentation-exampleCode" spellcheck="false">
a := 1
-</pre>`,
+</textarea>
+`,
},
{
"stripped output comment",
@@ -340,11 +342,11 @@
// removed
`,
`
-<pre class="Documentation-exampleCode">
+<textarea class="Documentation-exampleCode" spellcheck="false">
a := 1
-<span class="comment">// Output:</span>
+// Output:
b := 1
-</pre>
+</textarea>
`,
},
{
@@ -358,15 +360,15 @@
cleanup()
`,
`
-<pre class="Documentation-exampleCode">
+<textarea class="Documentation-exampleCode" spellcheck="false">
a := 1
-<span class="comment">// Output:</span>
+// Output:
b := 1
-</pre>
+</textarea>
`,
},
} {
- out := codeHTML(test.in, legacyExampleTmpl)
+ out := codeHTML(test.in, exampleTmpl)
got := strings.TrimSpace(string(out.String()))
want := strings.TrimSpace(test.want)
if got != want {
diff --git a/internal/godoc/dochtml/internal/render/render.go b/internal/godoc/dochtml/internal/render/render.go
index 295f147..434f24b 100644
--- a/internal/godoc/dochtml/internal/render/render.go
+++ b/internal/godoc/dochtml/internal/render/render.go
@@ -67,12 +67,6 @@
//
// Only relevant for HTML formatting.
EnableCommandTOC bool
-
- // EnableInteractivePlayground turns on the interactive playgrounds on
- // unit pages with examples.
- //
- // Only relevant for HTML formatting.
- EnableInteractivePlayground bool
}
// docDataTmpl renders documentation. It expects a docData.
@@ -102,19 +96,6 @@
{{- end -}}
{{end}}`))
-// legacyExampleTmpl renders code for a legacy example. It expect an Example.
-var legacyExampleTmpl = template.Must(template.New("").Parse(`
-<pre class="Documentation-exampleCode">
-{{range .}}
- {{- if .Comment -}}
- <span class="comment">{{.Text}}</span>
- {{- else -}}
- {{.Text}}
- {{- end -}}
-{{end}}
-</pre>
-`))
-
// exampleTmpl renders code for an example. It expect an Example.
var exampleTmpl = template.Must(template.New("").Parse(`
<textarea class="Documentation-exampleCode" spellcheck="false">
@@ -130,7 +111,6 @@
var disableHotlinking bool
var disablePermalinks bool
var enableCommandTOC bool
- exampleTemplate := legacyExampleTmpl
if opts != nil {
if len(opts.RelatedPackages) > 0 {
others = opts.RelatedPackages
@@ -141,9 +121,6 @@
disableHotlinking = opts.DisableHotlinking
disablePermalinks = opts.DisablePermalinks
enableCommandTOC = opts.EnableCommandTOC
- if opts.EnableInteractivePlayground {
- exampleTemplate = exampleTmpl
- }
}
pids := newPackageIDs(pkg, others...)
@@ -155,7 +132,7 @@
disablePermalinks: disablePermalinks,
enableCommandTOC: enableCommandTOC,
docTmpl: docDataTmpl,
- exampleTmpl: exampleTemplate,
+ exampleTmpl: exampleTmpl,
ctx: ctx,
}
}