Method: JsDuck::App#run

Defined in:
lib/jsduck/app.rb

#runObject

Call this after input parameters set



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/jsduck/app.rb', line 44

def run
  parsed_files = parallel_parse(@opts.input_files)
  result = aggregate(parsed_files)
  @relations = filter_classes(result)
  InheritDoc.new(@relations).resolve_all
  Lint.new(@relations).run

  # Initialize guides, videos, examples, ...
  @assets = Assets.new(@relations, @opts)

  # Give access to assets from all meta-tags
  MetaTagRegistry.instance.assets = @assets

  if @opts.export
    format_classes
    FileUtils.rm_rf(@opts.output_dir) unless @opts.output_dir == :stdout
    exporters = {
      :full => FullExporter,
      :api => ApiExporter,
      :examples => ExamplesExporter,
    }
    cw = ClassWriter.new(exporters[@opts.export], @relations, @opts)
    cw.write(@opts.output_dir, ".json")
    if @opts.export == :examples
      gw = GuideWriter.new(exporters[@opts.export], @assets.guides, @opts)
      gw.write(@opts.output_dir, ".json")
    end
    Stdout.instance.flush
  else
    FileUtils.rm_rf(@opts.output_dir)
    TemplateDir.new(@opts).write

    IndexHtml.new(@assets, @opts).write

    AppData.new(@relations, @assets, @opts).write(@opts.output_dir+"/data.js")

    # class-formatting is done in parallel which breaks the links
    # between source files and classes. Therefore it MUST to be done
    # after writing sources which needs the links to work.
    if @opts.source
      source_writer = SourceWriter.new(parsed_files, @parallel)
      source_writer.write(@opts.output_dir + "/source")
    end
    format_classes

    if @opts.tests
      examples = InlineExamples.new
      examples.add_classes(@relations)
      examples.add_guides(@assets.guides)
      examples.write(@opts.output_dir+"/inline-examples.js")
    end

    cw = ClassWriter.new(AppExporter, @relations, @opts)
    cw.write(@opts.output_dir+"/output", ".js")

    @assets.write
  end
end