Skip to content
Permalink
Browse files

fix(godocfx): shorten function names (#2880)

After this change, function headers show up as `func Foo` rather than
`func Foo(s string) string`, matching the behavior of pkg.go.dev.
  • Loading branch information
tbpg committed Sep 17, 2020
1 parent 8728cdf commit 48a0217930750c1f4327f2622b0f2a3ec8afc0b7
Showing with 7 additions and 13 deletions.
  1. +7 −13 internal/godocfx/parse.go
@@ -241,50 +241,44 @@ func parse(glob string) (map[string]*page, tableOfContents, *packages.Module, er
for _, fn := range t.Funcs {
fnUID := uid + "." + fn.Name
pkgItem.addChild(child(fnUID))
s := pkgsite.Synopsis(pkg.Fset, fn.Decl)
pkgPage.addItem(&item{
UID: fnUID,
Name: s,
Name: fmt.Sprintf("func %s\n", fn.Name),
ID: fn.Name,
Parent: uid,
Type: "function",
Summary: fn.Doc,
Langs: onlyGo,
// Note: Name has the syntax already.
// Syntax: Syntax{Content: s},
Syntax: syntax{Content: pkgsite.Synopsis(pkg.Fset, fn.Decl)},
})
}
for _, fn := range t.Methods {
fnUID := uid + "." + fn.Name
pkgItem.addChild(child(fnUID))
s := pkgsite.Synopsis(pkg.Fset, fn.Decl)
pkgPage.addItem(&item{
UID: fnUID,
Name: s,
Name: fmt.Sprintf("func (%s) %s\n", fn.Recv, fn.Name),
ID: fn.Name,
Parent: uid,
Type: "function",
Type: "function", // Note: this is actually a method.
Summary: fn.Doc,
Langs: onlyGo,
// Note: Name has the syntax already.
// Syntax: Syntax{Content: s},
Syntax: syntax{Content: pkgsite.Synopsis(pkg.Fset, fn.Decl)},
})
}
}
for _, fn := range docPkg.Funcs {
uid := pkg.PkgPath + "." + fn.Name
pkgItem.addChild(child(uid))
s := pkgsite.Synopsis(pkg.Fset, fn.Decl)
pkgPage.addItem(&item{
UID: uid,
Name: s,
Name: fmt.Sprintf("func %s\n", fn.Name),
ID: fn.Name,
Parent: pkg.PkgPath,
Type: "function",
Summary: fn.Doc,
Langs: onlyGo,
// Note: Name has the syntax already.
// Syntax: Syntax{Content: s},
Syntax: syntax{Content: pkgsite.Synopsis(pkg.Fset, fn.Decl)},
})
}
}

0 comments on commit 48a0217

Please sign in to comment.