jsduck 3.0.pre2 → 3.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.md +14 -7
  2. data/Rakefile +277 -24
  3. data/bin/compare +163 -0
  4. data/bin/stats +92 -0
  5. data/jsduck.gemspec +3 -3
  6. data/lib/jsduck/accessors.rb +64 -8
  7. data/lib/jsduck/aggregator.rb +10 -6
  8. data/lib/jsduck/aliases.rb +3 -2
  9. data/lib/jsduck/app.rb +51 -44
  10. data/lib/jsduck/author_tag.rb +11 -0
  11. data/lib/jsduck/categories.rb +14 -8
  12. data/lib/jsduck/class.rb +2 -1
  13. data/lib/jsduck/class_formatter.rb +5 -4
  14. data/lib/jsduck/doc_author_tag.rb +11 -0
  15. data/lib/jsduck/doc_formatter.rb +17 -37
  16. data/lib/jsduck/doc_parser.rb +39 -11
  17. data/lib/jsduck/exporter.rb +11 -0
  18. data/lib/jsduck/guides.rb +3 -3
  19. data/lib/jsduck/images.rb +72 -0
  20. data/lib/jsduck/js_parser.rb +20 -4
  21. data/lib/jsduck/lexer.rb +2 -8
  22. data/lib/jsduck/lint.rb +3 -2
  23. data/lib/jsduck/logger.rb +24 -5
  24. data/lib/jsduck/merger.rb +38 -8
  25. data/lib/jsduck/meta_tag.rb +49 -0
  26. data/lib/jsduck/meta_tag_loader.rb +48 -0
  27. data/lib/jsduck/options.rb +37 -25
  28. data/lib/jsduck/os.rb +11 -0
  29. data/lib/jsduck/renderer.rb +37 -34
  30. data/lib/jsduck/search_data.rb +1 -1
  31. data/lib/jsduck/source_file.rb +13 -8
  32. data/template-min/app.js +1 -1
  33. data/template-min/{egIframe.html → extIframe.html} +3 -4
  34. data/template-min/extjs/ext-all-debug.js +3107 -2026
  35. data/template-min/extjs/ext-all.js +1 -1
  36. data/template-min/extjs/resources/css/ext-all.css +1 -1
  37. data/template-min/resources/css/app.css +1 -1
  38. data/template-min/resources/images/down-arr.png +0 -0
  39. data/template-min/resources/images/gettingstarted.jpg +0 -0
  40. data/template-min/resources/images/ipad-l.jpg +0 -0
  41. data/template-min/resources/images/ipad-p.jpg +0 -0
  42. data/template-min/resources/images/iphone-l.jpg +0 -0
  43. data/template-min/resources/images/iphone-p.jpg +0 -0
  44. data/template-min/resources/images/iphone-small-l.jpg +0 -0
  45. data/template-min/resources/images/iphone-small-p.jpg +0 -0
  46. data/template-min/resources/images/link-arrow-next.png +0 -0
  47. data/template-min/template.html +5 -1
  48. data/template-min/touch-welcome.html +122 -0
  49. data/template-min/touchIframe.html +85 -0
  50. data/template-min/welcome.html +2 -0
  51. metadata +25 -8
  52. data/lib/jsduck/page.rb +0 -118
  53. data/lib/jsduck/timer.rb +0 -44
data/README.md CHANGED
@@ -49,17 +49,24 @@ single .exe file. Grab it from the [download page][].
49
49
  Usage
50
50
  -----
51
51
 
52
- For the simplest test-run just pass in the src/ dir of Ext JS 4:
52
+ For the simplest test-run just use the `--builtin-classes` option to
53
+ automatically produce documentation for JavaScript builtin classes
54
+ like Array, String and Object:
53
55
 
54
- $ jsduck ext-4.0.2a/src --output your/docs
56
+ $ jsduck --builtin-classes --output your/docs
57
+
58
+ You can also use `--verbose` option to see what's actually happening.
59
+
60
+ To generate docs for Ext JS 4 add path to the corresponding src/ dir:
61
+
62
+ $ jsduck --builtin-classes --output your/docs extjs-4.0.2a/src
55
63
 
56
64
  Running JSDuck with the current ext-4.0.2a release is expected to
57
65
  generate a lot of warnings. Because of the bugs in doc-comments a
58
66
  global class will also get created. You can disable this by adding
59
67
  `--ignore-global` switch. If you are bothered by the excessive amount
60
- of warnings, use the `--no-warnings` switch. Now it might look like
61
- nothing is happening... check out the `--verbose` flag. For more
62
- command line options type `jsduck --help`.
68
+ of warnings, use the `--no-warnings` switch. For full list of command
69
+ line options type `jsduck --help=full`.
63
70
 
64
71
  The latest ext-4.0.6 release will produce only few warnings, so use
65
72
  that if you can get it.
@@ -79,7 +86,7 @@ source files for these.
79
86
  To generate docs for your own project, simply add as many other input
80
87
  directories as needed:
81
88
 
82
- $ jsduck ext-4.0.2a/src project1/js project2/js --output your/docs
89
+ $ jsduck --builtin-classes ext-4.0.2a/src project1/js project2/js --output your/docs
83
90
 
84
91
  Of course you don't have to include the whole Ext JS into your
85
92
  documentation, but if your project is built on top of it, it makes
@@ -102,7 +109,7 @@ See [Hacking guide](https://github.com/senchalabs/jsduck/wiki/Hacking) in wiki.
102
109
  Documenting your code
103
110
  ---------------------
104
111
 
105
- All the supported syntax is described in the [Guide][].
112
+ All the supported syntax is described in the [Guide][].
106
113
 
107
114
 
108
115
  Copying
data/Rakefile CHANGED
@@ -27,6 +27,8 @@ def load_sdk_vars
27
27
  puts " OUT_DIR='/path/to/ouput/dir'"
28
28
  puts " # path to SDK (for developers at Sencha)"
29
29
  puts " SDK_DIR='/path/to/SDK'"
30
+ puts " # path to Animator (for developers at Sencha)"
31
+ puts " ANIMATOR_DIR='/path/to/Animator'"
30
32
  exit 1
31
33
  end
32
34
  end
@@ -93,6 +95,8 @@ def compress
93
95
  # Now do everything that follows in template-min/ dir
94
96
  dir = "template-min"
95
97
 
98
+ # Create JSB3 file for Docs app
99
+ system("sencha", "create", "jsb", "-a", "#{dir}/build-js.html", "-p", "#{dir}/app.jsb3")
96
100
  # Concatenate files listed in JSB3 file
97
101
  system("sencha", "build", "-p", "#{dir}/app.jsb3", "-d", dir)
98
102
  # Remove intermediate build files
@@ -143,6 +147,7 @@ class JsDuckRunner
143
147
  @sdk_dir = SDK_DIR
144
148
  @out_dir = OUT_DIR
145
149
  @ext_dir = EXT_DIR
150
+ @animator_dir = ANIMATOR_DIR
146
151
  end
147
152
 
148
153
  def add_options(options)
@@ -163,22 +168,42 @@ class JsDuckRunner
163
168
  "--guides", "#{@sdk_dir}/extjs/docs/guides.json",
164
169
  "--videos", "#{@sdk_dir}/extjs/docs/videos.json",
165
170
  "--examples", "#{@sdk_dir}/extjs/examples/examples.json",
166
- "--inline-examples", "#{@sdk_dir}/extjs/docs/resources",
167
171
  "--categories", "#{@sdk_dir}/extjs/docs/categories.json",
168
172
  "--output", "#{@out_dir}",
169
173
  "--builtin-classes",
174
+ "--images", "#{@sdk_dir}/extjs/docs/resources",
175
+ "--images", "#{@sdk_dir}/platform/docs/resources",
170
176
  "#{@sdk_dir}/extjs/src",
171
177
  "#{@sdk_dir}/platform/src",
172
178
  "#{@sdk_dir}/platform/core/src",
173
179
  ]
