Separate jekyll-docs out into a separate gem & bless it
This commit is contained in:
parent
657b16519e
commit
ac41312c5d
|
@ -6,12 +6,9 @@ $:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
||||||
require 'jekyll'
|
require 'jekyll'
|
||||||
require 'mercenary'
|
require 'mercenary'
|
||||||
|
|
||||||
%w[jekyll-import].each do |blessed_gem|
|
Jekyll::External.require_if_present(
|
||||||
begin
|
Jekyll::External.blessed_gems
|
||||||
require blessed_gem
|
)
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Jekyll::PluginManager.require_from_bundler
|
Jekyll::PluginManager.require_from_bundler
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
module Jekyll
|
|
||||||
module Commands
|
|
||||||
class Docs < Command
|
|
||||||
|
|
||||||
class << self
|
|
||||||
|
|
||||||
def init_with_program(prog)
|
|
||||||
prog.command(:docs) do |c|
|
|
||||||
c.syntax 'docs'
|
|
||||||
c.description "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"
|
|
||||||
|
|
||||||
c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
|
|
||||||
c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
|
|
||||||
|
|
||||||
c.action do |args, options|
|
|
||||||
options.merge!({
|
|
||||||
'source' => File.expand_path("../../../site", File.dirname(__FILE__)),
|
|
||||||
'destination' => File.expand_path("../../../site/_site", File.dirname(__FILE__))
|
|
||||||
})
|
|
||||||
Jekyll::Commands::Build.process(options)
|
|
||||||
Jekyll::Commands::Serve.process(options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
module Jekyll
|
||||||
|
module External
|
||||||
|
class << self
|
||||||
|
|
||||||
|
#
|
||||||
|
# Gems that, if installed, should be loaded.
|
||||||
|
# Usually contain subcommands.
|
||||||
|
#
|
||||||
|
def blessed_gems
|
||||||
|
%w{
|
||||||
|
jekyll-docs
|
||||||
|
jekyll-import
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Require a gem or file if it's present, otherwise silently fail.
|
||||||
|
#
|
||||||
|
# names - a string gem name or array of gem names
|
||||||
|
#
|
||||||
|
def require_if_present(names)
|
||||||
|
Array(names).each do |name|
|
||||||
|
begin
|
||||||
|
require name
|
||||||
|
rescue LoadError
|
||||||
|
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Require a gem or gems. If it's not present, show a very nice error
|
||||||
|
# message that explains everything and is much more helpful than the
|
||||||
|
# normal LoadError.
|
||||||
|
#
|
||||||
|
# names - a string gem name or array of gem names
|
||||||
|
#
|
||||||
|
def require_with_graceful_fail(names)
|
||||||
|
Array(names).each do |name|
|
||||||
|
begin
|
||||||
|
require name
|
||||||
|
rescue LoadError => e
|
||||||
|
Jekyll.logger.error "Dependency Error:", <<-MSG
|
||||||
|
Yikes! It looks like you don't have #{name} or one of its dependencies installed.
|
||||||
|
In order to use Jekyll as currently configured, you'll need to install this gem.
|
||||||
|
|
||||||
|
The full error message from Ruby is: '#{e.message}'
|
||||||
|
|
||||||
|
If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!
|
||||||
|
MSG
|
||||||
|
raise Jekyll::Errors::MissingDependencyException.new(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -82,3 +82,6 @@ $ jekyll build --source _source --destination _deploy
|
||||||
|
|
||||||
For more about the possible configuration options, see the
|
For more about the possible configuration options, see the
|
||||||
[configuration](../configuration/) page.
|
[configuration](../configuration/) page.
|
||||||
|
|
||||||
|
If you're interested in browsing these docs on-the-go, install the
|
||||||
|
`jekyll-docs` gem and run `jekyll docs` in your terminal.
|
||||||
|
|
Loading…
Reference in New Issue