Commit c8a59c8e authored by Nick Poulden's avatar Nick Poulden
Browse files

Animator task

parent 44e75bd0
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ class JsDuckRunner
    @sdk_dir = SDK_DIR
    @out_dir = OUT_DIR
    @ext_dir = EXT_DIR
    @animator_dir = ANIMATOR_DIR
  end

  def add_options(options)
@@ -224,6 +225,24 @@ class JsDuckRunner
    @options += extract_jsb_build_files("#{@sdk_dir}/touch/touch.jsb3")
  end

  def add_animator
    head_html = <<-EOHTML
      <link rel="canonical" href="http://docs.sencha.com/animator/1-0/" />
      <meta name="description" content="Sencha Animator 1.0 API Documentation from Sencha. Documentation on how to create Javascript applications with Sencha Touch">
    EOHTML

    @options += [
      "--title", "Sencha Docs - Animator 1.0",
      "--head-html", head_html,
      "--footer", "Sencha Animator 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
      "--videos", "#{@animator_dir}/docs/videos.json",
      "--guides", "#{@animator_dir}/docs/guides.json",
      "--examples", "#{@animator_dir}/docs/examples/examples.json",
        "--output", "#{@out_dir}",
      "--builtin-classes"
    ]
  end

  # Extracts files of first build in jsb file
  def extract_jsb_build_files(jsb_file)
    json = JSON.parse(IO.read(jsb_file))
@@ -333,6 +352,11 @@ class JsDuckRunner
    system "cp -r #{@sdk_dir}/touch/docs/resources #{@out_dir}/doc-resources"
  end

  # Copy over the images that Animator documentation links to.
  def copy_animator_images
    system "cp -r #{@animator_dir}/docs/resources #{@out_dir}/doc-resources"
  end

  # Copy over SDK examples
  def copy_sdk_examples
    system "mkdir #{@out_dir}/extjs/builds"
@@ -342,6 +366,11 @@ class JsDuckRunner
    system "cp -r #{@ext_dir}/welcome #{@out_dir}/extjs"
  end

  def copy_animator_examples
    system "mkdir -p #{@out_dir}/extjs"
    system "cp -r #{@animator_dir}/docs/examples #{@out_dir}/extjs"
  end

  def run
    # Pass multiple arguments to system, so we'll take advantage of the built-in escaping
    system(*["ruby", "bin/jsduck"].concat(@options))
@@ -432,6 +461,24 @@ task :touch2, [:mode] => :sass do |t, args|
  runner.copy_touch2_images
end

desc "Run JSDuck on Sencha Animator (for internal use at Sencha)\n" +
     "animator       - creates debug/development version\n" +
     "animator[live] - create live version for deployment\n"
task :animator, [:mode] => :sass do |t, args|
  mode = args[:mode] || "debug"
  throw "Unknown mode #{mode}" unless ["debug", "live"].include?(mode)
  compress if mode == "live"

  runner = JsDuckRunner.new
  runner.add_animator
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.run

  runner.copy_animator_images
  runner.copy_animator_examples
end

desc "Build JSDuck gem"
task :gem => :sass do
  compress