174
180
  end
175
181
 
182
+ def add_ext3
183
+ @options += [
184
+ "--title", "Sencha Docs - Ext JS 3.4",
185
+ "--footer", "Ext JS 3.4 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
186
+ "--categories", "#{@sdk_dir}/../ext-3.4.0/src/categories.json",
187
+ "--ignore-global",
188
+ "--output", "#{@out_dir}",
189
+ "#{@sdk_dir}/../ext-3.4.0/src/core",
190
+ "#{@sdk_dir}/../ext-3.4.0/src/data",
191
+ "#{@sdk_dir}/../ext-3.4.0/src/dd",
192
+ "#{@sdk_dir}/../ext-3.4.0/src/direct",
193
+ "#{@sdk_dir}/../ext-3.4.0/src/ext-core/src",
194
+ "#{@sdk_dir}/../ext-3.4.0/src/state",
195
+ "#{@sdk_dir}/../ext-3.4.0/src/util",
196
+ "#{@sdk_dir}/../ext-3.4.0/src/widgets"
197
+ ]
198
+ end
199
+
176
200
  def add_ext4
177
201
  @options += [
178
202
  "--title", "Sencha Docs - Ext JS 4.0",
179
203
  "--footer", "Ext JS 4.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
180
204
  "--ignore-global",
181
205
  "--no-warnings",
206
+ "--images", "#{@ext_dir}/docs/doc-resources",
182
207
  "--output", "#{@out_dir}",
183
208
  "#{@ext_dir}/src",
184
209
  ]
@@ -186,24 +211,138 @@ class JsDuckRunner
186
211
 
187
212
  def add_touch
188
213
  head_html = <<-EOHTML
189
- <link rel="canonical" href="http://docs.sencha.com/touch/1-0/" />
190
- <meta name="description" content="Sencha Touch 1.0 API Documentation from Sencha. Documentation on how to create Javascript applications with Sencha Touch">
214
+ <link rel="canonical" href="http://docs.sencha.com/touch/1-1/" />
215
+ <meta name="description" content="Sencha Touch 1.1 API Documentation from Sencha. Documentation on how to create Javascript applications with Sencha Touch">
191
216
  EOHTML
192
217
 
193
218
  @options += [
194
- "--title", "Sencha Docs - Touch 1.0",
219
+ "--title", "Sencha Docs - Touch 1.1",
195
220
  "--head-html", head_html,
196
- "--footer", "Sencha Touch 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
221
+ "--footer", "Sencha Touch 1.1 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
197
222
  "--categories", "#{@sdk_dir}/touch/doc-resources/categories.json",
198
223
  "--videos", "#{@sdk_dir}/touch/doc-resources/videos.json",
199
224
  "--output", "#{@out_dir}",
200
225
  "--external=google.maps.Map,google.maps.LatLng",
226
+ "--images", "#{@sdk_dir}/touch/doc-resources",
201
227
  "#{@sdk_dir}/touch/resources/themes/stylesheets/sencha-touch/default",
202
228
  ]
203
229
 
204
230
  @options += extract_jsb_build_files("#{@sdk_dir}/touch/sencha-touch.jsb3")
205
231
  end
206
232
 
233
+ def add_touch2
234
+ head_html = <<-EOHTML
235
+ <link rel="canonical" href="http://docs.sencha.com/touch/2-0/" />
236
+ <meta name="description" content="Sencha Touch 2.0 API Documentation from Sencha. Documentation on how to create Javascript applications with Sencha Touch">
237
+ EOHTML
238
+
239
+ @options += [
240
+ "--title", "Sencha Docs - Touch 2.0",
241
+ "--head-html", head_html,
242
+ "--footer", "Sencha Touch 2.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
243
+ "--categories", "#{@sdk_dir}/touch/docs/categories.json",
244
+ "--welcome", "template/touch-welcome.html",
245
+ "--videos", "#{@sdk_dir}/touch/docs/videos.json",
246
+ "--guides", "#{@sdk_dir}/touch/docs/guides.json",
247
+ "--examples", "#{@sdk_dir}/touch/docs/examples.json",
248
+ "--touch-examples-ui",
249
+ "--output", "#{@out_dir}",
250
+ "--external=google.maps.Map,google.maps.LatLng",
251
+ "--builtin-classes",
252
+ "--img", "<p class='screenshot'><img src='%u' alt='%a'><span>%a</span></p>",
253
+ "#{@sdk_dir}/touch/resources/themes/stylesheets/sencha-touch/default",
254
+ ]
255
+
256
+ @options += extract_jsb_build_files("#{@sdk_dir}/touch/touch.jsb3")
257
+ end
258
+
259
+ def add_touch_export
260
+ @options += [
261
+ "--json",
262
+ "--output", "#{@out_dir}/../export/touch1",
263
+ "--external=google.maps.Map,google.maps.LatLng",
264
+ ]
265
+ @options += extract_jsb_build_files("#{@sdk_dir}/touch/sencha-touch.jsb3")
266
+ end
267
+
268
+ def add_touch2_export
269
+ @options += [
270
+ "--json",
271
+ "--output", "#{@out_dir}/../export/touch2",
272
+ "--external=google.maps.Map,google.maps.LatLng",
273
+ ]
274
+ @options += extract_jsb_build_files("#{@sdk_dir}/touch/touch.jsb3")
275
+ end
276
+
277
+ def set_touch2_src
278
+ relative_touch_path = "../"
279
+ touch_iframe = "template-min/touchIframe.html";
280
+
281
+ ["template-min/touchIframe.html", "template-min/touch-welcome.html"].each do |file|
282
+ html = IO.read(file);
283
+
284
+ touch_src_re = /((src|href)="touch)/m
285
+ out = []
286
+
287
+ html.each_line do |line|
288
+ out << line.sub(/((src|href)="touch\/)/, '\2="' + relative_touch_path)
289
+ end
290
+
291
+ File.open(file, 'w') {|f| f.write(out) }
292
+ end
293
+
294
+ head_html = <<-EOHTML
295
+ <script type="text/javascript">
296
+ Docs.exampleBaseUrl = "#{relative_touch_path}examples/";
297
+ if (Ext.is.Phone) { window.location = "#{relative_touch_path}examples/"; }
298
+ </script>
299
+ <div id="notice-text" style="display: none">
300
+ 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
301
+ </div>
302
+ EOHTML
303
+
304
+ @options += [
305
+ "--welcome", "template-min/touch-welcome.html",
306
+ "--body-html", head_html
307
+ ]
308
+ end
309
+
310
+ def add_touch_charts
311
+ head_html = <<-EOHTML
312
+ <link rel="canonical" href="http://docs.sencha.com/touch-charts/1-0/" />
313
+ <meta name="description" content="Sencha Touch Charts 1.0 API Documentation. Documentation on how to create Charts with Sencha Touch">
314
+ EOHTML
315
+
316
+ @options += [
317
+ "--title", "Sencha Docs - Touch Charts 1.0",
318
+ "--head-html", head_html,
319
+ "--footer", "Sencha Touch Charts 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a>",
320
+ "--categories", "#{@sdk_dir}/charts/docs/categories.json",
321
+ "--guides", "#{@sdk_dir}/charts/docs/guides.json",
322
+ "--images", "#{@sdk_dir}/charts/docs/resources",
323
+ "--output", "#{@out_dir}"
324
+ ]
325
+
326
+ @options += extract_jsb_build_files("#{@sdk_dir}/charts/touch-charts.jsb3")
327
+ end
328
+
329
+ def add_animator
330
+ head_html = <<-EOHTML
331
+ <link rel="canonical" href="http://docs.sencha.com/animator/1-0/" />
332
+ <meta name="description" content="Sencha Animator 1.0 API Documentation from Sencha. Documentation on how to create Javascript applications with Sencha Touch">
333
+ EOHTML
334
+
335
+ @options += [
336
+ "--title", "Sencha Docs - Animator 1.0",
337
+ "--head-html", head_html,
338
+ "--footer", "Sencha Animator 1.0 Docs - Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{revision}",
339
+ # "--videos", "#{@animator_dir}/docs/videos.json",
340
+ "--guides", "#{@animator_dir}/docs/guides.json",
341
+ # "--examples", "#{@animator_dir}/docs/examples/examples.json",
342
+ "--output", "#{@out_dir}",
343
+ ]
344
+ end
345
+
207
346
  # Extracts files of first build in jsb file
208
347
  def extract_jsb_build_files(jsb_file)
209
348
  json = JSON.parse(IO.read(jsb_file))
@@ -246,6 +385,16 @@ class JsDuckRunner
246
385
  ]
247
386
  end
248
387
 
388
+ def add_touch2_export_notice
389
+ @options += [
390
+ "--body-html", <<-EOHTML
391
+ <div id="notice-text" style="display: none">
392
+ 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
393
+ </div>
394
+ EOHTML
395
+ ]
396
+ end
397
+
249
398
  def add_google_analytics
250
399
  @options += [
251
400
  "--body-html", <<-EOHTML
@@ -287,25 +436,37 @@ class JsDuckRunner
287
436
  }
288
437
  });
