lib/octopress-docs/command.rb in octopress-docs-0.0.11 vs lib/octopress-docs/command.rb in octopress-docs-0.0.12
- old
+ new
@@ -17,77 +17,43 @@
end
end
end
def self.serve_docs(options)
+ # Tell the world, we're serving the docs site
+ #
+ ENV['OCTOPRESS_DOCS'] = 'true'
+
# Activate dependencies for serving docs.
- require "octopress-escape-code"
+ #
+ require "octopress-docs/jekyll/convertible"
+ require "octopress-docs/jekyll/page"
+ require "octopress-docs/liquid_filters"
require "octopress-hooks"
- require "octopress-docs/page"
require "octopress-docs/doc"
require "octopress-docs/hooks"
- require "octopress-docs/liquid_filters"
- ENV['OCTOPRESS_DOCS'] = true
- options = init_octopress_docs(options)
- options["port"] ||= '4444'
- options["serving"] = true
- options = Jekyll.configuration Jekyll::Utils.symbolize_hash_keys(options)
- Jekyll::Commands::Build.process(options)
- Jekyll::Commands::Serve.process(options)
- end
- def self.init_octopress_docs(options)
- require_plugins
- options['source'] = site_dir
- options['destination'] = File.join(site_dir, '_site')
- options
- end
+ # Look at the local site and require all of its plugins
+ # Ensuring their documentation is loaded into the docs site
+ #
+ site = Octopress.read_site({'config'=>options['config']})
+ site.plugin_manager.conscientious_require
- def self.init_jekyll_docs(options)
- options.delete('jekyll')
-
- # Find local Jekyll gem path
+ # Require escape code last to set Octopress hook priority.
#
- spec = Gem::Specification.find_by_name("jekyll")
- gem_path = spec.gem_dir
+ require "octopress-escape-code"
- options['source'] = "#{gem_path}/site",
- options['destination'] = "#{gem_path}/site/_site"
- options
- end
-
- def self.site_dir
- Docs.gem_dir('docs')
- end
-
- def self.require_plugins
- config = Octopress::Configuration.jekyll_config
-
- if config['gems'].is_a?(Array)
- config['gems'].each {|g| require g }
- end
-
- unless config['safe']
- plugins_path.each do |plugins|
- Dir[File.join(plugins, "**", "*.rb")].sort.each do |f|
- require f
- end
- end
- end
+ options = Docs.site.config.merge(options)
+ 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
- # Returns an Array of plugin search paths
- def self.plugins_path
- config = Octopress::Configuration.jekyll_config
- plugins = config['plugins']
- if (plugins == Jekyll::Configuration::DEFAULTS['plugins'])
- [Jekyll.sanitized_path(config['source'], plugins)]
- else
- Array(plugins).map { |d| File.expand_path(d) }
- end
- end
-
end
end
end