Class: ScDocs::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/sc_docs/generator.rb

Direct Known Subclasses

HtmlGenerator, ScGenerator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Generator.



18
19
20
21
22
23
# File 'lib/sc_docs/generator.rb', line 18

def initialize(directories, options={})
  @input_dirs = directories.map{|d| File.expand_path(d) }
  @output_dir = File.expand_path(options[:output_dir])
  @smartdown  = false
  @verbose    = options[:verbose]
end

Instance Attribute Details

#input_dirsObject (readonly)

Returns the value of attribute input_dirs.



8
9
10
# File 'lib/sc_docs/generator.rb', line 8

def input_dirs
  @input_dirs
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



10
11
12
# File 'lib/sc_docs/generator.rb', line 10

def output_dir
  @output_dir
end

#smartdownObject (readonly)

Returns the value of attribute smartdown.



14
15
16
# File 'lib/sc_docs/generator.rb', line 14

def smartdown
  @smartdown
end

#templateObject (readonly)

Returns the value of attribute template.



12
13
14
# File 'lib/sc_docs/generator.rb', line 12

def template
  @template
end

#verboseObject (readonly)

Returns the value of attribute verbose.



16
17
18
# File 'lib/sc_docs/generator.rb', line 16

def verbose
  @verbose
end

Instance Method Details

#commandObject



25
26
27
28
29
30
31
32
33
# File 'lib/sc_docs/generator.rb', line 25

def command
  @command ||= begin
    run_js_path = File.expand_path("../../../vendor/jsdoc/app/run.js", __FILE__)
    command = "#{run_js_path} -a -v -r=20 -t=\"#{template}\" #{input_dirs.map{|d| %{"#{d}"} }.join(' ')} " <<
                  "-d=\"#{output_dir}\" -f=class.js -l=Docs.Class"
    command << " --smartdown" if smartdown
    command
  end
end

#generateObject



35
36
37
38
# File 'lib/sc_docs/generator.rb', line 35

def generate
  prep
  run_command
end

#previewObject



40
41
42
43
44
# File 'lib/sc_docs/generator.rb', line 40

def preview
  prep
  run_command
  run_server
end