289
438
  }
439
+
440
+ Docs.otherProducts = [
441
+ {
442
+ text: 'Ext JS 4',
443
+ href: 'http://docs.sencha.com/ext-js/4-0'
444
+ },
445
+ {
446
+ text: 'Ext JS 3',
447
+ href: 'http://docs.sencha.com/ext-js/3-4'
448
+ },
449
+ {
450
+ text: 'Sencha Touch 2',
451
+ href: 'http://docs.sencha.com/touch/2-0'
452
+ },
453
+ {
454
+ text: 'Sencha Touch 1',
455
+ href: 'http://docs.sencha.com/touch/1-1'
456
+ },
457
+ {
458
+ text: 'Touch Charts',
459
+ href: 'http://docs.sencha.com/touch-charts/1-0'
460
+ },
461
+ {
462
+ text: 'Sencha Animator',
463
+ href: 'http://docs.sencha.com/animator/1-0'
464
+ }
465
+ ];
290
466
  </script>
291
467
  EOHTML
292
468
  ]
293
- end
294
-
295
- # Copy over the images that SDK documentation links to
296
- def copy_sdk_images
297
- system "cp -r #{@sdk_dir}/extjs/docs/resources #{@out_dir}/doc-resources"
298
- system "cp -r #{@sdk_dir}/platform/docs/resources/* #{@out_dir}/doc-resources"
299
- end
300
-
301
- # Copy over the images that Ext4 documentation links to
302
- def copy_ext4_images
303
- system "cp -r #{@ext_dir}/docs/doc-resources #{@out_dir}/doc-resources"
304
- end
305
469
 
306
- # Copy over the images that Sencha Touch documentation links to.
307
- def copy_touch_images
308
- system "cp -r #{@sdk_dir}/touch/doc-resources #{@out_dir}/doc-resources"
309
470
  end
310
471
 
311
472
  # Copy over SDK examples
@@ -317,6 +478,16 @@ class JsDuckRunner
317
478
  system "cp -r #{@ext_dir}/welcome #{@out_dir}/extjs"
318
479
  end
319
480
 
481
+ def copy_animator_examples
482
+ system "mkdir -p #{@out_dir}/extjs"
483
+ system "cp -r #{@animator_dir}/docs/examples #{@out_dir}/extjs"
484
+ end
485
+
486
+ # Copy over Sencha Touch
487
+ def copy_touch2_build
488
+ system "cp -r #{@sdk_dir}/touch/build #{@out_dir}/touch"
489
+ end
490
+
320
491
  def run
321
492
  # Pass multiple arguments to system, so we'll take advantage of the built-in escaping
322
493
  system(*["ruby", "bin/jsduck"].concat(@options))
