Commit 2db26f0c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'master' into comments-refactor

parents ed83da7d ffb09e9e
Loading
Loading
Loading
Loading

.travis.yml

0 → 100644
+11 −0
Original line number Diff line number Diff line
language: ruby
rvm:
  - "1.8.7"
  - "1.9.2"
install:
  - gem install rdiscount
  - gem install json
  - gem install parallel
  - gem install therubyracer
  - gem install rspec
  - gem install rake
+2 −0
Original line number Diff line number Diff line
JSDuck
======

[![Build Status](https://travis-ci.org/senchalabs/jsduck.png)](https://travis-ci.org/senchalabs/jsduck)

API documentation generator for Sencha JavaScript frameworks.

JSDuck aims to be a better documentation generator for [Ext JS][] than
+31 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ def load_sdk_vars
    puts "    OUT_DIR='/path/to/ouput/dir'"
    puts "    # path to Ext JS 4 build"
    puts "    EXT_BUILD='/path/to/ext-4'"
    puts "    # path to Touch 2 build"
    puts "    # path to Touch 2 build (for building Sencha Touch)"
    puts "    TOUCH_BUILD='/path/to/touch-2'"
    puts "    # path to SDK (for developers at Sencha)"
    puts "    SDK_DIR='/path/to/SDK'"
@@ -206,6 +206,36 @@ class JsDuckRunner
  end
end

# Download ExtJS into template/extjs
task :get_extjs do
  system "curl -o template/extjs.zip http://cdn.sencha.com/ext-4.1.1a-gpl.zip"
  system "unzip template/extjs.zip -d template/"
  system "rm -rf template/extjs"
  system "mv template/ext-4.1.1a template/extjs"
  system "rm template/extjs.zip"
end

# Auto-generate sdk-vars.rb config file
task :config_file do
  if File.exists?("sdk-vars.rb")
    puts "sdk-vars.rb already exists. Keeping it."
  else
    puts "Generating sdk-vars.rb with the following content:"
    config = <<-EORUBY
# where to output the docs
OUT_DIR='#{Dir.pwd}/output'
# path to Ext JS 4 build
EXT_BUILD='#{Dir.pwd}/template/extjs'
    EORUBY
    puts
    puts config
    File.open("sdk-vars.rb", "w") {|h| h.write(config) }
  end
end

desc "Download ExtJS and initialize sdk-vars.rb config file"
task :configure => [:get_extjs, :config_file]

# Run compass to generate CSS files
task :sass do
  system "compass compile --quiet template/resources/sass"
+72 −48
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ require "jsduck/util/json"

options = {
  :title => "Comparison of Ext 4.0.7 and Ext 4.1.1",
  :remap => {},
}

input_files = OptionParser.new do |opts|
@@ -30,6 +31,17 @@ input_files = OptionParser.new do |opts|
    options[:title] = text
  end

  opts.on("--show-unchanged", "To list classes that have not changed.",
    "By default only classes with changes are listed.") do
    options[:show_unchanged] = true
  end

  opts.on("--map=A:B", "Maps class A in old/classes/ to class B",
    "in new/classes/. For example --map Ext.Foo:Ext.NewFoo") do |pair|
    (a, b) = pair.split(/:/)
    options[:remap][a] = b
  end

  opts.on("-h", "--help", "Show this help message") do
    puts opts
    exit
@@ -69,19 +81,17 @@ def discard_docs(cls)
  cls
end

def read_all_classes(dir, ignore_private=false)
def read_all_classes(dir)
  map = {}
  Dir[dir+"/*.json"].each do |filename|
    print "."
    STDOUT.flush
    cls = discard_docs(read_class(filename))
    unless ignore_private && cls["private"]
    map[cls["name"]] = cls
    cls["alternateClassNames"].each do |name|
      map[name] = cls
    end
  end
  end
  puts "OK"
  map
end
@@ -225,39 +235,41 @@ def compare_classes(cls1, cls2)
end


old_classes = read_all_classes(options[:old_classes], :ignore_private)
old_classes = read_all_classes(options[:old_classes])
new_classes = read_all_classes(options[:new_classes])
ignored_members = options[:ignore] ? read_ignored_members(options[:ignore]) : {}

# Explicit remapping of classes
remap = {
  "Array" => "Ext.Array",
  "Date" => "Ext.Date",
  "Function" => "Ext.Function",
  "Number" => "Ext.Number",
  "String" => "Ext.String",
  "Ext.supports" => "Ext.feature.has",
}

diff_data = []
old_classes.each_pair do |name, cls|
  # only go through classes, not alternate names
  if name == cls["name"]
    if remap[name]
      new_cls = new_classes[remap[name]]
  if name == cls["name"] && !cls["private"]
    if options[:remap][name]
      new_cls = new_classes[options[:remap][name]]
    else
      new_cls = new_classes[name]
    end

    diff_data << {
      :name => cls["name"],
      :found => !!new_cls || ignored_members[name],
      :found => (new_cls || ignored_members[name]) ? :both : :old,
      :new_name => new_cls && new_cls["name"],
      :diff => new_cls ? compare_classes(cls, new_cls) : [],
    }
  end
end

new_classes.each_pair do |name, cls|
  if name == cls["name"] && !cls["private"]
    unless old_classes[name]
      diff_data << {
        :name => cls["name"],
        :found => :new,
        :diff => [],
      }
    end
  end
end

# Throw away ignored members and everything except configs
diff_data.each do |cls|
  cls[:diff] = cls[:diff].find_all do |m|
@@ -283,6 +295,9 @@ html << <<-EOHTML
body { font-family: Georgia, serif; }
li h2 { font-size: medium; font-weight: normal; }
li ul { display: none; }
b.unchanged { color: green; }
b.removed { color: red; }
b.new { color: black; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script>
@@ -301,11 +316,12 @@ EOHTML
html << "<ul>"
diff_data.sort! {|a, b| a[:name] <=> b[:name] }
diff_data.each do |cls|
  if cls[:found] == :both
    if cls[:diff].length > 0 || options[:show_unchanged]
      html << "<li>"
  if cls[:found]
      new_name = (cls[:new_name] == cls[:name] ? "" : " --> " + cls[:new_name])
      diff_count = cls[:diff].length > 0 ? "(#{cls[:diff].length} changes)" : ""
    link = cls[:diff].length > 0 ? "<a href='#expand'>#{cls[:name]}</a>" : "<span style='color:green'>"+cls[:name]+'</span>'
      link = cls[:diff].length > 0 ? "<a href='#expand'>#{cls[:name]}</a>" : cls[:name]+" <b class='unchanged'>Unchanged</b>"
      html << "<h2>#{link} #{new_name} #{diff_count}</h2>"
      if cls[:diff].length > 0
        html << "<ul>"
@@ -323,12 +339,19 @@ diff_data.each do |cls|
              html << " (#{c[:what]} changed from #{CGI.escapeHTML(c[:a])} to #{CGI.escapeHTML(c[:b])})"
            end
          end
        end
        html << "</li>"
      end
      html << "</ul>"
      html << "</li>"
    end
  else
    html << "<h2>" + cls[:name] + " <b>not found</b></h2>"
  elsif cls[:found] == :old
    html << "<li>"
    html << "<h2>" + cls[:name] + " <b class='removed'>Removed</b></h2>"
    html << "</li>"
  elsif cls[:found] == :new
    html << "<li>"
    html << "<h2>" + cls[:name] + " <b class='new'>New class</b></h2>"
    html << "</li>"
  end
  html << "</li>"
end
@@ -336,10 +359,11 @@ html << "</ul>"

html << "<h2>Summary</h2>"
dd = diff_data
html << "<p>" + dd.find_all {|c| !c[:found] }.length.to_s + " classes not found</p>"
html << "<p>" + dd.find_all {|c| c[:found] && c[:diff].length == 0 }.length.to_s + " classes exactly the same</p>"
html << "<p>" + dd.find_all {|c| c[:found] && c[:name] == c[:new_name] }.length.to_s + " classes with same name</p>"
html << "<p>" + dd.find_all {|c| c[:found] && c[:name] != c[:new_name] }.length.to_s + " renamed classes</p>"
html << "<p>" + dd.find_all {|c| c[:found] == :old }.length.to_s + " classes removed</p>"
html << "<p>" + dd.find_all {|c| c[:found] == :new }.length.to_s + " new classes added</p>"
html << "<p>" + dd.find_all {|c| c[:found] == :both && c[:diff].length == 0 }.length.to_s + " classes exactly the same</p>"
html << "<p>" + dd.find_all {|c| c[:found] == :both && c[:name] == c[:new_name] }.length.to_s + " classes with same name</p>"
html << "<p>" + dd.find_all {|c| c[:found] == :both && c[:name] != c[:new_name] }.length.to_s + " renamed classes</p>"
html << "<p>" + dd.find_all {|c| c[:diff].length > 0 }.length.to_s + " classes with changed members</p>"
html << "<p>" + dd.map {|c| c[:diff].length }.inject {|sum,x| sum + x }.to_s + " changed members</p>"

+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
  s.required_rubygems_version = ">= 1.3.5"

  s.name = 'jsduck'
  s.version = '4.2.0'
  s.date = '2012-10-01'
  s.version = '4.2.1'
  s.date = '2012-10-12'
  s.summary = "Simple JavaScript Duckumentation generator"
  s.description = "Documentation generator for Sencha JS frameworks"
  s.homepage = "https://github.com/senchalabs/jsduck"
Loading