Commit 70c7146e authored by Nick Poulden's avatar Nick Poulden
Browse files

Merge branch 'master' into comments

parents 15552810 80bfac5a
Loading
Loading
Loading
Loading
+106 −28
Original line number Diff line number Diff line
@@ -179,6 +179,24 @@ class JsDuckRunner
    ]
  end

  def add_ext3
    @options += [
      "--title", "Sencha Docs - Ext JS 3.4",
      "--footer", "Ext JS 3.4 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
      "--categories", "#{@sdk_dir}/../ext-3.4.0/src/categories.json",
      "--ignore-global",
      "--output", "#{@out_dir}",
      "#{@sdk_dir}/../ext-3.4.0/src/core",
      "#{@sdk_dir}/../ext-3.4.0/src/data",
      "#{@sdk_dir}/../ext-3.4.0/src/dd",
      "#{@sdk_dir}/../ext-3.4.0/src/direct",
      "#{@sdk_dir}/../ext-3.4.0/src/ext-core/src",
      "#{@sdk_dir}/../ext-3.4.0/src/state",
      "#{@sdk_dir}/../ext-3.4.0/src/util",
      "#{@sdk_dir}/../ext-3.4.0/src/widgets"
    ]
  end

  def add_ext4
    @options += [
      "--title", "Sencha Docs - Ext JS 4.0",
@@ -193,14 +211,14 @@ class JsDuckRunner

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

    @options += [
      "--title", "Sencha Docs - Touch 1.0",
      "--title", "Sencha Docs - Touch 1.1",
      "--head-html", head_html,
      "--footer", "Sencha Touch 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
      "--footer", "Sencha Touch 1.1 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
      "--categories", "#{@sdk_dir}/touch/doc-resources/categories.json",
      "--videos", "#{@sdk_dir}/touch/doc-resources/videos.json",
      "--output", "#{@out_dir}",
@@ -289,6 +307,25 @@ class JsDuckRunner
    ]
  end

  def add_touch_charts
    head_html = <<-EOHTML
      <link rel="canonical" href="http://docs.sencha.com/touch-charts/1-0/" />
      <meta name="description" content="Sencha Touch Charts 1.0 API Documentation. Documentation on how to create Charts with Sencha Touch">
    EOHTML

    @options += [
      "--title", "Sencha Docs - Touch Charts 1.0",
      "--head-html", head_html,
      "--footer", "Sencha Touch Charts 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a>",
      "--categories", "#{@sdk_dir}/charts/docs/categories.json",
      "--guides", "#{@sdk_dir}/charts/docs/guides.json",
      "--images", "#{@sdk_dir}/charts/docs/resources",
      "--output", "#{@out_dir}"
    ]

    @options += extract_jsb_build_files("#{@sdk_dir}/charts/touch-charts.jsb3")
  end

  def add_animator
    head_html = <<-EOHTML
      <link rel="canonical" href="http://docs.sencha.com/animator/1-0/" />
@@ -399,9 +436,37 @@ class JsDuckRunner
                }
            });
        }

        Docs.otherProducts = [
          {
              text: 'Ext JS 4',
              href: 'http://docs.sencha.com/ext-js/4-0'
          },
          {
              text: 'Ext JS 3',
              href: 'http://docs.sencha.com/ext-js/3-4'
          },
          {
              text: 'Sencha Touch 2',
              href: 'http://docs.sencha.com/touch/2-0'
          },
          {
              text: 'Sencha Touch 1',
              href: 'http://docs.sencha.com/touch/1-1'
          },
          {
              text: 'Touch Charts',
              href: 'http://docs.sencha.com/touch-charts/1-0'
          },
          {
              text: 'Sencha Animator',
              href: 'http://docs.sencha.com/animator/1-0'
          }
        ];
      </script>
    EOHTML
    ]

  end

  # Copy over SDK examples
@@ -423,29 +488,6 @@ class JsDuckRunner
    system "cp -r #{@sdk_dir}/touch/build #{@out_dir}/touch"
  end

  def add_product_doc_urls
    @options += [
      "--body-html", <<-EOHTML
      <script type="text/javascript">
        Docs.otherProducts = [
          {
              text: 'Ext JS 4.0',
              href: 'http://docs.sencha.com/ext-js/4-0'
          },
          {
              text: 'Sencha Touch 2.0',
              href: 'http://docs.sencha.com/touch/2-0'
          },
          {
              text: 'Sencha Animator 1.0',
              href: 'http://docs.sencha.com/animator/1-0'
          }
        ];
      </script>
      EOHTML
    ]
  end

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

desc "Run JSDuck on official Ext JS 3.4 build\n" +
     "ext3             - creates debug/development version\n" +
     "ext3[export]     - creates export/deployable version\n"
     "ext3[live]       - creates live version for deployment\n"
task :ext3, [:mode] => :sass do |t, args|
  mode = args[:mode] || "debug"
  throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode)
  compress if mode == "export"

  runner = JsDuckRunner.new
  runner.add_ext3
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "live"
  runner.add_google_analytics if mode == "live"
  runner.run
end

desc "Run JSDuck on Sencha Touch (for internal use at Sencha)\n" +
     "touch       - creates debug/development version\n" +
     "touch[live] - create live version for deployment\n"
@@ -510,6 +569,7 @@ task :touch, [:mode] => :sass do |t, args|
  runner.add_touch
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.add_google_analytics if mode == "live"
  runner.run
end

@@ -528,12 +588,29 @@ task :touch2, [:mode] => :sass do |t, args|
  runner.add_touch2_export_notice if mode == "export"
  runner.set_touch2_src if mode == "export"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.add_product_doc_urls if mode == "live"
  runner.add_google_analytics if mode == "live"
  runner.run

  runner.copy_touch2_build if mode != "export"
end

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

  runner = JsDuckRunner.new
  runner.add_touch_charts
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.add_google_analytics if mode == "live"
  runner.run
end

desc "Run JSDuck JSON Export (for internal use at Sencha)\n" +
     "export[touch]  - creates export for Touch 1\n" +
     "export[touch2] - creates export for Touch 2"
@@ -560,6 +637,7 @@ task :animator, [:mode] => :sass do |t, args|
  runner.add_animator
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.add_google_analytics if mode == "live"
  runner.run

  runner.copy_animator_examples
+7 −7
Original line number Diff line number Diff line
@@ -34,26 +34,26 @@ module JsDuck
    # Expands class name like 'Foo.*' into multiple class names.
    def expand(name)
      re = Regexp.new("^" + name.split(/\*/, -1).map {|part| Regexp.escape(part) }.join('.*') + "$")
      @relations.to_a.find_all {|cls| re =~ cls[:name] && !cls[:private] }.map {|cls| cls[:name] }.sort
      classes = @relations.to_a.find_all {|cls| re =~ cls[:name] && !cls[:private] }.map {|cls| cls[:name] }.sort
      if classes.length == 0
        Logger.instance.warn("No class found matching a pattern '#{name}' in categories file.")
      end
      classes
    end

    # Prints warnings for missing classes in categories file
    def validate
      # Build a map of all classes listed in categories
      listed_classes = {}

      # Check that each class listed in overview file exists
      @categories.each do |cat|
        cat["groups"].each do |group|
          group["classes"].each do |cls_name|
            unless @relations[cls_name]
              Logger.instance.warn("Class '#{cls_name}' in category '#{cat['name']}/#{group['name']}' not found")
            end
            listed_classes[cls_name] = true
          end
        end
      end

      # Check that each existing non-private class is listed in overview file
      # Check that each existing non-private class is listed
      @relations.each do |cls|
        unless listed_classes[cls[:name]] || cls[:private]
          Logger.instance.warn("Class '#{cls[:name]}' not found in categories file")
+15 −4
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ module JsDuck
      end
    end

    # matches: <ident-chain> | "[" <ident-chain> [ "=" <literal> ] "]"
    # matches: <ident-chain> | "[" <ident-chain> [ "=" <default-value> ] "]"
    def maybe_name_with_default
      skip_horiz_white
      if look(/\[/)
@@ -381,7 +381,7 @@ module JsDuck
        if look(/=/)
          match(/=/)
          skip_horiz_white
          @current_tag[:default] = literal
          @current_tag[:default] = default_value
        end
        skip_horiz_white
        match(/\]/)
@@ -425,9 +425,20 @@ module JsDuck
      end
    end

    def literal
    # attempts to match javascript literal,
    # when it fails grabs anything up to closing "]"
    def default_value
      start_pos = @input.pos
      lit = JsLiteralParser.new(@input).literal
      lit ? JsLiteralBuilder.new.to_s(lit) : nil
      if lit && look(/ *]/)
        # When lital matched and there's nothing after it up to the closing "]"
        JsLiteralBuilder.new.to_s(lit)
      else
        # Otherwise reset parsing position to where we started
        # and rescan up to "]" using simple regex.
        @input.pos = start_pos
        match(/[^\]]*/)
      end
    end

    # matches {...} and returns text inside brackets
+17 −2
Original line number Diff line number Diff line
require 'jsduck/logger'

module JsDuck

  # Takes data from doc-comment and code that follows it and combines
@@ -6,6 +8,15 @@ module JsDuck
  #
  # The main method merge() produces a hash as a result.
  class Merger
    # Allow passing in filename and line for error reporting
    attr_accessor :filename
    attr_accessor :linenr

    def initialize
      @filename = ""
      @linenr = 0
    end

    def merge(docs, code)
      case detect_doc_type(docs, code)
      when :class
@@ -417,8 +428,12 @@ module JsDuck
        if it[:name] =~ /^(.+)\.([^.]+)$/
          it[:name] = $2
          parent = index[$1]
          if parent
            parent[:properties] = [] unless parent[:properties]
            parent[:properties] << it
          else
            Logger.instance.warn("Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'.", @filename, @linenr)
          end
        else
          items << it
        end
+2 −0
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ module JsDuck
      @links = {}

      merger = Merger.new
      merger.filename = @filename
      @docs = parse.map do |docset|
        merger.linenr = docset[:linenr]
        link(docset[:linenr], merger.merge(docset[:comment], docset[:code]))
      end
    end
Loading