@@ -351,8 +522,6 @@ task :sdk, [:mode] => :sass do |t, args|
351
522
  runner.add_google_analytics if mode == "live"
352
523
  runner.run
353
524
 
354
- runner.copy_sdk_images
355
-
356
525
  runner.copy_sdk_examples if mode == "export" || mode == "live"
357
526
  end
358
527
 
@@ -369,8 +538,23 @@ task :ext4, [:mode] => :sass do |t, args|
369
538
  runner.add_debug if mode == "debug"
370
539
  runner.add_seo
371
540
  runner.run
541
+ end
542
+
543
+ desc "Run JSDuck on official Ext JS 3.4 build\n" +
544
+ "ext3 - creates debug/development version\n" +
545
+ "ext3[export] - creates export/deployable version\n"
546
+ "ext3[live] - creates live version for deployment\n"
547
+ task :ext3, [:mode] => :sass do |t, args|
548
+ mode = args[:mode] || "debug"
549
+ throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode)
550
+ compress if mode == "export"
372
551
 
373
- runner.copy_ext4_images
552
+ runner = JsDuckRunner.new
553
+ runner.add_ext3
554
+ runner.add_debug if mode == "debug"
555
+ runner.add_seo if mode == "live"
556
+ runner.add_google_analytics if mode == "live"
557
+ runner.run
374
558
  end
375
559
 
376
560
  desc "Run JSDuck on Sencha Touch (for internal use at Sencha)\n" +
@@ -385,9 +569,78 @@ task :touch, [:mode] => :sass do |t, args|
385
569
  runner.add_touch
386
570
  runner.add_debug if mode == "debug"
387
571
  runner.add_seo if mode == "debug" || mode == "live"
572
+ runner.add_google_analytics if mode == "live"
573
+ runner.run
574
+ end
575
+
576
+ desc "Run JSDuck on Sencha Touch 2 (for internal use at Sencha)\n" +
577
+ "touch2 - creates debug/development version\n" +
578
+ "touch2[export] - creates export version\n" +
579
+ "touch2[live] - create live version for deployment\n"
580
+ task :touch2, [:mode] => :sass do |t, args|
581
+ mode = args[:mode] || "debug"
582
+ throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode)
583
+ compress if mode == "live" || mode == "export"
584
+
585
+ runner = JsDuckRunner.new
586
+ runner.add_touch2
587
+ runner.add_debug if mode == "debug"
588
+ runner.add_touch2_export_notice if mode == "export"
589
+ runner.set_touch2_src if mode == "export"
590
+ runner.add_seo if mode == "debug" || mode == "live"
591
+ runner.add_google_analytics if mode == "live"
592
+ runner.run
593
+
594
+ runner.copy_touch2_build if mode != "export"
595
+ end
596
+
597
+ desc "Run JSDuck on Sencha Touch Charts (for internal use at Sencha)\n" +
598
+ "charts - creates debug/development version\n" +
599
+ "charts[export] - create live version for deployment\n"
600
+ "charts[live] - create live version for deployment\n"
601
+ task :charts, [:mode] => :sass do |t, args|
602
+ mode = args[:mode] || "debug"
603
+ throw "Unknown mode #{mode}" unless ["debug", "export", "live"].include?(mode)
604
+ compress if mode == "live"
605
+
606
+ runner = JsDuckRunner.new
607
+ runner.add_touch_charts
608
+ runner.add_debug if mode == "debug"
609
+ runner.add_seo if mode == "debug" || mode == "live"
610
+ runner.add_google_analytics if mode == "live"
611
+ runner.run
612
+ end
613
+
614
+ desc "Run JSDuck JSON Export (for internal use at Sencha)\n" +
615
+ "export[touch] - creates export for Touch 1\n" +
616
+ "export[touch2] - creates export for Touch 2"
617
+ task :export, [:mode] do |t, args|
618
+ mode = args[:mode]
619
+ throw "Unknown mode #{mode}" unless ["touch", "touch2"].include?(mode)
620
+
621
+ runner = JsDuckRunner.new
622
+ runner.add_touch_export if mode == "touch"
623
+ runner.add_touch2_export if mode == "touch2"
624
+ runner.run
625
+ end
626
+
627
+ desc "Run JSDuck on Sencha Animator (for internal use at Sencha)\n" +
628
+ "animator - creates debug/development version\n" +
629
+ "animator[export] - create live version for deployment\n"
630
+ "animator[live] - create live version for deployment\n"
631
+ task :animator, [:mode] => :sass do |t, args|
632
+ mode = args[:mode] || "debug"
633
+ throw "Unknown mode #{mode}" unless ["debug", "live", "export"].include?(mode)
634
+ compress if mode == "live"
635
+
636
+ runner = JsDuckRunner.new
637
+ runner.add_animator
638
+ runner.add_debug if mode == "debug"
639
+ runner.add_seo if mode == "debug" || mode == "live"
640
+ runner.add_google_analytics if mode == "live"
388
641
  runner.run
