forked from golang/pkgsite
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6aed5c8
commit 3721a51
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package godoc | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"golang.org/x/net/html" | ||
"golang.org/x/pkgsite/internal" | ||
"golang.org/x/pkgsite/internal/godoc/dochtml" | ||
"golang.org/x/pkgsite/internal/source" | ||
) | ||
|
||
func TestGopRender(t *testing.T) { | ||
dochtml.LoadTemplates(templateFS) | ||
ctx := context.Background() | ||
p, err := packageForDir(filepath.Join("testdata", "gop"), false) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
parts, err := p.Render(ctx, "", &source.Info{}, &dochtml.ModuleInfo{}, nil, internal.BuildContext{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
htmlDoc, err := html.Parse(strings.NewReader(parts.Body.String())) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
wantFuncAnchor := []string{"Mul", "Mul__1", "Mul__2", "MulFloat", "MulInt"} | ||
for _, anchor := range wantFuncAnchor { | ||
t.Run(anchor, func(t *testing.T) { | ||
checker := in("h4.Documentation-functionHeader#" + anchor) | ||
if err := checker(htmlDoc); err != nil { | ||
t.Fatal(err) | ||
} | ||
}) | ||
} | ||
// TODO: check overload method (htmlcheck.Checker cant select id like "foo.Division") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package foo | ||
|
||
const GopPackage = true | ||
|
||
const Gopo_Mul = "MulInt,,MulFloat" | ||
|
||
// Mut int | ||
func MulInt(a int, b int) int { | ||
return a * b | ||
} | ||
|
||
// Mut string | ||
func Mul__1(a string, b string) string { | ||
return a + b | ||
} | ||
|
||
// Mut float | ||
func MulFloat(a float64, b float64) float64 { | ||
return a * b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters