deps

package
v0.45.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {

	// The logger to use.
	Log *jww.Notepad `json:"-"`

	// Used to log errors that may repeat itself many times.
	DistinctErrorLog *helpers.DistinctLogger

	// The templates to use. This will usually implement the full tpl.TemplateHandler.
	Tmpl tpl.TemplateFinder `json:"-"`

	// We use this to parse and execute ad-hoc text templates.
	TextTmpl tpl.TemplateParseFinder `json:"-"`

	// 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 *resource.Spec

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

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

	Language *langs.Language

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

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

	Metrics metrics.Provider

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

	// BuildStartListeners will be notified before a build starts.
	BuildStartListeners *Listeners
	// 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) ForLanguage

func (d Deps) ForLanguage(cfg DepsCfg) (*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) TemplateHandler added in v0.22.1

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

TemplateHandler returns the used tpl.TemplateFinder as tpl.TemplateHandler.

type DepsCfg

type DepsCfg struct {

	// The Logger to use.
	Logger *jww.Notepad

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

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

	// The configuration to use.
	Cfg config.Provider

	// The media types configured.
	MediaTypes media.Types

	// Template handling.
	TemplateProvider ResourceProvider
	WithTemplate     func(templ tpl.TemplateHandler) error

	// 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
}

func (*Listeners) Add added in v0.45.1

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

func (*Listeners) Notify added in v0.45.1

func (b *Listeners) Notify()

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