Documentation
¶
Index ¶
- Constants
- Variables
- func FuncName(f any) string
- func GetDoc(val, owner reflect.Value, field *reflect.StructField, label string) (string, bool)
- func TypeName(typ reflect.Type) string
- func TypeNameObj(v any) string
- type Directive
- type Directives
- type Field
- type Fields
- type Func
- type Method
- type Methods
- type Type
- func AddType(typ *Type) *Type
- func AllEmbeddersOf(typ *Type) []*Type
- func TypeByName(nm string) *Type
- func TypeByNameTry(nm string) (*Type, error)
- func TypeByReflectType(typ reflect.Type) *Type
- func TypeByReflectTypeTry(typ reflect.Type) (*Type, error)
- func TypeByValue(val any) *Type
- func TypeByValueTry(val any) (*Type, error)
Constants ¶
const ( // Version is the version of this package being used Version = "v0.1.32" // GitCommit is the commit just before the latest version commit GitCommit = "4749ff1" // VersionDate is the date-time of the latest version commit in UTC (in the format 'YYYY-MM-DD HH:MM', which is the Go format '2006-01-02 15:04') VersionDate = "2023-12-26 23:26" )
Variables ¶
var ( // Funcs records all types (i.e., a type registry) // key is long type name: package_url.Func, e.g., goki.dev/gi/v2/gi.Button Funcs = map[string]*Func{} // FuncIDCounter is an atomically incremented uint64 used // for assigning new [Func.ID] numbers FuncIDCounter uint64 )
var ( // Types records all types (i.e., a type registry) // key is long type name: package_url.Type, e.g., goki.dev/gi/v2/gi.Button Types = map[string]*Type{} // TypeIDCounter is an atomically incremented uint64 used // for assigning new [Type.ID] numbers TypeIDCounter uint64 )
Functions ¶
func FuncName ¶
FuncName returns the fully package-qualified name of given function This is guaranteed to be unique and used for the Funcs registry.
func GetDoc ¶ added in v0.1.24
GetDoc gets the documentation for the given value with the given owner value, field, and label. The value, owner value, and field may be nil/invalid. The owner value, if valid, is the value that contains the value (the parent struct, map, slice, or array). The field, if non-nil, is the struct field that the value represents. GetDoc uses the given label to format the documentation with sentence.Doc before returning it.
func TypeName ¶
TypeName returns the long, full package-path qualified type name. This is guaranteed to be unique and used for the Types registry.
func TypeNameObj ¶
TypeNameObj returns the long, full package-path qualified type name from given object. Automatically finds the non-pointer base type. This is guaranteed to be unique and used for the Types registry.
Types ¶
type Directive ¶
Directive represents a comment directive in the format:
//tool:directive args...
type Directives ¶
type Directives []*Directive
func (Directives) ForTool ¶
func (d Directives) ForTool(tool string) Directives
ForTool returns all of the directives in these directives that have the given tool name.
func (Directives) GoString ¶
func (d Directives) GoString() string
GoString returns the directives as Go code.
type Field ¶
type Field struct { // Name is the name of the field (eg: Icon) Name string // Type has the fully-package-path-qualified name of the type, // which can be used to look up the type in the Types registry // (eg: goki.dev/gi/v2/gi.Button) Type string // LocalType is the shorter, local name of the type from the // perspective of the code where this field is declared // (eg: gi.Button or Button, depending on where this is) LocalType string // Doc has all of the comment documentation // info as one string with directives removed. Doc string // Directives has the parsed comment directives Directives Directives // Tag, if this field is part of a struct, contains the struct // tag for it. Tag reflect.StructTag }
Field represents a field or embed in a struct, or an argument or return value of a function.
type Func ¶
type Func struct { // Name is the fully-qualified name of the function // (eg: goki.dev/gi/v2/gi.NewButton) Name string // Doc has all of the comment documentation // info as one string with directives removed. Doc string // Directives has the parsed comment directives Directives Directives // Args are arguments to the function Args *Fields // Returns are return values of the function Returns *Fields // unique type ID number ID uint64 }
Func represents a global function
func FuncByName ¶
FuncByName returns a Func by name (package_url.Type, e.g., goki.dev/gi/v2/gi.Button),
func FuncByNameTry ¶
FuncByNameTry returns a Func by name (package_url.Type, e.g., goki.dev/gi/v2/gi.Button), or error if not found
func FuncInfoTry ¶
FuncInfoTry returns function info for given function.
type Method ¶
type Method struct { // Name is the name of the method (eg: NewChild) Name string // Doc has all of the comment documentation // info as one string with directives removed. Doc string // Directives has the parsed comment directives Directives Directives // Args are arguments to the method Args *Fields // Returns are return values of the method Returns *Fields }
Method represents a method
type Type ¶
type Type struct { // Name is the fully package-path-qualified name of the type (eg: goki.dev/gi/v2/gi.Button) Name string // ShortName is the short, package-qualified name of the type (eg: gi.Button) ShortName string // IDName is the short, package-unqualified, kebab-case name of the type that is suitable // for use in an ID (eg: button) IDName string // Doc has all of the comment documentation // info as one string with directives removed. Doc string // Directives has the parsed comment directives Directives Directives // unique type ID number ID uint64 // Methods are available for all types Methods *Methods // Embedded fields for struct types Embeds *Fields // Fields for struct types Fields *Fields // instance of the type Instance any // All embedded fields (including nested ones) for struct types; // not set by gtigen -- HasEmbed automatically compiles it as needed. // Key is the ID of the type. AllEmbeds map[uint64]*Type }
Type represents a type
func AllEmbeddersOf ¶ added in v0.1.7
AllEmbeddersOf returns all registered types that embed the given type. List is sorted in alpha order by fully package-path-qualified Name.
func TypeByName ¶
TypeByName returns a Type by name (package_url.Type, e.g., goki.dev/gi/v2/gi.Button),
func TypeByNameTry ¶
TypeByNameTry returns a Type by name (package_url.Type, e.g., goki.dev/gi/v2/gi.Button), or error if not found
func TypeByReflectType ¶ added in v0.1.24
TypeByReflectType returns the Type of the given reflect type
func TypeByReflectTypeTry ¶ added in v0.1.24
TypeByReflectTypeTry returns the Type of the given reflect type, or an error if it is not found
func TypeByValueTry ¶
TypeByValueTry returns the Type of the given value, or an error if it is not found
func (*Type) CompileEmbeds ¶
func (tp *Type) CompileEmbeds()
func (*Type) HasEmbed ¶
HasEmbed returns true if this type has the given type at any level of embedding depth, including if this type is the given type. The first time called it will Compile a map of all embedded types so subsequent calls are very fast.
func (*Type) ReflectType ¶
ReflectType returns the reflect.Type for this type, using the Instance