Class Nanoc::Compiler
In: lib/nanoc/base/compilation/compiler.rb
Parent: Object

Responsible for compiling a site’s item representations.

The compilation process makes use of notifications (see {Nanoc::NotificationCenter}) to track dependencies between items, layouts, etc. The following notifications are used:

  • `compilation_started` — indicates that the compiler has started compiling this item representation. Has one argument: the item representation itself. Only one item can be compiled at a given moment; therefore, it is not possible to get two consecutive `compilation_started` notifications without also getting a `compilation_ended` notification in between them.
  • `compilation_ended` — indicates that the compiler has finished compiling this item representation (either successfully or with failure). Has one argument: the item representation itself.
  • `visit_started` — indicates that the compiler requires content or attributes from the item representation that will be visited. Has one argument: the visited item identifier. This notification is used to track dependencies of items on other items; a `visit_started` event followed by another `visit_started` event indicates that the item corresponding to the former event will depend on the item from the latter event.
  • `visit_ended` — indicates that the compiler has finished visiting the item representation and that the requested attributes or content have been fetched (either successfully or with failure)
  • `processing_started` — indicates that the compiler has started processing the specified object, which can be an item representation (when it is compiled) or a layout (when it is used to lay out an item representation or when it is used as a partial)
  • `processing_ended` — indicates that the compiler has finished processing the specified object.

Methods

Attributes

site  [R]  @return [Nanoc::Site] The site this compiler belongs to
stack  [R]  The compilation stack. When the compiler begins compiling a rep or a layout, it will be placed on the stack; when it is done compiling the rep or layout, it will be removed from the stack.

@return [Array] The compilation stack

Public Class methods

Creates a new compiler fo the given site

@param [Nanoc::Site] site The site this compiler belongs to

Public Instance methods

@param [Nanoc::ItemRep] rep The item representation for which the

  assigns should be fetched

@return [Hash] The assigns that should be used in the next filter/layout

  operation

@api private

Creates the representations of all items as defined by the compilation rules.

@api private

Returns the dependency tracker for this site, creating it first if it does not yet exist.

@api private

@return [Nanoc::DependencyTracker] The dependency tracker for this site

Load the helper data that is used for compiling the site.

@api private

@return [void]

Returns all objects managed by the site (items, layouts, code snippets, site configuration and the rules).

@api private

@return [Nanoc::OutdatednessChecker] The outdatedness checker

Runs the preprocessor.

@api private

Determines the paths of all item representations.

@api private

@return [Nanoc::RulesCollection] The collection of rules to be used

  for compiling this site

Compiles the site and writes out the compiled item representations.

Previous versions of nanoc (< 3.2) allowed passing items to compile, and had a “force” option to make the compiler recompile all pages, even when not outdated. These arguments and options are, as of nanoc 3.2, no longer used, and will simply be ignored when passed to {run}.

@overload run

  @return [void]

Store the modified helper data used for compiling the site.

@api private

@return [void]

Undoes the effects of {load}. Used when {load} raises an exception.

@api private

@return [void]

[Validate]