Class: ApiDocGeneration::Generation
- Inherits:
-
Object
- Object
- ApiDocGeneration::Generation
- Defined in:
- lib/api_doc_generation.rb
Instance Method Summary collapse
- #generate_detailed_html_string(opts = {}) ⇒ Object
- #generate_html_string(opts = {}) ⇒ Object
-
#initialize(codes_path = nil) ⇒ Generation
constructor
A new instance of Generation.
Constructor Details
#initialize(codes_path = nil) ⇒ Generation
Returns a new instance of Generation.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/api_doc_generation.rb', line 13 def initialize(codes_path = nil) codes_path ||= File.('app/controllers/api', Rails.root) @controller_documents = [] each_api_controllers_file(codes_path) do |path| controller_path = path.split("app/controllers").last class_name = controller_path.gsub('.rb', '').classify klass = class_name.safe_constantize @controller_documents << generate_controller(path, klass) end end |
Instance Method Details
#generate_detailed_html_string(opts = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/api_doc_generation.rb', line 38 def generate_detailed_html_string(opts = {}) template = ERB.new( File.read(File.('../../templates/doc_detailed.html.erb', __FILE__)) ) ViewHelper.render(template, opts.merge({ :documents => @controller_documents })) end |
#generate_html_string(opts = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/api_doc_generation.rb', line 27 def generate_html_string(opts = {}) template = ERB.new( File.read(File.('../../templates/doc.html.erb', __FILE__)) ) ViewHelper.render(template, opts.merge({ :documents => @controller_documents })) end |