Commit ad9da464 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'master' into doc-tags

parents 4c175471 bcebe90e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -159,6 +159,11 @@ class JsDuckRunner
    add_options("--comments-domain", db_name+"/"+version)
  end

  def add_search(product, version)
    add_options("--search-url", "http://support-test.sencha.com:8080/docsearch/search")
    add_options("--search-domain", product+"/"+version)
  end

  def add_ext4
    @options += [
      "--title", "Sencha Docs - Ext JS 4.0",
@@ -263,6 +268,7 @@ task :sdk => :sass do
  )
  runner.add_debug
  runner.add_comments('ext-js', '4')
  runner.add_search('Ext JS', '4.2.0')
  runner.run

  system("ln -s #{EXT_BUILD} #{OUT_DIR}/extjs-build")
+31 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ module JsDuck
    attr_accessor :tests
    attr_accessor :comments_url
    attr_accessor :comments_domain
    attr_accessor :search
    attr_accessor :ignore_html

    # Debugging
@@ -122,6 +123,7 @@ module JsDuck
      @tests = false
      @comments_url = nil
      @comments_domain = nil
      @search = {}
      @ignore_html = {}

      # Debugging
@@ -460,6 +462,35 @@ module JsDuck
          @comments_domain = domain
        end

        opts.on('--search-url=URL',
          "Address of guides search server server.",
          "",
          "When supplied, the search for guides is performed through this",
          "external service and the results merged together with API search.",
          "The search server must respond to JSONP requests.",
          "",
          "For example: http://sencha.com/docsearch",
          "",
          "Must be used together with --search-domain option.",
          "",
          "This option is EXPERIMENTAL.") do |url|
          @search[:url] = url
        end

        opts.on('--search-domain=STRING',
          "A string consisting of <name>/<version>.",
          "",
          "Tells the search engine which product and version",
          "to include into search.",
          "",
          "For example: Ext JS/4.2.0",
          "",
          "Must be used together with --search-url option.",
          "",
          "This option is EXPERIMENTAL.") do |domain|
          @search[:product], @search[:version] = domain.slice(/\//)
        end

        opts.separator ""
        opts.separator "Tweaking:"
        opts.separator ""
+2 −1
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ module JsDuck
            :guides => @assets.guides.to_array,
            :videos => @assets.videos.to_array,
            :examples => @assets.examples.to_array,
            :search => Web::Search.new.create(@relations.classes, @assets),
            :search => Web::Search.new.create(@relations.classes, @assets, @opts),
            :guideSearch => @opts.search,
            :tests => @opts.tests,
            :signatures => TagRegistry.signatures,
            :memberTypes => TagRegistry.member_types,
+3 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ module JsDuck
    class Search
      # Given list of classes and other assets, returns an array of
      # hashes describing the search data.
      def create(classes, assets)
      def create(classes, assets, opts)
        list = []

        classes.each do |cls|
@@ -32,7 +32,8 @@ module JsDuck
          end
        end

        assets.guides.each_item {|g| list << guide_node(g) }
        # Don't include guides data when separate guides search engine is provided
        assets.guides.each_item {|g| list << guide_node(g) } unless opts.search[:url]

        assets.videos.each_item {|v| list << video_node(v) }

+38 −1
Original line number Diff line number Diff line
@@ -24,6 +24,24 @@ Ext.define("Docs.ClassRegistry", {
        return this.altNames[name] || name;
    },

    /**
     * Given a full package or class name extracts the "class"-part of the name.
     * @param {String} name
     * @return {String}
     */
    shortName: function(name) {
        return name.split(/\./).pop();
    },

    /**
     * Given a package or class name finds the name of its parent package.
     * @param {String} name
     * @return {String}
     */
    packageName: function(name) {
        return name.slice(0, -this.shortName(name).length - 1) || "";
    },

    /**
     * Searches class and member names including given search string.
     *
@@ -66,10 +84,12 @@ Ext.define("Docs.ClassRegistry", {
     *     59  middle removed   guide
     *
     * @param {String} text  The query string to search for
     * @param {Object[]} [guides] Results of guides search, to be
     * combined with the results of API search.
     * @return {Object[]} array of the matching items from Docs.search.data
     * ordered by best matches first.
     */
    search: function(text) {
    search: function(text, guides) {
        // Each record has 1 of 5 possible sorting orders,
        var nSort = 5;
        // which is *4 by it being public/deprecated/private/removed,
@@ -93,6 +113,23 @@ Ext.define("Docs.ClassRegistry", {
        var adjPri = nSort * 2;
        var adjRem = nSort * 3;

        // When guides given, populate the result fields with them
        if (guides) {
            var guidePos = 4;
            for (var i=0; i<guides.length; i++) {
                var g = guides[i];
                if (g.score > 5) {
                    results[guidePos + adjPub + adjFul].push(g);
                }
                else if (g.score > 1) {
                    results[guidePos + adjPub + adjBeg].push(g);
                }
                else {
                    results[guidePos + adjPub + adjMid].push(g);
                }
            }
        }

        var searchFull = /[.:]/.test(text);
        var safeText = Ext.escapeRe(text);
        var reFull = new RegExp("^" + safeText + "$", "i");
Loading