Documentation ¶
Overview ¶
Package provides ways to identify values in Hugo. Used for dependency tracking etc.
Package provides ways to identify values in Hugo. Used for dependency tracking etc.
Index ¶
- Constants
- Variables
- func CleanString(s string) string
- func NewPredicateIdentity(probablyDependent func(Identity) bool, probablyDependency func(Identity) bool) *predicateIdentity
- func PrintIdentityInfo(v any)
- func WalkIdentitiesDeep(v any, cb func(level int, id Identity) bool)
- func WalkIdentitiesShallow(v any, cb func(level int, id Identity) bool)
- type DependencyManagerProvider
- type DependencyManagerProviderFunc
- type DependencyManagerScopedProvider
- type FindFirstManagerIdentityProvider
- type Finder
- type FinderConfig
- type FinderResult
- type ForEeachIdentityByNameProvider
- type ForEeachIdentityProvider
- type ForEeachIdentityProviderFunc
- type Identities
- type Identity
- type IdentityGroupProvider
- type IdentityProvider
- type IncrementByOne
- type Incrementer
- type IsProbablyDependencyProvider
- type IsProbablyDependentProvider
- type Manager
- type ManagerIdentity
- type ManagerOption
- type Question
- type SignalRebuilder
- type StringIdentity
Constants ¶
const ( // Anonymous is an Identity that can be used when identity doesn't matter. Anonymous = StringIdentity("__anonymous") // GenghisKhan is an Identity everyone relates to. GenghisKhan = StringIdentity("__genghiskhan") )
Variables ¶
var NopManager = new(nopManager)
Functions ¶
func CleanString ¶ added in v0.123.0
CleanString cleans s to be suitable as an identifier.
func NewPredicateIdentity ¶ added in v0.123.0
func NewPredicateIdentity( probablyDependent func(Identity) bool, probablyDependency func(Identity) bool, ) *predicateIdentity
NewPredicateIdentity creates a new Identity that implements both IsProbablyDependencyProvider and IsProbablyDependentProvider using the provided functions, both of which are optional.
func PrintIdentityInfo ¶ added in v0.123.0
func PrintIdentityInfo(v any)
PrintIdentityInfo is used for debugging/tests only.
func WalkIdentitiesDeep ¶ added in v0.123.0
WalkIdentitiesDeep walks identities in v and applies cb to every identity found. Return true from cb to terminate. If deep is true, it will also walk nested Identities in any Manager found.
Types ¶
type DependencyManagerProvider ¶ added in v0.123.0
type DependencyManagerProvider interface {
GetDependencyManager() Manager
}
DependencyManagerProvider provides a manager for dependencies.
type DependencyManagerProviderFunc ¶ added in v0.123.0
type DependencyManagerProviderFunc func() Manager
DependencyManagerProviderFunc is a function that implements the DependencyManagerProvider interface.
func (DependencyManagerProviderFunc) GetDependencyManager ¶ added in v0.123.0
func (d DependencyManagerProviderFunc) GetDependencyManager() Manager
type DependencyManagerScopedProvider ¶ added in v0.123.0
type DependencyManagerScopedProvider interface { GetDependencyManagerForScope(scope int) Manager GetDependencyManagerForScopesAll() []Manager }
DependencyManagerScopedProvider provides a manager for dependencies with a given scope.
type FindFirstManagerIdentityProvider ¶ added in v0.123.0
type FindFirstManagerIdentityProvider interface { Identity FindFirstManagerIdentity() ManagerIdentity }
func NewFindFirstManagerIdentityProvider ¶ added in v0.123.0
func NewFindFirstManagerIdentityProvider(m Manager, id Identity) FindFirstManagerIdentityProvider
type Finder ¶ added in v0.123.0
type Finder struct {
// contains filtered or unexported fields
}
Finder finds identities inside another.
func NewFinder ¶ added in v0.123.0
func NewFinder(cfg FinderConfig) *Finder
NewFinder creates a new Finder. This is a thread safe implementation with a cache.
type FinderConfig ¶ added in v0.123.0
type FinderConfig struct { // Match exact matches only. Exact bool }
FinderConfig provides configuration for the Finder. Note that we by default will use a strategy where probable matches are good enough. The primary use case for this is to identity the change set for a given changed identity (e.g. a template), and we don't want to have any false negatives there, but some false positives are OK. Also, speed is important.
type FinderResult ¶ added in v0.123.0
type FinderResult int
const ( FinderNotFound FinderResult = iota FinderFoundOneOfManyRepetition FinderFoundOneOfMany FinderFound )
type ForEeachIdentityByNameProvider ¶ added in v0.123.0
type ForEeachIdentityByNameProvider interface { // ForEeachIdentityByName calls cb for each Identity that relates to name. // If cb returns true, the iteration is terminated. ForEeachIdentityByName(name string, cb func(id Identity) bool) }
ForEeachIdentityByNameProvider provides a way to look up identities by name.
type ForEeachIdentityProvider ¶ added in v0.123.0
type ForEeachIdentityProvider interface { // ForEeachIdentityProvider calls cb for each Identity. // If cb returns true, the iteration is terminated. // The return value is whether the iteration was terminated. ForEeachIdentity(cb func(id Identity) bool) bool }
ForEeachIdentityProvider provides a way iterate over identities.
type ForEeachIdentityProviderFunc ¶ added in v0.123.0
ForEeachIdentityProviderFunc is a function that implements the ForEeachIdentityProvider interface.
func (ForEeachIdentityProviderFunc) ForEeachIdentity ¶ added in v0.123.0
func (f ForEeachIdentityProviderFunc) ForEeachIdentity(cb func(id Identity) bool) bool
type Identities ¶
Identities stores identity providers.
func (Identities) AsSlice ¶ added in v0.123.0
func (ids Identities) AsSlice() []Identity
func (Identities) String ¶ added in v0.123.0
func (ids Identities) String() string
type Identity ¶
type Identity interface {
IdentifierBase() string
}
Identity represents a thing in Hugo (a Page, a template etc.) Any implementation must be comparable/hashable.
func FirstIdentity ¶ added in v0.123.0
FirstIdentity returns the first Identity in v, Anonymous if none found
func NewGlobIdentity ¶ added in v0.123.0
NewGlobIdentity creates a new Identity that is probably dependent on any other Identity that matches the given pattern.
type IdentityGroupProvider ¶ added in v0.123.0
type IdentityGroupProvider interface {
GetIdentityGroup() Identity
}
IdentityGroupProvider can be implemented by tightly connected types. Current use case is Resource transformation via Hugo Pipes.
type IdentityProvider ¶ added in v0.123.0
type IdentityProvider interface {
GetIdentity() Identity
}
IdentityProvider can be implemented by types that isn't itself and Identity, usually because they're not comparable/hashable.
type IncrementByOne ¶ added in v0.69.0
type IncrementByOne struct {
// contains filtered or unexported fields
}
IncrementByOne implements Incrementer adding 1 every time Incr is called.
func (*IncrementByOne) Incr ¶ added in v0.69.0
func (c *IncrementByOne) Incr() int
type Incrementer ¶ added in v0.69.0
type Incrementer interface {
Incr() int
}
Incrementer increments and returns the value. Typically used for IDs.
type IsProbablyDependencyProvider ¶ added in v0.123.0
IsProbablyDependencyProvider is an optional interface for Identity.
type IsProbablyDependentProvider ¶ added in v0.123.0
IsProbablyDependentProvider is an optional interface for Identity.
type Manager ¶
type Manager interface { Identity AddIdentity(ids ...Identity) AddIdentityForEach(ids ...ForEeachIdentityProvider) GetIdentity() Identity Reset() // contains filtered or unexported methods }
Manager is an Identity that also manages identities, typically dependencies.
func GetDependencyManager ¶ added in v0.123.0
GetDependencyManager returns the DependencyManager from v or nil if none found.
func NewManager ¶
func NewManager(name string, opts ...ManagerOption) Manager
NewIdentityManager creates a new Manager.
type ManagerIdentity ¶ added in v0.123.0
ManagerIdentity wraps a pair of Identity and Manager.
func (ManagerIdentity) String ¶ added in v0.123.0
func (p ManagerIdentity) String() string
type ManagerOption ¶ added in v0.123.0
type ManagerOption func(m *identityManager)
func WithOnAddIdentity ¶ added in v0.123.0
func WithOnAddIdentity(f func(id Identity)) ManagerOption
WithOnAddIdentity sets a callback that will be invoked when an identity is added to the manager.
type Question ¶ added in v0.123.0
A Question is defined by its Identity and can be answered once.
func NewQuestion ¶ added in v0.123.0
NewQuestion creates a new question with the given identity.
type SignalRebuilder ¶ added in v0.127.0
type SignalRebuilder interface {
SignalRebuild(ids ...Identity)
}
SignalRebuilder is an optional interface for types that can signal a rebuild.
type StringIdentity ¶ added in v0.123.0
type StringIdentity string
StringIdentity is an Identity that wraps a string.
func CleanStringIdentity ¶ added in v0.123.0
func CleanStringIdentity(s string) StringIdentity
CleanStringIdentity cleans s to be suitable as an identifier and wraps it in a StringIdentity.
func (StringIdentity) IdentifierBase ¶ added in v0.123.0
func (s StringIdentity) IdentifierBase() string