From 3868f57059a826bce3a0097012d4870f8d7c9bd1 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Thu, 14 Apr 2016 12:13:35 +1000 Subject: [PATCH] godoc/static: replace version strings with actual versions This will allow the source installation instructions to always show the current version, but only when that version is a release version. Fixes golang/go#14371 Change-Id: Ibfad8054f3c75d9320ca94ba5149ab9bf052157e Reviewed-on: https://go-review.googlesource.com/22056 Reviewed-by: Brad Fitzpatrick --- godoc/static/godoc.html | 1 + godoc/static/godocs.js | 9 +++++++++ godoc/static/static.go | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/godoc/static/godoc.html b/godoc/static/godoc.html index e4ea6e1a..a7009827 100644 --- a/godoc/static/godoc.html +++ b/godoc/static/godoc.html @@ -100,6 +100,7 @@ and code is licensed under a BSD license.
{{if .Playground}} {{end}} +{{with .Version}}{{end}} diff --git a/godoc/static/godocs.js b/godoc/static/godocs.js index ec9f37a9..10183cba 100644 --- a/godoc/static/godocs.js +++ b/godoc/static/godocs.js @@ -297,6 +297,14 @@ function personalizeInstallInstructions() { window.location = download; } +function updateVersionTags() { + var v = window.goVersion; + if (/^go[0-9.]+$/.test(v)) { + $(".versionTag").empty().text(v); + $(".whereTag").hide(); + } +} + $(document).ready(function() { bindSearchEvents(); generateTOC(); @@ -313,6 +321,7 @@ $(document).ready(function() { setupCallgraphs(); toggleHash(); personalizeInstallInstructions(); + updateVersionTags(); // godoc.html defines window.initFuncs in the tag, and root.html and // codewalk.js push their on-page-ready functions to the list. diff --git a/godoc/static/static.go b/godoc/static/static.go index 985243d8..a29eaed1 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -560,6 +560,7 @@ and code is licensed under a BSD license.
{{if .Playground}} {{end}} +{{with .Version}}{{end}} @@ -866,6 +867,14 @@ function personalizeInstallInstructions() { window.location = download; } +function updateVersionTags() { + var v = window.goVersion; + if (/^go[0-9.]+$/.test(v)) { + $(".versionTag").empty().text(v); + $(".whereTag").hide(); + } +} + $(document).ready(function() { bindSearchEvents(); generateTOC(); @@ -882,6 +891,7 @@ $(document).ready(function() { setupCallgraphs(); toggleHash(); personalizeInstallInstructions(); + updateVersionTags(); // godoc.html defines window.initFuncs in the tag, and root.html and // codewalk.js push their on-page-ready functions to the list.