Class: ApiDocGeneration::Generation

Inherits:
Object
  • Object
show all
Defined in:
lib/api_doc_generation/generation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path('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_documentsObject (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.expand_path('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.expand_path('templates/doc.html.erb', ROOT_PATH))

  ViewHelper.render(ERB.new(path), opts.merge({
    :documents => @controller_documents,
    :title => @title
  }), path)
end