Class: Octopress::Docs::Commands

Inherits:
Command
  • Object
show all
Defined in:
lib/octopress/commands/docs.rb

Class Method Summary collapse

Methods inherited from Command

inherited, #init_with_program, subclasses

Class Method Details

.init_with_program(p) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/octopress/commands/docs.rb', line 4

def self.init_with_program(p)
  p.command(:docs) do |c|
    c.syntax 'octopress docs'
    c.description "Launch local server with docs for Octopress v#{Octopress::VERSION} and Octopress plugins."

    c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
    c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
    if ENV['OCTODEV']
      c.option 'watch', '--watch', 'Watch docs site for changes and rebuild. (For docs development)'
    end

    c.action do |args, options|
      serve_docs(options)
    end
  end
end

.serve_docs(options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/octopress/commands/docs.rb', line 21

def self.serve_docs(options)

  # Activate dependencies for serving docs.
  #
  options = Docs.load_docs(options)

  if defined? Octopress::Ink
    Octopress::Ink.load_plugin_assets = false
  end

  
  Jekyll.logger.log_level = :error
  Jekyll::Commands::Build.process(options)
  url = "http://#{options['host']}:#{options['port']}"
  puts "Serving Docs site: #{url}"
  puts "  press ctrl-c to stop."
  Jekyll::Commands::Serve.process(options)
  Jekyll.logger.log_level = :info
end