Class: JekyllDocs::DocsCommand

Inherits:
Jekyll::Command
  • Object
show all
Defined in:
lib/jekyll-docs.rb

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll-docs.rb', line 8

def init_with_program(prog)
  prog.command(:docs) do |cmd|
    cmd.description "Start a local server for the Jekyll documentation"
    cmd.syntax "docs [options]"
    cmd.alias :d

    cmd.option "port", "-P", "--port", "Port to listen on."

    cmd.action do |_, opts|
      JekyllDocs::DocsCommand.process(opts)
    end
  end
end

.process(opts) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jekyll-docs.rb', line 22

def process(opts)
  Dir.mktmpdir do |dest_dir|
    options = opts.merge({
      "serving"     => true,
      "watch"       => false,
      "config"      => File.expand_path("../../site/_config.yml", __FILE__),
      "source"      => File.expand_path("../../site", __FILE__),
      "destination" => dest_dir
    })
    Jekyll::Commands::Build.process(options)
    Jekyll::Commands::Serve.process(options)
  end
end