Commit 1d554742 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'master' into doc-tags

parents 8cba3888 0f731957
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -275,10 +275,14 @@ task :touch2 => :sass do
    "--output", OUT_DIR,
    "--config", "#{SDK_DIR}/touch/docs/config.json",
    "--examples-base-url", "touch-build/examples/production/",
    # "--import", "Touch 1.1:../docs.sencha.com/exports/touch-1.1",
    # "--import", "Touch 2.0:../docs.sencha.com/exports/touch-2.0.1",
    # "--import", "Touch 2.1.0:../docs.sencha.com/exports/touch-2.1.0",
    # "--import", "Touch 2.1.1",
    # "--import", "1.1.0:../docs.sencha.com/exports/touch-1.1.0",
    # "--import", "1.1.1:../docs.sencha.com/exports/touch-1.1.1",
    # "--import", "2.0.0:../docs.sencha.com/exports/touch-2.0.0",
    # "--import", "2.0.1:../docs.sencha.com/exports/touch-2.0.1",
    # "--import", "2.1.0:../docs.sencha.com/exports/touch-2.1.0",
    # "--import", "2.1.1:../docs.sencha.com/exports/touch-2.1.1",
    # "--import", "2.2.0:../docs.sencha.com/exports/touch-2.2.0",
    # "--import", "2.2.1",
    "--seo"
  )

+3 −1
Original line number Diff line number Diff line
@@ -22,4 +22,6 @@ require 'jsduck/options'

opts = JsDuck::Options.new
opts.parse!(ARGV)
JsDuck::App.new(opts).run
exit_code = JsDuck::App.new(opts).run

exit exit_code
+8 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ require 'jsduck/assets'
require 'jsduck/tag_registry'
require 'jsduck/export_writer'
require 'jsduck/web/writer'
require 'jsduck/logger'

module JsDuck

@@ -15,6 +16,7 @@ module JsDuck
    end

    # Main App logic.
    # Returns application exit code.
    def run
      parse

@@ -25,6 +27,12 @@ module JsDuck
      else
        generate_web_page
      end

      if @opts.warnings_exit_nonzero && Logger.warnings_logged?
        return 2
      else
        return 0
      end
    end

    private
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ require 'jsduck/videos'
require 'jsduck/examples'
require 'jsduck/categories/factory'
require 'jsduck/format/doc'
require 'jsduck/news'

module JsDuck

@@ -22,6 +23,7 @@ module JsDuck
    attr_reader :videos
    attr_reader :examples
    attr_reader :categories
    attr_reader :news

    def initialize(relations, opts)
      @relations = relations
@@ -35,6 +37,7 @@ module JsDuck
      @videos = Videos.create(@opts.videos)
      @examples = Examples.create(@opts.examples, @opts)
      @categories = Categories::Factory.create(@opts.categories_path, doc_formatter, @relations)
      @news = News.create(@relations, doc_formatter, @opts)
    end

    # Writes out the assets that can be written out separately:
+5 −43
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ require 'jsduck/logger'
require 'jsduck/categories/file'
require 'jsduck/categories/auto'
require 'jsduck/categories/class_name'
require 'jsduck/columns'

module JsDuck
  module Categories
@@ -20,6 +21,7 @@ module JsDuck
      def initialize(categories, doc_formatter, relations={})
        @categories = categories
        @class_name = Categories::ClassName.new(doc_formatter, relations)
        @columns = Columns.new("classes")
      end

      # Returns HTML listing of classes divided into categories
@@ -41,10 +43,12 @@ module JsDuck
        EOHTML
      end

      private

      def render_columns(groups)
        align = ["left-column", "middle-column", "right-column"]
        i = -1
        return split(groups, 3).map do |col|
        return @columns.split(groups, 3).map do |col|
          i += 1
          [
            "<div class='#{align[i]}'>",
@@ -65,48 +69,6 @@ module JsDuck
        end
      end

      # Splits the array of items into n chunks so that the sum of
      # largest chunk is as small as possible.
      #
      # This is a brute-force implementation - we just try all the
      # combinations and choose the best one.
      def split(items, n)
        if n == 1
          [items]
        elsif items.length <= n
          Array.new(n) {|i| items[i] ? [items[i]] : [] }
        else
          min_max = nil
          min_arr = nil
          i = 0
          while i <= items.length-n
            i += 1
            # Try placing 1, 2, 3, ... items to first chunk.
            # Calculate the remaining chunks recursively.
            cols = [items[0,i]] + split(items[i, items.length], n-1)
            max = max_sum(cols)
            # Is this the optimal solution so far? Remember it.
            if !min_max || max < min_max
              min_max = max
              min_arr = cols
            end
          end
          min_arr
        end
      end

      def max_sum(cols)
        cols.map {|col| sum(col) }.max
      end

      # Finds the total size of items in array
      #
      # The size of one item is it's number of classes + the space for header
      def sum(arr)
        header_size = 3
        arr.reduce(0) {|sum, item| sum + item["classes"].length + header_size }
      end

    end

  end
Loading