Copyright 2021 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package dochtml

import (
	
	
	
	

	
	
	
	
)
GetSymbols renders package documentation HTML for the provided file set and package, in separate parts. If any of the rendered documentation part HTML sizes exceeds the specified limit, an error with ErrTooLarge in its chain will be returned.
func ( *doc.Package,  *token.FileSet) ( []*internal.Symbol,  error) {
	defer derrors.Wrap(&, "GetSymbols for %q", .ImportPath)
	if docIsEmpty() {
		return nil, nil
	}
	,  := types(, )
	if  != nil {
		return nil, 
	}
	,  := variables(.Vars, )
	if  != nil {
		return nil, 
	}
	return append(append(append(
		constants(.Consts), ...), functions(, )...), ...), nil
}

func ( []*doc.Value) []*internal.Symbol {
	var  []*internal.Symbol
	for ,  := range  {
		for ,  := range .Names {
			if  == "_" {
				continue
			}
			 = append(, &internal.Symbol{
				SymbolMeta: internal.SymbolMeta{
					Name:     ,
					Synopsis: "const " + ,
					Section:  internal.SymbolSectionConstants,
					Kind:     internal.SymbolKindConstant,
				},
			})
		}
	}
	return 
}

func ( []*doc.Value,  *token.FileSet) ( []*internal.Symbol,  error) {
	defer derrors.Wrap(&, "variables")
	var  []*internal.Symbol
	for ,  := range  {
		 := .Decl.Specs
		for ,  := range  {
			 := .(*ast.ValueSpec) // must succeed; we can't mix types in one GenDecl.
			for ,  := range .Names {
				if .Name == "_" {
					continue
				}
				 := *
				if len(.Names) != 0 {
					.Names = []*ast.Ident{}
				}
				 := render.ConstOrVarSynopsis(&, , token.VAR, "", 0, 0)
				 = append(,
					&internal.Symbol{
						SymbolMeta: internal.SymbolMeta{
							Name:     .Name,
							Synopsis: ,
							Section:  internal.SymbolSectionVariables,
							Kind:     internal.SymbolKindVariable,
						},
					})
			}

		}
	}
	return , nil
}

func ( *doc.Package,  *token.FileSet) []*internal.Symbol {
	var  []*internal.Symbol
	for ,  := range .Funcs {
		 = append(, &internal.Symbol{
			SymbolMeta: internal.SymbolMeta{
				Name:     .Name,
				Synopsis: render.OneLineNodeDepth(, .Decl, 0),
				Section:  internal.SymbolSectionFunctions,
				Kind:     internal.SymbolKindFunction,
			},
		})
	}
	return 
}

func ( *doc.Package,  *token.FileSet) ([]*internal.Symbol, error) {
	var  []*internal.Symbol
	for ,  := range .Types {
		 := .Decl.Specs
		if len() != 1 {
			return nil, fmt.Errorf("unexpected number of t.Decl.Specs: %d (wanted len = 1)", len(.Decl.Specs))
		}
		,  := [0].(*ast.TypeSpec)
		if ! {
			return nil, fmt.Errorf("unexpected type for Spec node: %q", .Name)
		}
		,  := methodsForType(, , )
		if  != nil {
			return nil, 
		}
		 := &internal.Symbol{
			SymbolMeta: internal.SymbolMeta{
				Name:     .Name,
				Synopsis: strings.TrimSuffix(strings.TrimSuffix(render.OneLineNodeDepth(, , 0), "{ ... }"), "{}"),
				Section:  internal.SymbolSectionTypes,
				Kind:     internal.SymbolKindType,
			},
		}
		 := fieldsForType(.Name, , )
		if  != nil {
			return nil, 
		}
		 = append(, )
		,  := variablesForType(, )
		if  != nil {
			return nil, 
		}
		.Children = append(append(append(append(append(
			.Children,
			constantsForType()...),
			...),
			functionsForType(, )...),
			...),
			...)
	}
	return , nil
}

func ( *doc.Type) []*internal.SymbolMeta {
	 := constants(.Consts)
	var  []*internal.SymbolMeta
	for ,  := range  {
		 := .SymbolMeta
		.ParentName = .Name
		.Section = internal.SymbolSectionTypes
		 = append(, &)
	}
	return 
}

func ( *doc.Type,  *token.FileSet) ( []*internal.SymbolMeta,  error) {
	,  := variables(.Vars, )
	if  != nil {
		return nil, 
	}
	var  []*internal.SymbolMeta
	for ,  := range  {
		 := .SymbolMeta
		.ParentName = .Name
		.Section = internal.SymbolSectionTypes
		 = append(, &)
	}
	return , nil
}

func ( *doc.Type,  *token.FileSet) []*internal.SymbolMeta {
	var  []*internal.SymbolMeta
	for ,  := range .Funcs {
		 = append(, &internal.SymbolMeta{
			Name:       .Name,
			ParentName: .Name,
			Kind:       internal.SymbolKindFunction,
			Synopsis:   render.OneLineNodeDepth(, .Decl, 0),
			Section:    internal.SymbolSectionTypes,
		})
	}
	return 
}

func ( string,  *ast.TypeSpec,  *token.FileSet) []*internal.SymbolMeta {
	,  := .Type.(*ast.StructType)
	if ! {
		return nil
	}
	var  []*internal.SymbolMeta
It's not possible for there to be more than one name. FieldList is also used by go/ast for st.Methods, which is the only reason this type is a list.
		for ,  := range .Names {
			 := fmt.Sprintf("%s %s", , render.OneLineNodeDepth(, .Type, 0))
			 :=  + "." + .Name
			 = append(, &internal.SymbolMeta{
				Name:       ,
				ParentName: ,
				Kind:       internal.SymbolKindField,
				Synopsis:   ,
				Section:    internal.SymbolSectionTypes,
			})
		}
	}
	return 
}

func ( *doc.Type,  *ast.TypeSpec,  *token.FileSet) ([]*internal.SymbolMeta, error) {
	var  []*internal.SymbolMeta
	for ,  := range .Methods {
		 = append(, &internal.SymbolMeta{
			Name:       .Name + "." + .Name,
			ParentName: .Name,
			Kind:       internal.SymbolKindMethod,
			Synopsis:   render.OneLineNodeDepth(, .Decl, 0),
			Section:    internal.SymbolSectionTypes,
		})
	}
	if ,  := .Type.(*ast.InterfaceType);  {
It's not possible for there to be more than one name. FieldList is also used by go/ast for st.Methods, which is the only reason this type is a list.
			if len(.Names) > 1 {
				return nil, fmt.Errorf("len(m.Names) = %d; expected 0 or 1", len(.Names))
			}
			for ,  := range .Names {
				 := .Name + "." + .Name
				 := render.OneLineField(, , 0)
				 = append(, &internal.SymbolMeta{
					Name:       ,
					ParentName: .Name,
					Kind:       internal.SymbolKindMethod,
					Synopsis:   ,
					Section:    internal.SymbolSectionTypes,
				})
			}
		}
	}
	return , nil