internal/frontend: change single-doc linux/amd64 to all/all
Until we reprocess, the documentation table will have many rows with
GOOS/GOARCH = linux/amd64, because that is the first build context in
our list. Most of the time, the unit will not care about build
context, and a reprocessing will change it to all/all. But until then,
add a hack to adjust the values used to render the doc page, to avoid
displaying GOOS/GOARCH.
Change-Id: I3e466939526b748ad1ab7f373ac752a8dcb4762b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290096
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/frontend/unit_main.go b/internal/frontend/unit_main.go
index 0b7ef21..0cd1cb6 100644
--- a/internal/frontend/unit_main.go
+++ b/internal/frontend/unit_main.go
@@ -172,6 +172,22 @@
synopsis = doc.Synopsis
goos = doc.GOOS
goarch = doc.GOARCH
+ // If there is only one Documentation and it is linux/amd64, then
+ // make it all/all.
+ //
+ // This is temporary, until the next reprocessing. It assumes a unit
+ // with a single linux/amd64 actually has only one build context,
+ // and hasn't been reprocessed to have all/all.
+ //
+ // The only effect of this is to prevent "GOOS=linux, GOARCH=amd64" from
+ // appearing at the bottom of the doc. That is wrong in the (rather
+ // unlikely) case that the package truly only has doc for linux/amd64,
+ // but the bug is only cosmetic.
+ if len(unit.Documentation) == 1 && goos == "linux" && goarch == "amd64" {
+ goos = internal.All
+ goarch = internal.All
+ }
+
end := middleware.ElapsedStat(ctx, "DecodePackage")
docPkg, err := godoc.DecodePackage(doc.Source)
end()