389
642
 
390
- runner.copy_touch_images
643
+ runner.copy_animator_examples
391
644
  end
392
645
 
393
646
  desc "Build JSDuck gem"
data/bin/compare ADDED
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env ruby
2
+ # Compare .json files of different ExtJS versions
3
+
4
+ # For running when gem not installed
5
+ $:.unshift File.dirname(File.dirname(__FILE__)) + "/lib"
6
+
7
+ require "rubygems"
8
+ require "jsduck/json_duck"
9
+
10
+ def read_class(filename)
11
+ JsDuck::JsonDuck.read(filename)
12
+ end
13
+
14
+ def read_all_classes(dir, ignore_private=false)
15
+ map = {}
16
+ Dir[dir+"/*.json"].each do |filename|
17
+ print "."
18
+ STDOUT.flush
19
+ cls = read_class(filename)
20
+ unless ignore_private && cls["private"]
21
+ map[cls["name"]] = cls
22
+ cls["alternateClassNames"].each do |name|
23
+ map[name] = cls
24
+ end
25
+ end
26
+ end
27
+ puts "OK"
28
+ map
29
+ end
30
+
31
+ # Gathers class members that are in cls1, but are missing in cls2
32
+ def compare_classes(cls1, cls2)
33
+ diff = []
34
+ cls1["members"].each_pair do |group_name, group_items|
35
+ group_items.find_all {|m1| !m1["private"] && !m1["protected"] && m1["owner"] == cls1["name"] }.each do |m1|
36
+ match = cls2["members"][group_name].find do |m2|
37
+ m2["name"] == m1["name"] && !m2["protected"] && !m2["private"]
38
+ end
39
+ if !match && m1["name"] != "constructor" && m1["name"] != ""
40
+ other = nil
41
+ ["cfg", "property", "method", "event"].each do |g|
42
+ other = other || cls2["members"][g].find {|m2| m2["name"] == m1["name"] }
43
+ other = other || cls2["statics"][g].find {|m2| m2["name"] == m1["name"] }
44
+ end
45
+ diff << {
46
+ :type => group_name,
47
+ :name => m1["name"],
48
+ :other => other ? {
49
+ :type => other["tagname"],
50
+ :static => other["static"],
51
+ :private => other["private"],
52
+ :protected => other["protected"],
53
+ } : nil
54
+ }
55
+ end
56
+ end
57
+ end
58
+ diff
59
+ end
60
+
61
+
62
+
63
+ old_classes = read_all_classes(ARGV[0], :ignore_private)
64
+ new_classes = read_all_classes(ARGV[1])
65
+ out_file = ARGV[2]
66
+
67
+ diff_data = []
68
+ old_classes.each_pair do |name, cls|
69
+ if name == cls["name"]
70
+ new_cls = new_classes[cls["name"]]
71
+ # Remap classes like Array to Ext.Array
72
+ new_cls = new_classes["Ext."+cls["name"]] unless new_cls
73
+
74
+ diff_data << {
75
+ :name => cls["name"],
76
+ :found => !!new_cls,
77
+ :new_name => new_cls && new_cls["name"],
78
+ :diff => new_cls ? compare_classes(cls, new_cls) : [],
79
+ }
80
+ end
81
+ end
82
+
83
+ # Choose title based on filename
84
+ if out_file =~ /touch/
85
+ title = "Comparison of Touch 1.1.1 and Touch 2.0.0"
86
+ else
87
+ title = "Comparison of Ext 4.0.7 and Ext 4.1.0"
88
+ end
89
+
90
+ # do HTML output
91
+ html = []
92
+ html << <<-EOHTML
93
+ <!DOCTYPE html>
94
+ <html>
95
+ <head>
96
+ <title>#{title}</title>
97
+ <style type="text/css">
98
+ body { font-family: Georgia, serif; }
99
+ li h2 { font-size: medium; font-weight: normal; }
100
+ li ul { display: none; }
101
+ </style>
102
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
103
+ <script>
104
+ $(function() {
105
+ $("h2 > a").live("click", function() {
106
+ $("ul", $(this).parent().parent()).toggle();
107
+ return false;
108
+ });
109
+ });
110
+ </script>
111
+ </head>
112
+ <body>
113
+ <h1>#{title}</h1>
114
+ EOHTML
115
+
116
+ html << "<ul>"
117
+ diff_data.sort! {|a, b| a[:name] <=> b[:name] }
118
+ diff_data.each do |cls|
119
+ if !cls[:found] || cls[:diff].length > 0
120
+ html << "<li>"
121
+ if cls[:found]
122
+ new_name = (cls[:new_name] == cls[:name] ? "" : " --> " + cls[:new_name])
123
+ diff_count = cls[:diff].length > 0 ? "(#{cls[:diff].length} missing members)" : ""
124
+ link = cls[:diff].length > 0 ? "<a href='#expand'>#{cls[:name]}</a>" : cls[:name]
125
+ html << "<h2>#{link} #{new_name} #{diff_count}</h2>"
126
+ if cls[:diff].length > 0
127
+ html << "<ul>"
128
+ cls[:diff].each do |m|
129
+ html << "<li>"
130
+ html << m[:type] + " " + m[:name]
131
+ if m[:other]
132
+ o = m[:other]
133
+ stat = o[:static] ? 'static' : ''
134
+ priv = o[:private] ? 'private' : ''
135
+ prot = o[:protected] ? 'protected' : ''
136
+ html << " (found #{stat} #{priv} #{prot} #{o[:type]} with the same name)"
137
+ end
138
+ html << "</li>"
139
+ end
140
+ html << "</ul>"
141
+ end
142
+ else
143
+ html << "<h2>" + cls[:name] + " <b>not found</b></h2>"
144
+ end
145
+ html << "</li>"
146
+ end
147
+ end
148
+ html << "</ul>"
149
+
150
+ html << "<h2>Summary</h2>"
151
+ dd = diff_data
152
+ html << "<p>" + dd.find_all {|c| !c[:found] }.length.to_s + " classes not found</p>"
153
+ html << "<p>" + dd.find_all {|c| c[:found] && c[:name] == c[:new_name] }.length.to_s + " classes with same name</p>"
154
+ html << "<p>" + dd.find_all {|c| c[:found] && c[:name] != c[:new_name] }.length.to_s + " renamed classes</p>"
155
+ html << "<p>" + dd.find_all {|c| c[:diff].length > 0 }.length.to_s + " classes with missing members</p>"
156
+ html << "<p>" + dd.map {|c| c[:diff].length }.inject {|sum,x| sum + x }.to_s + " missing members</p>"
157
+ html << "<p>" + dd.map {|c| c[:diff].find_all {|m| !m[:other]}.length }.inject {|sum,x| sum + x }.to_s + " completely missing members</p>"
158
+
159
+
160
+ html << "</body>"
161
+ html << "</html>"
162
+
163
+ File.open(out_file, 'w') {|f| f.write(html.join("\n")) }