class Jekyll::Commands::Build

def build(site, options)

Returns nothing.

options - A Hash of options passed to the command
site - the Jekyll::Site instance to build

Build your Jekyll site.
def build(site, options)
  t = Time.now
  source      = File.expand_path(options["source"])
  destination = File.expand_path(options["destination"])
  incremental = options["incremental"]
  Jekyll.logger.info "Source:", source
  Jekyll.logger.info "Destination:", destination
  Jekyll.logger.info "Incremental build:",
                     (incremental ? "enabled" : "disabled. Enable with --incremental")
  Jekyll.logger.info "Generating..."
  process_site(site)
  Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
end

def init_with_program(prog)

Create the Mercenary command for the Jekyll CLI for this Command
def init_with_program(prog)
  prog.command(:build) do |c|
    c.syntax      "build [options]"
    c.description "Build your site"
    c.alias :b
    add_build_options(c)
    c.action do |_, options|
      options["serving"] = false
      process_with_graceful_fail(c, options, self)
    end
  end
end

def process(options)

Continuously watch if `watch` is set to true in the config.
Build your jekyll site
def process(options)
  # Adjust verbosity quickly
  Jekyll.logger.adjust_verbosity(options)
  options = configuration_from_options(options)
  site = Jekyll::Site.new(options)
  if options.fetch("skip_initial_build", false)
    Jekyll.logger.warn "Build Warning:",
                       "Skipping the initial build. This may result in an out-of-date site."
  else
    build(site, options)
  end
  if options.fetch("detach", false)
    Jekyll.logger.info "Auto-regeneration:",
                       "disabled when running server detached."
  elsif options.fetch("watch", false)
    watch(site, options)
  else
    Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
  end
end

def watch(site, options)

Returns nothing.

options - A Hash of options passed to the command
site - A Jekyll::Site instance

Private: Watch for file changes and rebuild the site.
def watch(site, options)
  External.require_with_graceful_fail "jekyll-watch"
  Jekyll::Watcher.watch(options, site)
end