Class: Moonrope::DocServer::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/moonrope/doc_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, options = {}) ⇒ Generator

Returns a new instance of Generator.



32
33
34
35
# File 'lib/moonrope/doc_server.rb', line 32

def initialize(base, options = {})
  @base = base
  @options = options
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



37
38
39
# File 'lib/moonrope/doc_server.rb', line 37

def base
  @base
end

Instance Method Details

#generate_file(output_file, template_file, variables = {}) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/moonrope/doc_server.rb', line 55

def generate_file(output_file, template_file, variables = {})
  # Generate the page for the requested template with the given variables
  file = DocContext.new(self, :output_file => output_file, :vars => variables)
  file_string = file.render(File.join(template_root_path, "#{template_file}.erb"))
  # Generate the final page within the layout
  DocContext.new(self, :output_file => output_file, :vars => {:page_title => file.vars[:page_title], :active_nav =>file.vars[:active_nav], :body => file_string}).render(File.join(template_root_path, "layout.erb"))
end

#hostObject



43
44
45
# File 'lib/moonrope/doc_server.rb', line 43

def host
  @options[:host]
end

#prefixObject



47
48
49
# File 'lib/moonrope/doc_server.rb', line 47

def prefix
  @options[:prefix]
end

#template_root_pathObject



39
40
41
# File 'lib/moonrope/doc_server.rb', line 39

def template_root_path
  File.expand_path("../../../templates/basic", __FILE__)
end

#versionObject



51
52
53
# File 'lib/moonrope/doc_server.rb', line 51

def version
  @options[:version]
end