Sha256: a451c6ff8cf2c65670bd2cd692d8f717232a576ff54a64fcb0e90dee5477800f

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'jekyll'
require File.expand_path('helpers', File.dirname(__FILE__))

module Octopress
  class Docs < Command
    def self.init_with_program(p)
      p.command(:docs) do |c|
        c.syntax 'octopress docs'
        c.description "Soon: Launch local server with docs for Octopress v#{Octopress::VERSION}"

        c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
        c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
        c.option 'jekyll', '--jekyll', "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"

        c.action do |args, options|
          
          # Only show jekyll docs if the jekyll flag was used
          #
          if options['jekyll']
            options.delete('jekyll')

            # Find local Jekyll gem path
            #
            spec = Gem::Specification.find_by_name("jekyll")
            gem_path = spec.gem_dir

            options = CommandHelpers.normalize_options(options)
            options = ::Jekyll.configuration(options.to_symbol_keys.merge!({
              'source' => "#{gem_path}/site",
              'destination' => "#{gem_path}/site/_site"
            }))
            
            ::Jekyll::Commands::Build.process(options)
            ::Jekyll::Commands::Serve.process(options)
          else
            puts "Sorry, not yet. View Octopress docs on http://octopress.org or view Jekyll docs locally by running `octopress docs --jekyll`"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octopress-3.0.0.alpha7 lib/octopress/commands/docs.rb
octopress-3.0.0.alpha6 lib/octopress/commands/docs.rb
octopress-3.0.0.alpha5 lib/octopress/commands/docs.rb
octopress-3.0.0.alpha4 lib/octopress/commands/docs.rb