Class: Octopress::Docs::Commands
- Inherits:
-
Command
- Object
- Command
- Octopress::Docs::Commands
- Defined in:
- lib/octopress-docs/command.rb
Class Method Summary collapse
- .init_jekyll_docs(options) ⇒ Object
- .init_octopress_docs(options) ⇒ Object
- .init_with_program(p) ⇒ Object
-
.plugins_path ⇒ Object
Returns an Array of plugin search paths.
- .require_plugins ⇒ Object
- .serve_docs(options) ⇒ Object
- .site_dir ⇒ Object
Class Method Details
.init_jekyll_docs(options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/octopress-docs/command.rb', line 45 def self.init_jekyll_docs() .delete('jekyll') # Find local Jekyll gem path # spec = Gem::Specification.find_by_name("jekyll") gem_path = spec.gem_dir ['source'] = "#{gem_path}/site", ['destination'] = "#{gem_path}/site/_site" end |
.init_octopress_docs(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/octopress-docs/command.rb', line 34 def self.init_octopress_docs() Octopress.config({ 'config-file' => File.join(site_dir, '_octopress.yml'), 'override' => { 'docs_mode' => true } }) require_plugins ['source'] = site_dir ['destination'] = File.join(site_dir, '_site') end |
.init_with_program(p) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/octopress-docs/command.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.option 'jekyll', '--jekyll', "Launch local server with docs for Jekyll v#{Jekyll::VERSION}" c.action do |args, | serve_docs() end end end |
.plugins_path ⇒ Object
Returns an Array of plugin search paths
80 81 82 83 84 85 86 |
# File 'lib/octopress-docs/command.rb', line 80 def self.plugins_path if (Octopress.site.config['plugins'] == Jekyll::Configuration::DEFAULTS['plugins']) [Jekyll.sanitized_path(Octopress.site.source, Octopress.site.config['plugins'])] else Array(Octopress.site.config['plugins']).map { |d| File.(d) } end end |
.require_plugins ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/octopress-docs/command.rb', line 62 def self.require_plugins config = Octopress.site.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 end |
.serve_docs(options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octopress-docs/command.rb', line 22 def self.serve_docs() if ['jekyll'] = init_jekyll_docs() else = init_octopress_docs() end ["serving"] = true = Jekyll.configuration Jekyll::Utils.symbolize_hash_keys() Jekyll::Commands::Build.process() Jekyll::Commands::Serve.process() end |
.site_dir ⇒ Object
58 59 60 |
# File 'lib/octopress-docs/command.rb', line 58 def self.site_dir Docs.gem_dir('docs') end |