Class: JsDuck::Welcome

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/welcome.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, doc_formatter) ⇒ Welcome

Parses welcome HTML or Markdown file with content for welcome page.



17
18
19
20
21
22
# File 'lib/jsduck/welcome.rb', line 17

def initialize(filename, doc_formatter)
  @html = Util::IO.read(filename)
  if filename =~ /\.(md|markdown)\z/i
    @html = '<div class="markdown">' + doc_formatter.format(@html) + '</div>'
  end
end

Class Method Details

.create(filename, doc_formatter) ⇒ Object

Creates Welcome object from filename.



8
9
10
11
12
13
14
# File 'lib/jsduck/welcome.rb', line 8

def self.create(filename, doc_formatter)
  if filename
    Welcome.new(filename, doc_formatter)
  else
    Util::NullObject.new(:to_html => "")
  end
end

Instance Method Details

#to_html(style = "") ⇒ Object

Returns the HTML



25
26
27
# File 'lib/jsduck/welcome.rb', line 25

def to_html(style="")
  "<div id='welcome-content' style='#{style}'>#{@html}</div>"
end