Class: Legion::CLI::Docs
- Inherits:
-
Thor
- Object
- Thor
- Legion::CLI::Docs
- Defined in:
- lib/legion/cli/docs_command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
12 13 14 |
# File 'lib/legion/cli/docs_command.rb', line 12 def self.exit_on_failure? true end |
Instance Method Details
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/legion/cli/docs_command.rb', line 21 def generate out = formatter require 'legion/docs/site_generator' out.header('Generating documentation site...') unless [:json] stats = Legion::Docs::SiteGenerator.new(output_dir: [:output]).generate if [:json] out.json(stats) else out.success("Documentation generated in #{stats[:output]}") puts " #{out.colorize("#{stats[:pages]} pages", :accent)} written" puts " #{out.colorize("#{stats[:sections]} guide sections", :label)} converted" end end |
#serve ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/cli/docs_command.rb', line 40 def serve out = formatter dir = [:dir] port = [:port] unless Dir.exist?(dir) out.warn("Directory #{dir} does not exist. Run 'legion docs generate' first.") return end out.header('Documentation preview') puts " Open http://localhost:#{port}/ in your browser" puts " Serving files from: #{File.(dir)}" puts '' puts " To start: #{Legion::Python.interpreter} -m http.server #{port} --directory #{dir}" puts ' Press Ctrl+C to stop' end |