Class: JsDuck::AppData

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

Overview

Creates big JS file with data for Docs app.

Instance Method Summary collapse

Constructor Details

#initialize(relations, assets, opts) ⇒ AppData

Returns a new instance of AppData.



11
12
13
14
15
# File 'lib/jsduck/app_data.rb', line 11

def initialize(relations, assets, opts)
  @relations = relations
  @assets = assets
  @opts = opts
end

Instance Method Details

#write(filename) ⇒ Object

Writes classes, guides, videos, and search data to one big .js file



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jsduck/app_data.rb', line 18

def write(filename)
  js = "Docs = " + JsonDuck.generate({
    :data => {
      :classes => Icons.new.create(@relations.classes),
      :guides => @assets.guides.to_array,
      :videos => @assets.videos.to_array,
      :examples => @assets.examples.to_array,
      :search => SearchData.new.create(@relations.classes),
      :stats => @opts.stats ? Stats.new.create(@relations.classes) : [],
      :signatures => MetaTagRegistry.instance.signatures,
      :localStorageDb => @opts.local_storage_db,
      :showPrintButton => @opts.seo,
      :touchExamplesUi => @opts.touch_examples_ui,
    }
  }) + ";\n"
  File.open(filename, 'w') {|f| f.write(js) }
end