Loading Rakefile +47 −6 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ def compress # Now do everything that follows in template-min/ dir dir = "template-min" # Create JSB3 file for Docs app system("sencha", "create", "jsb", "-a", "#{dir}/build-js.html", "-p", "#{dir}/app.jsb3") # Concatenate files listed in JSB3 file system("sencha", "build", "-p", "#{dir}/app.jsb3", "-d", dir) # Remove intermediate build files Loading Loading @@ -221,6 +223,7 @@ class JsDuckRunner "--head-html", head_html, "--footer", "Sencha Touch 2.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}", "--categories", "#{@sdk_dir}/touch/docs/categories.json", "--welcome", "template/touch-welcome.html", "--videos", "#{@sdk_dir}/touch/docs/videos.json", "--guides", "#{@sdk_dir}/touch/docs/guides.json", "--examples", "#{@sdk_dir}/touch/docs/examples.json", Loading @@ -228,6 +231,7 @@ class JsDuckRunner "--output", "#{@out_dir}", "--external=google.maps.Map,google.maps.LatLng", "--builtin-classes", "--img", "<p class='screenshot'><img src='%u' alt='%a'><span>%a</span></p>", "#{@sdk_dir}/touch/resources/themes/stylesheets/sencha-touch/default", ] Loading @@ -252,6 +256,30 @@ class JsDuckRunner @options += extract_jsb_build_files("#{@sdk_dir}/touch/touch.jsb3") end def set_touch2_src relative_touch_path = "../" touch_iframe = "template-min/touchIframe.html"; ["template-min/touchIframe.html", "template-min/touch-welcome.html"].each do |file| html = IO.read(file); touch_src_re = /((src|href)="touch)/m out = [] html.each_line do |line| out << line.sub(/((src|href)="touch\/)/, '\2="' + relative_touch_path) end File.open(file, 'w') {|f| f.write(out) } end @options += [ "--welcome", "template-min/touch-welcome.html", "--body-html", '<script type="text/javascript">Docs.exampleBaseUrl = "' + relative_touch_path + 'examples/";if (Ext.is.Phone) { window.location = "' + relative_touch_path + 'examples/"; }</script>' ] end def add_animator head_html = <<-EOHTML <link rel="canonical" href="http://docs.sencha.com/animator/1-0/" /> Loading Loading @@ -311,6 +339,16 @@ class JsDuckRunner ] end def add_touch2_export_notice @options += [ "--body-html", <<-EOHTML <div id="notice-text" style="display: none"> Use <a href="http://docs.sencha.com/touch/2-0">http://docs.sencha.com/touch/2-0</a> for up to date documentation and features </div> EOHTML ] end def add_google_analytics @options += [ "--body-html", <<-EOHTML Loading Loading @@ -406,7 +444,7 @@ task :sdk, [:mode] => :sass do |t, args| runner.add_sdk runner.add_debug if mode == "debug" runner.add_seo if mode == "debug" || mode == "live" runner.add_export_notice if mode == "export" runner.add_sdk_export_notice if mode == "export" runner.add_google_analytics if mode == "live" runner.run Loading Loading @@ -445,19 +483,22 @@ end desc "Run JSDuck on Sencha Touch 2 (for internal use at Sencha)\n" + "touch2 - creates debug/development version\n" + "touch2[export] - creates export version\n" + "touch2[live] - create live version for deployment\n" task :touch2, [:mode] => :sass do |t, args| mode = args[:mode] || "debug" throw "Unknown mode #{mode}" unless ["debug", "live"].include?(mode) compress if mode == "live" throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode) compress if mode == "live" || mode == "export" runner = JsDuckRunner.new runner.add_touch2 runner.add_debug if mode == "debug" runner.add_touch2_export_notice if mode == "export" runner.set_touch2_src if mode == "export" runner.add_seo if mode == "debug" || mode == "live" runner.run runner.copy_touch2_build runner.copy_touch2_build if mode != "export" end desc "Run JSDuck JSON Export (for internal use at Sencha)\n" + Loading lib/jsduck/categories.rb +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,12 @@ module JsDuck def parse(path) @categories = JsonDuck.read(path) # Don't crash if old syntax is used. if @categories.is_a?(Hash) && @categories["categories"] Logger.instance.warn('Update categories file to contain just the array inside {"categories": [...]}') @categories = @categories["categories"] end # Perform expansion on all class names containing * wildcard @categories.each do |cat| cat["groups"].each do |group| Loading lib/jsduck/logger.rb +2 −2 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ module JsDuck # # Optionally filename and line number will be inserted to message. def warn(msg, filename=nil, line=0) msg = filename ? "#{filename} line #{line} #{msg}" : msg msg = filename ? "#{filename}:#{line}:Warning: #{msg}" : "Warning: #{msg}" if @warnings && !@shown_warnings[msg] $stderr.puts "Warning: " + msg $stderr.puts msg @shown_warnings[msg] = true end end Loading lib/jsduck/merger.rb +4 −2 Original line number Diff line number Diff line Loading @@ -223,7 +223,9 @@ module JsDuck end def create_member_id(m) "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{m[:name]}" # Sanitize $ in member names with something safer name = m[:name].gsub(/\$/, 'S-') "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{name}" end def detect_name(tagname, doc_map, code, name_type = :last_name) Loading Loading @@ -330,7 +332,7 @@ module JsDuck end end (code[:alias] || []).each do |a| if a =~ /^(\w+)\.(\w+)$/ if a =~ /^([\w.]+)\.(\w+)$/ if xtypes[$1] xtypes[$1] << $2 else Loading lib/jsduck/renderer.rb +16 −19 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ module JsDuck return [ "<div>", render_hierarchy, render_sidebar, "<div class='doc-contents'>", render_private_class_notice, @cls[:doc], Loading Loading @@ -51,22 +51,20 @@ module JsDuck html end def render_hierarchy has_parents = @cls[:extends] && @cls[:extends] != "Object" has_alt_names = @cls[:alternateClassNames].length > 0 has_mixins = @cls[:superclasses].length > 0 has_files = @cls[:files].length > 0 && @cls[:files][0][:filename] != "" return if !has_parents && !has_alt_names && !has_mixins && !has_files return [ '<pre class="hierarchy">', def render_sidebar items = [ render_alternate_class_names, render_tree, render_mixins, render_dependencies(:allMixins, "Mixins"), render_dependencies(:requires, "Requires"), render_dependencies(:uses, "Uses"), render_files, '</pre>' ] if items.compact.length > 0 return ['<pre class="hierarchy">', items, '</pre>'] else return nil end end def render_alternate_class_names Loading @@ -77,23 +75,22 @@ module JsDuck ] end def render_mixins return if @cls[:allMixins].length == 0 def render_dependencies(type, title) return if !@cls[type] || @cls[type].length == 0 return [ "<h4>Mixins</h4>", @cls[:allMixins].map {|name| "<div class='mixin'>#{render_link(name)}</div>" }, "<h4>#{title}</h4>", @cls[type].map {|name| "<div class='dependency'>#{render_link(name)}</div>" }, ] end def render_files return if @cls[:files].length == 0 || @cls[:files][0][:filename] == "" return [ "<h4>Files</h4>", @cls[:files].map do |file| url = "source/" + file[:href] title = File.basename(file[:filename]) "<div class='file'><a href='#{url}' target='_blank'>#{title}</a></div>" "<div class='dependency'><a href='#{url}' target='_blank'>#{title}</a></div>" end ] end Loading Loading
Rakefile +47 −6 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ def compress # Now do everything that follows in template-min/ dir dir = "template-min" # Create JSB3 file for Docs app system("sencha", "create", "jsb", "-a", "#{dir}/build-js.html", "-p", "#{dir}/app.jsb3") # Concatenate files listed in JSB3 file system("sencha", "build", "-p", "#{dir}/app.jsb3", "-d", dir) # Remove intermediate build files Loading Loading @@ -221,6 +223,7 @@ class JsDuckRunner "--head-html", head_html, "--footer", "Sencha Touch 2.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}", "--categories", "#{@sdk_dir}/touch/docs/categories.json", "--welcome", "template/touch-welcome.html", "--videos", "#{@sdk_dir}/touch/docs/videos.json", "--guides", "#{@sdk_dir}/touch/docs/guides.json", "--examples", "#{@sdk_dir}/touch/docs/examples.json", Loading @@ -228,6 +231,7 @@ class JsDuckRunner "--output", "#{@out_dir}", "--external=google.maps.Map,google.maps.LatLng", "--builtin-classes", "--img", "<p class='screenshot'><img src='%u' alt='%a'><span>%a</span></p>", "#{@sdk_dir}/touch/resources/themes/stylesheets/sencha-touch/default", ] Loading @@ -252,6 +256,30 @@ class JsDuckRunner @options += extract_jsb_build_files("#{@sdk_dir}/touch/touch.jsb3") end def set_touch2_src relative_touch_path = "../" touch_iframe = "template-min/touchIframe.html"; ["template-min/touchIframe.html", "template-min/touch-welcome.html"].each do |file| html = IO.read(file); touch_src_re = /((src|href)="touch)/m out = [] html.each_line do |line| out << line.sub(/((src|href)="touch\/)/, '\2="' + relative_touch_path) end File.open(file, 'w') {|f| f.write(out) } end @options += [ "--welcome", "template-min/touch-welcome.html", "--body-html", '<script type="text/javascript">Docs.exampleBaseUrl = "' + relative_touch_path + 'examples/";if (Ext.is.Phone) { window.location = "' + relative_touch_path + 'examples/"; }</script>' ] end def add_animator head_html = <<-EOHTML <link rel="canonical" href="http://docs.sencha.com/animator/1-0/" /> Loading Loading @@ -311,6 +339,16 @@ class JsDuckRunner ] end def add_touch2_export_notice @options += [ "--body-html", <<-EOHTML <div id="notice-text" style="display: none"> Use <a href="http://docs.sencha.com/touch/2-0">http://docs.sencha.com/touch/2-0</a> for up to date documentation and features </div> EOHTML ] end def add_google_analytics @options += [ "--body-html", <<-EOHTML Loading Loading @@ -406,7 +444,7 @@ task :sdk, [:mode] => :sass do |t, args| runner.add_sdk runner.add_debug if mode == "debug" runner.add_seo if mode == "debug" || mode == "live" runner.add_export_notice if mode == "export" runner.add_sdk_export_notice if mode == "export" runner.add_google_analytics if mode == "live" runner.run Loading Loading @@ -445,19 +483,22 @@ end desc "Run JSDuck on Sencha Touch 2 (for internal use at Sencha)\n" + "touch2 - creates debug/development version\n" + "touch2[export] - creates export version\n" + "touch2[live] - create live version for deployment\n" task :touch2, [:mode] => :sass do |t, args| mode = args[:mode] || "debug" throw "Unknown mode #{mode}" unless ["debug", "live"].include?(mode) compress if mode == "live" throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode) compress if mode == "live" || mode == "export" runner = JsDuckRunner.new runner.add_touch2 runner.add_debug if mode == "debug" runner.add_touch2_export_notice if mode == "export" runner.set_touch2_src if mode == "export" runner.add_seo if mode == "debug" || mode == "live" runner.run runner.copy_touch2_build runner.copy_touch2_build if mode != "export" end desc "Run JSDuck JSON Export (for internal use at Sencha)\n" + Loading
lib/jsduck/categories.rb +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,12 @@ module JsDuck def parse(path) @categories = JsonDuck.read(path) # Don't crash if old syntax is used. if @categories.is_a?(Hash) && @categories["categories"] Logger.instance.warn('Update categories file to contain just the array inside {"categories": [...]}') @categories = @categories["categories"] end # Perform expansion on all class names containing * wildcard @categories.each do |cat| cat["groups"].each do |group| Loading
lib/jsduck/logger.rb +2 −2 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ module JsDuck # # Optionally filename and line number will be inserted to message. def warn(msg, filename=nil, line=0) msg = filename ? "#{filename} line #{line} #{msg}" : msg msg = filename ? "#{filename}:#{line}:Warning: #{msg}" : "Warning: #{msg}" if @warnings && !@shown_warnings[msg] $stderr.puts "Warning: " + msg $stderr.puts msg @shown_warnings[msg] = true end end Loading
lib/jsduck/merger.rb +4 −2 Original line number Diff line number Diff line Loading @@ -223,7 +223,9 @@ module JsDuck end def create_member_id(m) "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{m[:name]}" # Sanitize $ in member names with something safer name = m[:name].gsub(/\$/, 'S-') "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{name}" end def detect_name(tagname, doc_map, code, name_type = :last_name) Loading Loading @@ -330,7 +332,7 @@ module JsDuck end end (code[:alias] || []).each do |a| if a =~ /^(\w+)\.(\w+)$/ if a =~ /^([\w.]+)\.(\w+)$/ if xtypes[$1] xtypes[$1] << $2 else Loading
lib/jsduck/renderer.rb +16 −19 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ module JsDuck return [ "<div>", render_hierarchy, render_sidebar, "<div class='doc-contents'>", render_private_class_notice, @cls[:doc], Loading Loading @@ -51,22 +51,20 @@ module JsDuck html end def render_hierarchy has_parents = @cls[:extends] && @cls[:extends] != "Object" has_alt_names = @cls[:alternateClassNames].length > 0 has_mixins = @cls[:superclasses].length > 0 has_files = @cls[:files].length > 0 && @cls[:files][0][:filename] != "" return if !has_parents && !has_alt_names && !has_mixins && !has_files return [ '<pre class="hierarchy">', def render_sidebar items = [ render_alternate_class_names, render_tree, render_mixins, render_dependencies(:allMixins, "Mixins"), render_dependencies(:requires, "Requires"), render_dependencies(:uses, "Uses"), render_files, '</pre>' ] if items.compact.length > 0 return ['<pre class="hierarchy">', items, '</pre>'] else return nil end end def render_alternate_class_names Loading @@ -77,23 +75,22 @@ module JsDuck ] end def render_mixins return if @cls[:allMixins].length == 0 def render_dependencies(type, title) return if !@cls[type] || @cls[type].length == 0 return [ "<h4>Mixins</h4>", @cls[:allMixins].map {|name| "<div class='mixin'>#{render_link(name)}</div>" }, "<h4>#{title}</h4>", @cls[type].map {|name| "<div class='dependency'>#{render_link(name)}</div>" }, ] end def render_files return if @cls[:files].length == 0 || @cls[:files][0][:filename] == "" return [ "<h4>Files</h4>", @cls[:files].map do |file| url = "source/" + file[:href] title = File.basename(file[:filename]) "<div class='file'><a href='#{url}' target='_blank'>#{title}</a></div>" "<div class='dependency'><a href='#{url}' target='_blank'>#{title}</a></div>" end ] end Loading