Commit 42b28d5f authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add --search-url and --search-domain options.

Only activate the external guides-search when --search-url option
is used.  Otherwise fall back to old search.
parent 1ca89ea2
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",
@@ -261,6 +266,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")
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ module JsDuck
          :guides => @assets.guides.to_array,
          :videos => @assets.videos.to_array,
          :examples => @assets.examples.to_array,
          :search => SearchData.new.create(@relations.classes, @assets),
          :search => SearchData.new.create(@relations.classes, @assets, @opts),
          :guideSearch => @opts.search,
          :tests => @opts.tests,
          :signatures => MetaTagRegistry.instance.signatures,
          :localStorageDb => @opts.local_storage_db,
+31 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ module JsDuck
    attr_accessor :tests
    attr_accessor :comments_url
    attr_accessor :comments_domain
    attr_accessor :search
    attr_accessor :ignore_html

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

      # Debugging
@@ -434,6 +436,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 ""
+3 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ module JsDuck
  class SearchData
    # 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|
@@ -30,7 +30,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) }

+0 −5
Original line number Diff line number Diff line
@@ -122,11 +122,6 @@ Ext.define("Docs.ClassRegistry", {
        for (var i=0, len=searchData.length; i<len; i++) {
            var r = searchData[i];

            // Skip guides when guides search results already provided
            if (guides && r.icon === "icon-guide") {
                continue;
            }

            // when search text has "." or ":" in it, search from the full name
            // (e.g. "Ext.Component.focus" or "xtype: grid")
            // Otherwise search from just the short name (e.g. "focus" or "Component")
Loading