deps

package
v0.89.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2021 License: Apache-2.0 Imports: 19 Imported by: 894

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildState added in v0.69.0

type BuildState struct {
	// contains filtered or unexported fields
}

BuildState are flags that may be turned on during a build.

func NewBuildState added in v0.69.0

func NewBuildState() BuildState

func (*BuildState) Incr added in v0.69.0

func (b *BuildState) Incr() int

type Closer added in v0.80.0

type Closer interface {
	Close() error
}

type Closers added in v0.80.0

type Closers struct {
	// contains filtered or unexported fields
}

func (*Closers) Add added in v0.80.0

func (cs *Closers) Add(c Closer)

func (*Closers) Close added in v0.80.0

func (cs *Closers) Close() error

type Deps

type Deps struct {

	// The logger to use.
	Log loggers.Logger `json:"-"`

	// Used to log errors that may repeat itself many times.
	LogDistinct loggers.Logger

	// The file systems to use.
	Fs *hugofs.Fs `json:"-"`

	// The PathSpec to use
	*helpers.PathSpec `json:"-"`

	// The ContentSpec to use
	*helpers.ContentSpec `json:"-"`

	// The SourceSpec to use
	SourceSpec *source.SourceSpec `json:"-"`

	// The Resource Spec to use
	ResourceSpec *resources.Spec

	// The configuration to use
	Cfg config.Provider `json:"-"`

	// The file cache to use.
	FileCaches filecache.Caches

	// The translation func to use
	Translate func(translationID string, templateData interface{}) string `json:"-"`

	// The language in use. TODO(bep) consolidate with site
	Language *langs.Language

	// The site building.
	Site page.Site

	// All the output formats available for the current site.
	OutputFormatsConfig output.Formats

	WithTemplate func(templ tpl.TemplateManager) error `json:"-"`

	// Used in tests
	OverloadedTemplateFuncs map[string]interface{}

	Metrics metrics.Provider

	// Timeout is configurable in site config.
	Timeout time.Duration

	// BuildStartListeners will be notified before a build starts.
	BuildStartListeners *Listeners

	// Resources that gets closed when the build is done or the server shuts down.
	BuildClosers *Closers

	// Atomic values set during a build.
	// This is common/global for all sites.
	BuildState *BuildState

	// Whether we are in running (server) mode
	Running bool
	// contains filtered or unexported fields
}

Deps holds dependencies used by many. There will be normally only one instance of deps in play at a given time, i.e. one per Site built.

func New

func New(cfg DepsCfg) (*Deps, error)

New initializes a Dep struct. Defaults are set for nil values, but TemplateProvider, TranslationProvider and Language are always required.

func (*Deps) Close added in v0.80.0

func (d *Deps) Close() error

func (Deps) ForLanguage

func (d Deps) ForLanguage(cfg DepsCfg, onCreated func(d *Deps) error) (*Deps, error)

ForLanguage creates a copy of the Deps with the language dependent parts switched out.

func (*Deps) LoadResources

func (d *Deps) LoadResources() error

LoadResources loads translations and templates.

func (Deps) SendError added in v0.54.0

func (e Deps) SendError(err error)

SendErr sends the error on a channel to be handled later. This can be used in situations where returning and aborting the current operation isn't practical.

func (*Deps) SetTextTmpl added in v0.63.0

func (d *Deps) SetTextTmpl(tmpl tpl.TemplateParseFinder)

func (*Deps) SetTmpl added in v0.63.0

func (d *Deps) SetTmpl(tmpl tpl.TemplateHandler)

func (Deps) StartErrorCollector added in v0.54.0

func (e Deps) StartErrorCollector() chan error

func (*Deps) TextTmpl added in v0.45.1

func (d *Deps) TextTmpl() tpl.TemplateParseFinder

func (*Deps) Tmpl

func (d *Deps) Tmpl() tpl.TemplateHandler

type DepsCfg

type DepsCfg struct {

	// The Logger to use.
	Logger loggers.Logger

	// The file systems to use
	Fs *hugofs.Fs

	// The language to use.
	Language *langs.Language

	// The Site in use
	Site page.Site

	// The configuration to use.
	Cfg config.Provider

	// The media types configured.
	MediaTypes media.Types

	// The output formats configured.
	OutputFormats output.Formats

	// Template handling.
	TemplateProvider ResourceProvider
	WithTemplate     func(templ tpl.TemplateManager) error
	// Used in tests
	OverloadedTemplateFuncs map[string]interface{}

	// i18n handling.
	TranslationProvider ResourceProvider

	// Whether we are in running (server) mode
	Running bool
}

DepsCfg contains configuration options that can be used to configure Hugo on a global level, i.e. logging etc. Nil values will be given default values.

type Listeners added in v0.45.1

type Listeners struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Listeners represents an event listener.

func (*Listeners) Add added in v0.45.1

func (b *Listeners) Add(f func())

Add adds a function to a Listeners instance.

func (*Listeners) Notify added in v0.45.1

func (b *Listeners) Notify()

Notify executes all listener functions.

type ResourceProvider

type ResourceProvider interface {
	Update(deps *Deps) error
	Clone(deps *Deps) error
}

ResourceProvider is used to create and refresh, and clone resources needed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL