Ship jekyll-docs properly

This commit is contained in:
Parker Moore 2016-02-19 16:47:24 -08:00
parent 32c5ac35dd
commit 5d66a12ed4
5 changed files with 79 additions and 0 deletions

3
jekyll-docs/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
jekyll
site
Gemfile.lock

2
jekyll-docs/Gemfile Normal file
View File

@ -0,0 +1,2 @@
source 'https://rubygems.org'
gemspec

19
jekyll-docs/Rakefile Normal file
View File

@ -0,0 +1,19 @@
require "bundler/gem_tasks"
task :build => :init
task :default => :init
def jekyll_version
ENV.fetch('JEKYLL_VERSION')
end
task :init do
sh "git clone git://github.com/jekyll/jekyll.git jekyll" unless Dir.exist? "jekyll/.git"
Dir.chdir("jekyll") { sh "git checkout v#{jekyll_version}" }
rm_rf "site"
cp_r "jekyll/site", "site"
end
task :teardown do
rm_rf "site"
rm_rf "jekyll"
end

View File

@ -0,0 +1,21 @@
# coding: utf-8
require File.expand_path('../../lib/jekyll/version', __FILE__)
Gem::Specification.new do |spec|
spec.name = 'jekyll-docs'
spec.version = ENV.fetch('JEKYLL_VERSION')
spec.authors = ['Parker Moore']
spec.email = ['parkrmoore@gmail.com']
spec.summary = %q{Offline usage documentation for Jekyll.}
spec.homepage = 'http://jekyllrb.com'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0").grep(%r{^site/})
spec.files << "lib/jekyll-docs.rb"
spec.require_paths = ['lib']
spec.add_dependency 'jekyll', Jekyll::VERSION
spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 10.0'
end

View File

@ -0,0 +1,34 @@
require 'rubygems'
require 'jekyll'
module JekyllDocs
class DocsCommand < Jekyll::Command
class << self
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
def process(opts)
Dir.mktmpdir do |dest_dir|
Jekyll::Commands::Serve.process(opts.merge({
"serving" => true,
"watch" => false,
"config" => File.expand_path("../../site/_config.yml", __FILE__),
"source" => File.expand_path("../../site/", __FILE__),
"destination" => dest_dir
}))
end
end
end
end
end