Class: ApiDocGeneration::Generation
- Inherits:
-
Object
- Object
- ApiDocGeneration::Generation
- Defined in:
- lib/api_doc_generation/generation.rb
Instance Attribute Summary collapse
-
#controller_documents ⇒ Object
readonly
Returns the value of attribute controller_documents.
Instance Method Summary collapse
- #generate_detailed_html_string(opts = {}) ⇒ Object
- #generate_html_string(opts = {}) ⇒ Object
-
#initialize(codes_path = nil, title = '') ⇒ Generation
constructor
A new instance of Generation.
Constructor Details
#initialize(codes_path = nil, title = '') ⇒ Generation
Returns a new instance of Generation.
10 11 12 13 14 15 16 17 18 |
# File 'lib/api_doc_generation/generation.rb', line 10 def initialize(codes_path = nil, title = '') codes_path ||= File.('app/controllers/api', Rails.root) @controller_documents = [] @title = title each_api_controllers_file(codes_path) do |path| @controller_documents << FormatFile.analyze_file(path) end end |
Instance Attribute Details
#controller_documents ⇒ Object (readonly)
Returns the value of attribute controller_documents.
8 9 10 |
# File 'lib/api_doc_generation/generation.rb', line 8 def controller_documents @controller_documents end |
Instance Method Details
#generate_detailed_html_string(opts = {}) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/api_doc_generation/generation.rb', line 31 def generate_detailed_html_string(opts = {}) path = File.read(File.('templates/doc_detailed.html.erb', ROOT_PATH)) ViewHelper.render(ERB.new(path), opts.merge({ :documents => @controller_documents, :title => @title }), path) end |
#generate_html_string(opts = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/api_doc_generation/generation.rb', line 21 def generate_html_string(opts = {}) path = File.read(File.('templates/doc.html.erb', ROOT_PATH)) ViewHelper.render(ERB.new(path), opts.merge({ :documents => @controller_documents, :title => @title }), path) end |