Class: JsDuck::Categories::Factory
- Inherits:
-
Object
- Object
- JsDuck::Categories::Factory
- Defined in:
- lib/jsduck/categories/factory.rb
Overview
Reads in categories and outputs them as HTML div
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(categories, doc_formatter, relations = {}) ⇒ Factory
constructor
A new instance of Factory.
-
#to_html(style = "") ⇒ Object
Returns HTML listing of classes divided into categories.
Constructor Details
#initialize(categories, doc_formatter, relations = {}) ⇒ Factory
Returns a new instance of Factory.
21 22 23 24 25 |
# File 'lib/jsduck/categories/factory.rb', line 21 def initialize(categories, doc_formatter, relations={}) @categories = categories @class_name = Categories::ClassName.new(doc_formatter, relations) @columns = Columns.new("classes") end |
Class Method Details
.create(filename, doc_formatter, relations) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/jsduck/categories/factory.rb', line 12 def self.create(filename, doc_formatter, relations) if filename categories = Categories::File.new(filename, relations) else categories = Categories::Auto.new(relations) end Categories::Factory.new(categories.generate, doc_formatter, relations) end |
Instance Method Details
#to_html(style = "") ⇒ Object
Returns HTML listing of classes divided into categories
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jsduck/categories/factory.rb', line 28 def to_html(style="") html = @categories.map do |category| [ "<div class='section'>", "<h1>#{category['name']}</h1>", render_columns(category['groups']), "<div style='clear:both'></div>", "</div>", ] end.flatten.join("\n") return <<-EOHTML <div id='categories-content' style='#{style}'> #{html} </div> EOHTML end |