Class: GrapeDocs::Command
- Inherits:
-
Thor
- Object
- Thor
- GrapeDocs::Command
- Defined in:
- lib/grape_docs/command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.banner(command, namespace = nil, subcommand = false) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/grape_docs/command.rb', line 36 def self.(command, namespace = nil, subcommand = false) result = "#{basename} #{command.usage}" if namespace != false and command.name == "export" result += "\n\nArguments:\n" result += " <api_name> # Constant name of your Grape API, e.g. MyApp::Api\n" result += " <export_path> # Directory / path where the markdown documentation will be generated in\n" end result end |
Instance Method Details
#__print_version ⇒ Object
10 11 12 |
# File 'lib/grape_docs/command.rb', line 10 def __print_version puts GrapeDocs::VERSION end |
#export(api_name, export_path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/grape_docs/command.rb', line 17 def export(api_name, export_path) # grape docs configuration GrapeDocs.config[:api_host] = .host GrapeDocs.config[:template] = .template # prepare grape API require_file = Workspace.file(.require) raise(Thor::Error, "ERROR: config/environment.rb doesn't exists!") unless require_file.exists? require require_file.to_s raise(Thor::Error, "ERROR: class #{api_name} isn't defined!") unless defined?(api_name) api = Api.new(api_name.constantize) # export grape API exporter = Exporter.new(export_path) exporter.export_summary(api) exporter.export_readme(api) exporter.export(api) end |