godoc: add links to docs in text and dir pages
Fixes golang/go#17125
Change-Id: I22dd0561cd1c8eb30524797b6c0488d08a65285b
Reviewed-on: https://go-review.googlesource.com/29279
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/godoc/godoc_test.go b/godoc/godoc_test.go
index ef5790e..dca1c95 100644
--- a/godoc/godoc_test.go
+++ b/godoc/godoc_test.go
@@ -290,3 +290,32 @@
}
}
}
+
+func TestSrcBreadcrumbFunc(t *testing.T) {
+ for _, tc := range []struct {
+ path string
+ want string
+ }{
+ {"src/", `<span class="text-muted">src/</span>`},
+ {"src/fmt/", `<a href="/src">src</a>/<span class="text-muted">fmt/</span>`},
+ {"src/fmt/print.go", `<a href="/src">src</a>/<a href="/src/fmt">fmt</a>/<span class="text-muted">print.go</span>`},
+ } {
+ if got := srcBreadcrumbFunc(tc.path); got != tc.want {
+ t.Errorf("srcBreadcrumbFunc(%v) = %v; want %v", tc.path, got, tc.want)
+ }
+ }
+}
+
+func TestSrcToPkgLinkFunc(t *testing.T) {
+ for _, tc := range []struct {
+ path string
+ want string
+ }{
+ {"src/", `<a href="/pkg">Index</a>`},
+ {"src/fmt/", `<a href="/pkg/fmt">fmt</a>`},
+ } {
+ if got := srcToPkgLinkFunc(tc.path); got != tc.want {
+ t.Errorf("srcToPkgLinkFunc(%v) = %v; want %v", tc.path, got, tc.want)
+ }
+ }
+}