Source File
symbol.go
Belonging Package
golang.org/x/pkgsite/internal/frontend
package frontend
import (
)
func ( string, map[string]map[internal.SymbolMeta]*internal.SymbolBuildContexts) [][]*Symbol {
:= map[string]map[internal.SymbolMeta]*Symbol{}
:= map[internal.SymbolMeta]*internal.SymbolBuildContexts{}
for , := range {
for , := range {
:= &Symbol{
Name: .Name,
Synopsis: .Synopsis,
Section: .Section,
Kind: .Kind,
Link: symbolLink(, .Name, .BuildContexts()),
New: true,
}
:= findParent(.ParentName, , )
= createParent(.ParentName, , .BuildContexts()...)
:= internal.SymbolMeta{
Name: .Name,
ParentName: .Name,
Synopsis: fmt.Sprintf("type %s (%v)", .Name, .BuildContexts()),
Section: .Section,
Kind: .Kind,
}
.Children = append(.Children, )
if , := [.Name]; ! {
[.Name] = map[internal.SymbolMeta]*Symbol{}
}
[.Name][] =
}
var []*Symbol
for , := range {
for , := range {
if len(.builds) != len(internal.BuildContexts) {
for := range .builds {
.Builds = append(.Builds, fmt.Sprintf("%s/%s", .GOOS, .GOARCH))
}
sort.Strings(.Builds)
}
= append(, )
}
}
return sortSymbols()
}
func ( string, *internal.SymbolBuildContexts,
map[string]map[internal.SymbolMeta]*Symbol) *Symbol {
, := []
if ! {
return nil
}
for , := range {
for := range .builds {
if .SupportsBuild() {
return
}
}
}
return nil
}
func (, string, []internal.BuildContext) string {
if len() == len(internal.BuildContexts) {
return fmt.Sprintf("%s#%s", , )
}
func (, string, ...internal.BuildContext) *Symbol {
:= &Symbol{
Name: ,
Synopsis: fmt.Sprintf("type %s", ),
Section: internal.SymbolSectionTypes,
Kind: internal.SymbolKindType,
Link: symbolLink(, , ),
}
.addBuilds(...)
return
}
func ( []*Symbol) [][]*Symbol {
:= map[internal.SymbolSection][]*Symbol{}
for , := range {
[.Section] = append([.Section], )
:= map[internal.SymbolKind][]*Symbol{}
.Synopsis = strings.TrimSuffix(.Synopsis, "{ ... }")
for , := range .Children {
[.Kind] = append([.Kind], )
}
for , := range {
sortSymbolsGroup()
}
:= append(append(append(
[internal.SymbolKindField],
[internal.SymbolKindConstant]...),
[internal.SymbolKindVariable]...),
[internal.SymbolKindFunction]...)
if strings.Contains(.Synopsis, "interface") {
.Children = append([internal.SymbolKindMethod], ...)
} else {
.Children = append(, [internal.SymbolKindMethod]...)
}
}
for , := range {
sortSymbolsGroup()
}
var [][]*Symbol
for , := range []internal.SymbolSection{
internal.SymbolSectionConstants,
internal.SymbolSectionVariables,
internal.SymbolSectionFunctions,
internal.SymbolSectionTypes} {
if [] != nil {
= append(, [])
}
}
return
}
func ( []*Symbol) {
sort.Slice(, func(, int) bool {
:= []
:= []
if .Synopsis != .Synopsis {
return .Synopsis < .Synopsis
}
return compareStringSlices(.Builds, .Builds) < 0
})
}
func (, []string) int {
for , := range {
if >= len() { // first slice is longer, so greater
return 1
}
if := strings.Compare(, []); != 0 {
return
}
}
if len() == len() {
return 0
return -1
}
func ( VersionsDetails) ( *internal.SymbolHistory, error) {
:= internal.NewSymbolHistory()
for , := range .ThisModule {
for , := range .Versions {
:= .Version
if .ThisModule[0].ModulePath == stdlib.ModulePath {
= stdlib.VersionForTag()
}
for , := range .Symbols {
for , := range {
if .New {
addSymbol(, , , .Builds)
}
for , := range .Children {
addSymbol(, , , .Builds)
}
}
}
}
}
return , nil
}
func ( *Symbol, string, *internal.SymbolHistory, []string) {
:= internal.SymbolMeta{
Name: .Name,
}
if len() == 0 {
.AddSymbol(, , internal.BuildContextAll)
return
}
for , := range {
:= strings.SplitN(, "/", 2)
var internal.BuildContext
switch [0] {
case "linux":
= internal.BuildContextLinux
case "darwin":
= internal.BuildContextDarwin
case "windows":
= internal.BuildContextWindows
case "js":
= internal.BuildContextJS
}
.AddSymbol(, , )
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |