jquery-cheat 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,4 +6,9 @@
6
6
  == 0.1.1 2007-06-01
7
7
 
8
8
  * 1 minor bugfix
9
- * Fixed a bug in pathname
9
+ * Fixed a bug in pathname
10
+
11
+ == 0.1.2 2007-06-01
12
+
13
+ * 1 minor bugfix
14
+ * removed dependency on Marshal
@@ -5,7 +5,9 @@ README.txt
5
5
  Rakefile
6
6
  bin/jcheat
7
7
  lib/index.xml
8
+ lib/jquery-cheat.rb
8
9
  lib/jquery-cheat/version.rb
10
+ lib/merger.rb
9
11
  scripts/txt2html
10
12
  setup.rb
11
13
  test/test_helper.rb
data/README.txt CHANGED
@@ -1,3 +1,61 @@
1
1
  README for jquery-cheat
2
2
  =======================
3
3
 
4
+ jQuery Cheat provides a command-line interface to the jQuery API.
5
+
6
+ == Usage
7
+
8
+ jcheat COMMAND [COMMAND_PREFS] [--name NAME [--precise]]
9
+ [--module MODULE [--recursive]] [--like STRING]
10
+ [--params PARAM1[,PARAM2...]] [--no-examples]
11
+
12
+ (describe|desc) METHOD_NAME [PARAM1, ...]
13
+ > the full description of each method matching METHOD_NAME.
14
+ > If you also pass optional PARAMs, the list of matching
15
+ > methods will be filtered to include only methods with those
16
+ > parameters.
17
+ >
18
+ > --no-examples(-e) suppresses examples from the output
19
+ >
20
+ > Example: "jcheat desc $ html" will return the description
21
+ > of the $ method with an "html" parameter.
22
+
23
+ * list MODULE_NAME
24
+ > A list of all methods directly under a specific module. Passing
25
+ > an optional "-r" will return a list of all methods at any level
26
+ > under the module.
27
+ >
28
+ > Example: "jcheat list DOM/Traversing"
29
+
30
+ * (apopros|ap|like) STRING
31
+ > A list of all methods whose description contains all of the
32
+ > words in STRING.
33
+ >
34
+ > Example: "jcheat like clear fields"
35
+
36
+ * named STRING
37
+ > A list of all methods named exactly STRING.
38
+ >
39
+ > Example: "jcheat named $"
40
+
41
+ * (namelike|nl) STRING
42
+ > A list of all methods whose names contain STRING.
43
+ >
44
+ > Example: "jcheat nl clear"
45
+
46
+ FILTERS
47
+ -------
48
+
49
+ [--name(-n) NAME [--substrings(-s)]] filters methods by their name.
50
+ Adding the --precise flag will allow a substring match.
51
+
52
+ [--module(-m) MODULE [--recursive(-r)]] filters methods by the
53
+ module they are in. Adding the --recursive flag will check
54
+ submodules (ex: -m DOM -r will search for methods in DOM,
55
+ DOM/Traversal, etc.)
56
+
57
+ [--like(-l) STRING] filters methods by words in their description.
58
+
59
+ [--params(-o) PARAM1[,PARAM2...]] filters methods by those that
60
+ contain all of the parameters passed in. Parameters should be
61
+ passed as a comma-separated list.
data/bin/jcheat CHANGED
@@ -1,91 +1,37 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'getoptlong'
3
4
  require 'rubygems'
4
5
  require 'hpricot'
5
6
  gem 'jquery-cheat'
7
+ require 'jquery-cheat'
6
8
 
7
- PATH = File.join(Gem.cache.search("jquery-cheat").sort_by{|x| x.version.version}.last.full_gem_path, 'lib','index.xml')
9
+ opts = GetoptLong.new(
10
+ [ '--recursive', '-r', GetoptLong::NO_ARGUMENT ],
11
+ [ '--module', '-m', GetoptLong::REQUIRED_ARGUMENT ],
12
+ [ '--name', '-n', GetoptLong::REQUIRED_ARGUMENT ],
13
+ [ '--substring', '-s', GetoptLong::NO_ARGUMENT ],
14
+ [ '--like', '-l', GetoptLong::REQUIRED_ARGUMENT ],
15
+ [ '--params', '-o', GetoptLong::REQUIRED_ARGUMENT ],
16
+ [ '--no-examples', '-e', GetoptLong::NO_ARGUMENT ],
17
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ]
18
+ )
8
19
 
9
- class JQueryMethod
10
-
11
- attr_accessor :short, :long, :cat, :params, :options, :examples, :name, :attributes, :param_order, :type
12
-
13
- def initialize elem
14
- @name = elem.attributes["name"]
15
- @short = elem.attributes["short"]
16
- @long = elem.search("> desc").inner_text
17
- @cat = elem.attributes["cat"]
18
- @params = elem.search("params").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
19
- @param_order = elem.search("params").map {|p| p.attributes["name"]}
20
- @options = elem.search("options").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
21
- @type = elem.attributes["type"]
22
- @examples = elem.search("examples").map do |example|
23
- {:desc => example.search("desc").inner_text,
24
- :before => example.search("before").inner_text,
25
- :code => example.search("code").inner_text,
26
- :result => example.search("result").inner_text
27
- }
28
-
29
- end
30
- @attributes = elem.attributes
31
- end
32
-
33
- def signature
34
- "#{name}#{"(#{ param_order.join(", ") })" if !attributes["property"] } in #{cat}"
35
- end
36
-
37
- end
38
-
39
- class JQueryMethods < Array
40
-
41
- @@parsed = Hpricot::XML(File.read(PATH))
42
-
43
- def initialize els
44
- push(*els.to_jquery_methods)
45
- end
46
-
47
- def self.with_name_and_params name, *params
48
- new(@@parsed.search("method[@name='#{name}']").reject{|m| params.any? {|p| m.search("params[@name=#{p}]").length == 0 } })
49
- end
50
-
51
- def self.in_module mod, recursive
52
- new(@@parsed.search("[@cat#{ '*' if recursive.to_s =~ /^\-?r/i }='#{mod}']")).named_list
53
- end
54
-
55
- def self.description_matches list
56
- new(@@parsed.search("method").select {|m| list.all? {|t| m.search("> desc").inner_text =~ /#{t}/i} }).named_list
57
- end
58
-
59
- def self.named name, precise = false
60
- new(@@parsed.search("method[@name#{ precise ? "=" : "*=" }'#{name}']")).named_list
61
- end
62
-
63
- def named_list
64
- list = inject([]) {|s,m| s.push(m.signature) }
65
- list.empty? ? ["No items found"] : list
66
- end
67
-
68
- end
20
+ line = "-" * 80
69
21
 
70
- class Array
71
-
72
- def to_jquery_methods
73
- map {|m| JQueryMethod.new(m)}
74
- end
75
-
76
- end
22
+ opts_hash = {}
77
23
 
78
- class String
79
-
80
- def word_wrap cols, padding = 0
81
- gsub(/\n\n/, "\r").gsub(/\n/, ' ').gsub(/\r/, "\n\n#{' ' * 14}").gsub(/(.{1,#{cols}}|\S{#{cols + 1},})(?: +|$\n?)/, "\\1\n#{ ' ' * padding}")
24
+ opts.each do |opt, arg|
25
+ case opt
26
+ when '--params'
27
+ opts_hash[:params] = arg.split(",")
28
+ else
29
+ opts_hash[opt.gsub("--", "").to_sym] = (arg || true)
82
30
  end
83
31
  end
84
32
 
85
- line = "-" * 80
86
-
87
33
  if ARGV[0] == "describe" || ARGV[0] == "desc"
88
- methods = JQueryMethods.with_name_and_params(ARGV[1], *ARGV[2..-1])
34
+ methods = JQuery::Methods.new(:name => ARGV[1], :params => ARGV[2..-1])
89
35
 
90
36
  for method in methods
91
37
  puts line
@@ -94,37 +40,47 @@ if ARGV[0] == "describe" || ARGV[0] == "desc"
94
40
  "Description: #{method.short.word_wrap(62, 14)}\n" +
95
41
  "Details: #{method.long.word_wrap(62, 14)}\n" +
96
42
  "Returns: #{method.type}\n"
97
- puts "#{line}\n|#{" " * 35 }EXAMPLES#{" " * 35}|\n#{line}\n"
98
- for example in method.examples
99
- puts "---------------\n| Description |\n---------------\n#{example[:desc].word_wrap(80)}\n" if example[:desc] != ""
100
- puts "----------\n| Before |\n----------\n#{example[:before]}\n\n" if example[:before] != ""
101
- puts "--------\n| Code |\n--------\n#{example[:code]}\n\n" if example[:code] != ""
102
- puts "----------\n| Result |\n----------\n#{example[:result]}\n\n" if example[:result] != ""
103
- puts "\n"
43
+
44
+ if !opts_hash[:"no-examples"]
45
+ puts "#{line}\n|#{" " * 35 }EXAMPLES#{" " * 35}|\n#{line}\n"
46
+
47
+ for example in method.examples
48
+ puts "---------------\n| Description |\n---------------\n#{example[:desc].word_wrap(80)}\n" if example[:desc] != ""
49
+ puts "----------\n| Before |\n----------\n#{example[:before]}\n\n" if example[:before] != ""
50
+ puts "--------\n| Code |\n--------\n#{example[:code]}\n\n" if example[:code] != ""
51
+ puts "----------\n| Result |\n----------\n#{example[:result]}\n\n" if example[:result] != ""
52
+ puts "\n"
53
+ end
104
54
  end
105
55
  end
106
56
  elsif ARGV[0] == "list"
107
- puts JQueryMethods.in_module(ARGV[1], ARGV[2]).join("\n")
57
+ hash = {:module => ARGV[1]}
108
58
  elsif ARGV[0] =~ /^(apopros|ap|like)$/
109
- puts JQueryMethods.description_matches(ARGV[1..-1]).join("\n")
59
+ hash = {:like => ARGV[1..-1]}
110
60
  elsif ARGV[0] == "named"
111
- puts JQueryMethods.named(ARGV[1], true).join("\n")
61
+ hash = {:name => ARGV[1]}
112
62
  elsif ARGV[0] =~ /^(namelike|nl)$/
113
- puts JQueryMethods.named(ARGV[1], false).join("\n")
114
- else
63
+ hash = {:name => ARGV[1], :substring => true}
64
+ elsif ARGV[0] == "tree"
65
+ JQuery.print_tree(JQuery.convert(JQuery::Parser.category_list))
66
+ elsif opts_hash[:help]
115
67
  puts %q{
116
- jcheat takes any of the following parameters:
68
+ jcheat COMMAND [COMMAND_PREFS] [--name NAME [--precise]]
69
+ [--module MODULE [--recursive]] [--like STRING]
70
+ [--params PARAM1[,PARAM2...]] [--no-examples]
117
71
 
118
72
  (describe|desc) METHOD_NAME [PARAM1, ...]
119
73
  > the full description of each method matching METHOD_NAME.
120
74
  > If you also pass optional PARAMs, the list of matching
121
75
  > methods will be filtered to include only methods with those
122
76
  > parameters.
77
+ >
78
+ > --no-examples(-e) suppresses examples from the output
123
79
  >
124
80
  > Example: "jcheat desc $ html" will return the description
125
81
  > of the $ method with an "html" parameter.
126
82
 
127
- * list MODULE_NAME [-r]
83
+ * list MODULE_NAME
128
84
  > A list of all methods directly under a specific module. Passing
129
85
  > an optional "-r" will return a list of all methods at any level
130
86
  > under the module.
@@ -146,6 +102,28 @@ else
146
102
  > A list of all methods whose names contain STRING.
147
103
  >
148
104
  > Example: "jcheat nl clear"
105
+
106
+ FILTERS
107
+ -------
108
+
109
+ [--name(-n) NAME [--substrings(-s)]] filters methods by their name.
110
+ Adding the --precise flag will allow a substring match.
111
+
112
+ [--module(-m) MODULE [--recursive(-r)]] filters methods by the
113
+ module they are in. Adding the --recursive flag will check
114
+ submodules (ex: -m DOM -r will search for methods in DOM,
115
+ DOM/Traversal, etc.)
116
+
117
+ [--like(-l) STRING] filters methods by words in their description.
118
+
119
+ [--params(-o) PARAM1[,PARAM2...]] filters methods by those that
120
+ contain all of the parameters passed in. Parameters should be
121
+ passed as a comma-separated list.
149
122
 
150
123
  }
124
+
125
+ else
126
+ hash = {}
151
127
  end
128
+
129
+ puts JQuery::Methods.new(opts_hash.merge(hash)).named_list.sort.join("\n") if hash
@@ -0,0 +1,113 @@
1
+ require 'getoptlong'
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ gem 'jquery-cheat'
5
+ require 'merger'
6
+
7
+ PATH = File.join(Gem.cache.search("jquery-cheat").sort_by{|x| x.version.version}.last.full_gem_path, 'lib','index.xml')
8
+
9
+ class JQuery::Method
10
+
11
+ attr_accessor :short, :long, :cat, :params, :options, :examples, :name, :attributes, :param_order, :type
12
+
13
+ def initialize elem
14
+ @name = elem.attributes["name"]
15
+ @short = elem.attributes["short"]
16
+ @long = elem.search("> desc").inner_text
17
+ @cat = elem.attributes["cat"]
18
+ @params = elem.search("params").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
19
+ @param_order = elem.search("params").map {|p| p.attributes["name"]}
20
+ @options = elem.search("options").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
21
+ @type = elem.attributes["type"]
22
+ @examples = elem.search("examples").map do |example|
23
+ {:desc => example.search("desc").inner_text,
24
+ :before => example.search("before").inner_text,
25
+ :code => example.search("code").inner_text,
26
+ :result => example.search("result").inner_text
27
+ }
28
+
29
+ end
30
+ @attributes = elem.attributes
31
+ end
32
+
33
+ def signature
34
+ "#{name}#{"(#{ param_order.join(", ") })" if !attributes["property"] } in #{cat}"
35
+ end
36
+
37
+ end
38
+
39
+ class JQuery::Parser
40
+
41
+ @@parsed = Hpricot::XML(File.read(PATH))
42
+
43
+ # The options hash supports the following options
44
+ # <tt>name</tt>:: search for methods matching the name passed
45
+ # <tt>substring</tt>:: to be used with :name. If :substring is true, all functions containing the substring passed in :name
46
+ # will be returned (defaults to false).
47
+ # <tt>module</tt>:: search for methods in :module
48
+ # <tt>recursive</tt>:: to be used with :module. If :recursive is true, all functions in :module, or its child modules will
49
+ # be returned (defaults to false)
50
+ # <tt>like</tt>:: search for methods whose descriptions include any strings included in the Array :like
51
+ # <tt>params</tt>:: search for methods whose parameters include all of the strings include in the Array :params
52
+ def self.get_methods_by_hash options = {}
53
+ filters = "method"
54
+ filters += "[@name#{ '*' if options[:substring] }='#{options[:name]}']" if options[:name]
55
+ filters += "[@cat#{ '*' if options[:recursive] }='#{options[:module]}']" if options[:module]
56
+ methods = @@parsed.search(filters)
57
+ methods.reject! {|m| options[:like].any? {|t| m.search("> desc").inner_text !~ /#{t}/i} } if options[:like]
58
+ methods.reject! {|m| options[:params].any? {|p| m.search("params[@name=#{p}]").length == 0 } } if options[:params]
59
+ methods
60
+ end
61
+
62
+ def self.category_list
63
+ @@parsed.search("[@cat]").map {|x| x.get_attribute("cat")}.uniq
64
+ end
65
+
66
+ end
67
+
68
+ class JQuery::Methods < Array
69
+
70
+ def initialize els
71
+ if(els.is_a?(Hash))
72
+ push(*JQuery::Parser.get_methods_by_hash(els).to_jquery_methods)
73
+ else
74
+ push(*els.to_jquery_methods)
75
+ end
76
+ end
77
+
78
+ def self.get_methods options = {}
79
+ JQuery::Parser.get_methods_by_hash(options)
80
+ end
81
+
82
+ def self.with_name_and_params name, *params
83
+ new(@@parsed.search("method[@name='#{name}']").reject{|m| params.any? {|p| m.search("params[@name=#{p}]").length == 0 } })
84
+ end
85
+
86
+ def named_list
87
+ list = inject([]) {|s,m| s.push(m.signature) }
88
+ list.empty? ? ["No items found"] : list
89
+ end
90
+
91
+ end
92
+
93
+ class Array
94
+
95
+ def to_jquery_methods
96
+ map {|m| JQuery::Method.new(m)}
97
+ end
98
+
99
+ end
100
+
101
+ class String
102
+
103
+ def word_wrap cols, padding = 0
104
+ gsub(/\n\n/, "\r").gsub(/\n/, ' ').gsub(/\r/, "\n\n#{' ' * 14}").gsub(/(.{1,#{cols}}|\S{#{cols + 1},})(?: +|$\n?)/, "\\1\n#{ ' ' * padding}")
105
+ end
106
+
107
+ end
108
+
109
+ class GetoptLong
110
+
111
+ attr_accessor :argument_flags
112
+
113
+ end
@@ -1,8 +1,8 @@
1
1
  module JQueryCheat #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 2
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,27 @@
1
+ module JQuery
2
+
3
+ def self.convert(a)
4
+ h = {}
5
+ a.each do |s|
6
+ parse_into(h, s)
7
+ end
8
+ h
9
+ end
10
+
11
+ def self.parse_into(frob, s)
12
+ s.split("/").each { |s1| frob = (frob[s1] ||= {}) }
13
+ end
14
+
15
+ def self.print_tree(hsh, c = 0)
16
+ hsh.each do |k,v|
17
+ puts k
18
+ if c > 0
19
+ print "|#{'-' * c}"
20
+ end
21
+ if v != {}
22
+ self.print_tree(v, c + 1)
23
+ end
24
+ end
25
+ end
26
+
27
+ end
@@ -1,11 +1,92 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require 'flexmock/test_unit'
3
+
4
+ StubMethod = JQueryMethod.dup
5
+ StubMethods = JQueryMethods.dup
6
+
7
+ class StubMethod
8
+ def initialize options = {}
9
+ @name = options[:name] || "function"
10
+ @param_order = options[:param_order] || ["param1", "param2"]
11
+ @cat = options[:cat] || "MyModule"
12
+ @attributes = options[:attributes] || {}
13
+ end
14
+ end
15
+
16
+ class StubMethods < Array
17
+ def initialize *args
18
+ if args[0]
19
+ args[0].each {|hsh| self.push(StubMethod.new(hsh)) }
20
+ else
21
+ push(StubMethod.new)
22
+ push(StubMethod.new(:name => "function2", :param_order => ["param_b1"], :cat => "MyModule", :attributes => {:property => true}))
23
+ end
24
+ end
25
+ end
2
26
 
3
27
  class TestJQueryCheat < Test::Unit::TestCase
4
28
 
29
+ @@parsed = Hpricot::XML(File.read(File.join(Gem.cache.search("jquery-cheat").sort_by{|x| x.version.version}.last.full_gem_path, 'lib','index.xml')))
30
+
5
31
  def setup
6
32
  end
7
33
 
8
- def test_truth
9
- assert true
34
+ def test_named
35
+ assert_hash_equals_filter({:name => '$'}, "method[@name='$']")
36
+ assert_hash_equals_filter({:name => '$', :precise => true}, "method[@name='$']")
10
37
  end
38
+
39
+ def test_named_imprecise
40
+ assert_hash_equals_filter({:name => '$', :precise => false}, "method[@name*='$']")
41
+ end
42
+
43
+ def test_module
44
+ assert_hash_equals_filter({:module => "Core"}, "method[@cat='Core']")
45
+ assert_hash_equals_filter({:module => "Core", :recursive => false}, "method[@cat='Core']")
46
+ end
47
+
48
+ def test_module_recursive
49
+ assert_hash_equals_filter({:module => "DOM", :recursive => true}, "method[@cat*='DOM']")
50
+ end
51
+
52
+ def test_like
53
+ expected_parse = @@parsed.search("method[@cat*='Plugins']").reject {|m| m.search("> desc").inner_text !~ /clear/i }
54
+ assert_equal JQueryParser.get_methods_by_hash(:module => "Plugins", :recursive => true, :like => ["clear"]).inner_html, expected_parse.inner_html
55
+ end
56
+
57
+ def test_like_multiple
58
+ expected_parse = @@parsed.search("method[@cat*='Plugins']").reject {|m| m.search("> desc").inner_text !~ /clear/i || m.search("> desc").inner_text !~ /field/i }
59
+ assert_equal JQueryParser.get_methods_by_hash(:module => "Plugins", :recursive => true, :like => ["clear", "field"]).inner_html, expected_parse.inner_html
60
+ end
61
+
62
+ def test_params
63
+ expected_parse = @@parsed.search("method[@cat*='Core']").reject {|m| m.search("params[@name=html]").length == 0 }
64
+ assert_equal JQueryParser.get_methods_by_hash(:module => "Core", :recursive => true, :params => ["html"]).inner_html, expected_parse.inner_html
65
+ end
66
+
67
+ def test_params_multiple
68
+ expected_parse = @@parsed.search("method[@cat*='Core']").reject {|m| m.search("params[@name=expr]").length == 0 || m.search("params[@name=context]").length == 0}
69
+ assert_equal JQueryParser.get_methods_by_hash(:module => "Core", :recursive => true, :params => ["expr", "context"]).inner_html, expected_parse.inner_html
70
+ end
71
+
72
+ def test_signature
73
+ assert_equal StubMethod.new({}).signature, "function(param1, param2) in MyModule"
74
+ end
75
+
76
+ def test_named_list
77
+ assert_equal StubMethods.new.named_list, ["function(param1, param2) in MyModule", "function2(param_b1) in MyModule"]
78
+ end
79
+
80
+ def test_empty_named_list
81
+ assert_equal StubMethods.new([]).named_list, ["No items found"]
82
+ end
83
+
84
+ def test_new_methods_by_hash
85
+ assert_equal JQueryMethods.new(:name => '$').length, JQueryParser.get_methods_by_hash(:name => '$').length
86
+ end
87
+
88
+ def assert_hash_equals_filter hash, filter
89
+ assert_equal JQueryParser.get_methods_by_hash(hash).inner_html, @@parsed.search(filter).inner_html
90
+ end
91
+
11
92
  end
@@ -33,7 +33,7 @@
33
33
  <h1>jquery cheat</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/jquery-cheat"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/jquery-cheat" class="numbers">0.1.1</a>
36
+ <a href="http://rubyforge.org/projects/jquery-cheat" class="numbers">0.2.0</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;jquery-cheat&#8217;</h1>
39
39
 
@@ -52,61 +52,95 @@
52
52
  <h2>Demonstration of usage</h2>
53
53
 
54
54
 
55
- <p>jcheat takes any of the following parameters:</p>
55
+ <h3>Main commands</h3>
56
56
 
57
57
 
58
+ <pre>jcheat COMMAND [COMMAND_PREFS] [--name NAME [--precise]]
59
+ [--module MODULE [--recursive]] [--like STRING]
60
+ [--params PARAM1[,PARAM2...]] [--no-examples]</pre>
61
+
58
62
  <ul>
59
- <li>(describe|desc) <span class="caps">METHOD</span>_NAME [PARAM1, ...]
63
+ <li><pre>(describe|desc) METHOD_NAME [PARAM1, ...]</pre>
60
64
  <ul>
61
- <li>the full description of each method matching <span class="caps">METHOD</span>_NAME.</li>
62
- <li>If you also pass optional PARAMs, the list of matching
65
+ <li>the full description of each method matching <span class="caps">METHOD</span>_NAME.
66
+ If you also pass optional PARAMs, the list of matching
63
67
  methods will be filtered to include only methods with those
64
68
  parameters.</li>
65
- <li>Example: &#8220;jcheat desc $ html&#8221; will return the description
69
+ <li><code>--no-examples(-e)</code> suppresses examples from the output</li>
70
+ <li>Example: <code>jcheat desc $ html</code> will return the description
66
71
  of the $ method with an &#8220;html&#8221; parameter.</li>
67
72
  </ul></li>
68
73
  </ul>
69
74
 
70
75
 
71
76
  <ul>
72
- <li>list <span class="caps">MODULE</span>_NAME [-r]
77
+ <li><pre>list MODULE_NAME</pre>
73
78
  <ul>
74
79
  <li>A list of all methods directly under a specific module. Passing
75
- an optional &#8220;-r&#8221; will return a list of all methods at any level
80
+ an optional <code>-r</code> will return a list of all methods at any level
76
81
  under the module.</li>
77
- <li>Example: &#8220;jcheat list <span class="caps">DOM</span>/Traversing&#8221;</li>
82
+ <li>Example: <code>jcheat list DOM/Traversing</code></li>
78
83
  </ul></li>
79
84
  </ul>
80
85
 
81
86
 
82
87
  <ul>
83
- <li>(apopros|ap|like) <span class="caps">STRING</span>
88
+ <li><pre>(apopros|ap|like) STRING</pre>
84
89
  <ul>
85
90
  <li>A list of all methods whose description contains all of the
86
91
  words in <span class="caps">STRING</span>.</li>
87
- <li>Example: &#8220;jcheat like clear fields&#8221;</li>
92
+ <li>Example: <code>jcheat like clear fields</code></li>
88
93
  </ul></li>
89
94
  </ul>
90
95
 
91
96
 
92
97
  <ul>
93
- <li>named <span class="caps">STRING</span>
98
+ <li><pre>named STRING</pre>
94
99
  <ul>
95
100
  <li>A list of all methods named exactly <span class="caps">STRING</span>.</li>
96
- <li>Example: &#8220;jcheat named $&#8221;</li>
101
+ <li>Example: <code>jcheat named $</code></li>
97
102
  </ul></li>
98
103
  </ul>
99
104
 
100
105
 
101
106
  <ul>
102
- <li>(namelike|nl) <span class="caps">STRING</span>
107
+ <li><pre>(namelike|nl) STRING</pre>
103
108
  <ul>
104
109
  <li>A list of all methods whose names contain <span class="caps">STRING</span>.</li>
105
- <li>Example: &#8220;jcheat nl clear&#8221;</li>
110
+ <li>Example: <code>jcheat nl clear</code></li>
106
111
  </ul></li>
107
112
  </ul>
108
113
 
109
114
 
115
+ <h3>Filters</h3>
116
+
117
+
118
+ <ul>
119
+ <li><code>[--name(-n) NAME [--substrings(-s)]]</code> filters methods by their name.
120
+ Adding the&#8212;precise flag will allow a substring match.</li>
121
+ </ul>
122
+
123
+
124
+ <ul>
125
+ <li><code>[--module(-m) MODULE [--recursive(-r)]]</code> filters methods by the
126
+ module they are in. Adding the&#8212;recursive flag will check
127
+ submodules (ex: -m <span class="caps">DOM</span> -r will search for methods in <span class="caps">DOM</span>,
128
+ <span class="caps">DOM</span>/Traversal, etc.)</li>
129
+ </ul>
130
+
131
+
132
+ <ul>
133
+ <li><code>[--like(-l) STRING]</code> filters methods by words in their description.</li>
134
+ </ul>
135
+
136
+
137
+ <ul>
138
+ <li><code>[--params(-o) PARAM1[,PARAM2...]]</code> filters methods by those that
139
+ contain all of the parameters passed in. Parameters should be
140
+ passed as a comma-separated list.</li>
141
+ </ul>
142
+
143
+
110
144
  <h2>License</h2>
111
145
 
112
146
 
@@ -12,34 +12,55 @@ h2. Installing
12
12
 
13
13
  h2. Demonstration of usage
14
14
 
15
- jcheat takes any of the following parameters:
15
+ h3. Main commands
16
16
 
17
- * (describe|desc) METHOD_NAME [PARAM1, ...]
17
+ <pre>jcheat COMMAND [COMMAND_PREFS] [--name NAME [--precise]]
18
+ [--module MODULE [--recursive]] [--like STRING]
19
+ [--params PARAM1[,PARAM2...]] [--no-examples]</pre>
20
+
21
+ * <pre>(describe|desc) METHOD_NAME [PARAM1, ...]</pre>
18
22
  ** the full description of each method matching METHOD_NAME.
19
- ** If you also pass optional PARAMs, the list of matching
23
+ If you also pass optional PARAMs, the list of matching
20
24
  methods will be filtered to include only methods with those
21
25
  parameters.
22
- ** Example: "jcheat desc $ html" will return the description
26
+ ** <code>--no-examples(-e)</code> suppresses examples from the output
27
+ ** Example: <code>jcheat desc $ html</code> will return the description
23
28
  of the $ method with an "html" parameter.
24
29
 
25
- * list MODULE_NAME [-r]
30
+ * <pre>list MODULE_NAME</pre>
26
31
  ** A list of all methods directly under a specific module. Passing
27
- an optional "-r" will return a list of all methods at any level
32
+ an optional <code>-r</code> will return a list of all methods at any level
28
33
  under the module.
29
- ** Example: "jcheat list DOM/Traversing"
34
+ ** Example: <code>jcheat list DOM/Traversing</code>
30
35
 
31
- * (apopros|ap|like) STRING
36
+ * <pre>(apopros|ap|like) STRING</pre>
32
37
  ** A list of all methods whose description contains all of the
33
38
  words in STRING.
34
- ** Example: "jcheat like clear fields"
39
+ ** Example: <code>jcheat like clear fields</code>
35
40
 
36
- * named STRING
41
+ * <pre>named STRING</pre>
37
42
  ** A list of all methods named exactly STRING.
38
- ** Example: "jcheat named $"
43
+ ** Example: <code>jcheat named $</code>
39
44
 
40
- * (namelike|nl) STRING
45
+ * <pre>(namelike|nl) STRING</pre>
41
46
  ** A list of all methods whose names contain STRING.
42
- ** Example: "jcheat nl clear"
47
+ ** Example: <code>jcheat nl clear</code>
48
+
49
+ h3. Filters
50
+
51
+ * <code>[--name(-n) NAME [--substrings(-s)]]</code> filters methods by their name.
52
+ Adding the --precise flag will allow a substring match.
53
+
54
+ * <code>[--module(-m) MODULE [--recursive(-r)]]</code> filters methods by the
55
+ module they are in. Adding the --recursive flag will check
56
+ submodules (ex: -m DOM -r will search for methods in DOM,
57
+ DOM/Traversal, etc.)
58
+
59
+ * <code>[--like(-l) STRING]</code> filters methods by words in their description.
60
+
61
+ * <code>[--params(-o) PARAM1[,PARAM2...]]</code> filters methods by those that
62
+ contain all of the parameters passed in. Parameters should be
63
+ passed as a comma-separated list.
43
64
 
44
65
  h2. License
45
66
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: jquery-cheat
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
6
+ version: 0.2.0
7
7
  date: 2007-06-01 00:00:00 -07:00
8
8
  summary: jQuery command-line API reference
9
9
  require_paths:
@@ -36,7 +36,9 @@ files:
36
36
  - Rakefile
37
37
  - bin/jcheat
38
38
  - lib/index.xml
39
+ - lib/jquery-cheat.rb
39
40
  - lib/jquery-cheat/version.rb
41
+ - lib/merger.rb
40
42
  - scripts/txt2html
41
43
  - setup.rb
42
44
  - test/test_helper.rb