jsduck 4.6.1 → 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - "1.8.7"
4
- - "1.9.2"
4
+ - "1.9.3"
5
5
  install:
6
6
  - gem install rdiscount
7
7
  - gem install json
@@ -9,3 +9,4 @@ install:
9
9
  - gem install therubyracer -v 0.10.1
10
10
  - gem install rspec
11
11
  - gem install rake
12
+ - gem install dimensions
data/README.md CHANGED
@@ -11,8 +11,8 @@ the old [ext-doc][] was. It is used by Sencha to document [Ext JS
11
11
  products.
12
12
 
13
13
  The highlights of JSDuck are [Markdown][] support and keeping you DRY
14
- by inferring a lot of information from code. Read the [Guide][] for
15
- full overview.
14
+ by inferring a lot of information from code. Read the
15
+ [documentation][] for full overview.
16
16
 
17
17
  **New to JSDuck?** Watch [introductory talk by Nick Poulden][video]:
18
18
 
@@ -23,8 +23,8 @@ full overview.
23
23
  [Markdown]: http://daringfireball.net/projects/markdown/
24
24
  [ext4-docs]: http://docs.sencha.com/ext-js/4-0/
25
25
  [touch2-docs]: http://docs.sencha.com/touch/2-0/
26
- [other-docs]: http://docs.sencha.com/ext-js/4-0/
27
- [Guide]: https://github.com/senchalabs/jsduck/wiki/Guide
26
+ [other-docs]: http://docs.sencha.com/
27
+ [documentation]: https://github.com/senchalabs/jsduck/wiki
28
28
  [video]: http://vimeo.com/33465319
29
29
 
30
30
  Getting it
@@ -112,21 +112,15 @@ directories:
112
112
  Note that the resulting documentation will only contain the API
113
113
  documentation. Guides, videos and examples will not be present.
114
114
  These can be added using more command line options as explained in the
115
- [Advanced Usage][adv] section of wiki.
116
-
117
- [adv]: https://github.com/senchalabs/jsduck/wiki/Advanced-Usage
115
+ [documentation][].
118
116
 
119
117
 
120
118
  Documenting your code
121
119
  ---------------------
122
120
 
123
- For quick overview read the [Guide][] and take a look at [example.js][example].
124
- Follow links in the guide to digg into the details.
125
-
126
- Looking for specific @tag? Take a look at the [whole list of supported tags][tags].
121
+ Read the [documentation][] and take a look at [example.js][example].
127
122
 
128
123
  [example]: https://github.com/senchalabs/jsduck/blob/master/opt/example.js
129
- [tags]: https://github.com/senchalabs/jsduck/wiki/Tags
130
124
 
131
125
 
132
126
  Hacking it
data/Rakefile CHANGED
@@ -104,7 +104,7 @@ def compress
104
104
  dir = "template-min"
105
105
 
106
106
  # Create JSB3 file for Docs app
107
- system("sencha", "create", "jsb", "-a", "http://localhost/docs/", "-p", "#{dir}/app.jsb3")
107
+ system("sencha", "create", "jsb", "-a", "http://localhost/~renesaarsoo/docs/", "-p", "#{dir}/app.jsb3")
108
108
  # Concatenate files listed in JSB3 file
109
109
  system("sencha", "build", "-p", "#{dir}/app.jsb3", "-d", dir)
110
110
 
@@ -234,7 +234,7 @@
234
234
 
235
235
  /**
236
236
  * @method getDate
237
- * Returns the numeric value corresponding to the current time.
237
+ * Returns the day of the month for the specified date according to local time.
238
238
  *
239
239
  * The second statement below assigns the value 25 to the variable `day`, based on the value of the
240
240
  * `Date` object `Xmas95`.
@@ -247,7 +247,7 @@
247
247
 
248
248
  /**
249
249
  * @method getDay
250
- * Returns the numeric value corresponding to the current time.
250
+ * Returns the day of the week for the specified date according to local time.
251
251
  *
252
252
  * The value returned by `getDay` is an integer corresponding to the day of the week: 0 for Sunday, 1
253
253
  * for Monday, 2 for Tuesday, and so on.
@@ -264,7 +264,7 @@
264
264
 
265
265
  /**
266
266
  * @method getFullYear
267
- * Returns the numeric value corresponding to the current time.
267
+ * Returns the year of the specified date according to local time.
268
268
  *
269
269
  * The value returned by `getFullYear` is an absolute number. For dates between the years 1000 and
270
270
  * 9999, `getFullYear` returns a four-digit number, for example, 1995. Use this function to make sure
@@ -282,7 +282,7 @@
282
282
 
283
283
  /**
284
284
  * @method getHours
285
- * Returns the numeric value corresponding to the current time.
285
+ * Returns the hour for the specified date according to local time.
286
286
  *
287
287
  * The second statement below assigns the value 23 to the variable `hours`, based on the value of the
288
288
  * `Date` object `Xmas95`.
@@ -295,7 +295,7 @@
295
295
 
296
296
  /**
297
297
  * @method getMilliseconds
298
- * Returns the numeric value corresponding to the current time.
298
+ * Returns the milliseconds in the specified date according to local time.
299
299
  *
300
300
  * The following example assigns the milliseconds portion of the current time to the variable ms.
301
301
  *
@@ -308,7 +308,7 @@
308
308
 
309
309
  /**
310
310
  * @method getMinutes
311
- * Returns the numeric value corresponding to the current time.
311
+ * Returns the minutes in the specified date according to local time.
312
312
  *
313
313
  * The second statement below assigns the value 15 to the variable `minutes`, based on the value of
314
314
  * the `Date` object `Xmas95`.
@@ -321,7 +321,7 @@
321
321
 
322
322
  /**
323
323
  * @method getMonth
324
- * Returns the numeric value corresponding to the current time.
324
+ * Returns the month in the specified date according to local time.
325
325
  *
326
326
  * The second statement below assigns the value 11 to the variable `month`, based on the value of the
327
327
  * `Date` object `Xmas95`.
@@ -334,7 +334,7 @@
334
334
 
335
335
  /**
336
336
  * @method getSeconds
337
- * Returns the numeric value corresponding to the current time.
337
+ * Returns the seconds in the specified date according to local time.
338
338
  *
339
339
  * The second statement below assigns the value 30 to the variable `secs`, based on the value of the
340
340
  * `Date` object `Xmas95`.
@@ -347,7 +347,8 @@
347
347
 
348
348
  /**
349
349
  * @method getTime
350
- * Returns the numeric value corresponding to the current time.
350
+ * Returns the numeric value corresponding to the time for the specified date according to
351
+ * universal time.
351
352
  *
352
353
  * The value returned by the `getTime` method is the number of milliseconds since 1 January 1970
353
354
  * 00:00:00 UTC. You can use this method to help assign a date and time to another `Date` object.
@@ -381,7 +382,7 @@
381
382
 
382
383
  /**
383
384
  * @method getTimezoneOffset
384
- * Returns the numeric value corresponding to the current time.
385
+ * Returns the time-zone offset from UTC, in minutes, for the current locale.
385
386
  *
386
387
  * The time-zone offset is the difference, in minutes, between UTC and local time. Note that this
387
388
  * means that the offset is positive if the local timezone is behind UTC and negative if it is ahead.
@@ -396,7 +397,7 @@
396
397
 
397
398
  /**
398
399
  * @method getUTCDate
399
- * Returns the numeric value corresponding to the current time.
400
+ * Returns the day (date) of the month in the specified date according to universal time.
400
401
  *
401
402
  * The following example assigns the day portion of the current date to the variable `d`.
402
403
  *
@@ -409,7 +410,7 @@
409
410
 
410
411
  /**
411
412
  * @method getUTCDay
412
- * Returns the numeric value corresponding to the current time.
413
+ * Returns the day of the week in the specified date according to universal time.
413
414
  *
414
415
  * The following example assigns the weekday portion of the current date to the variable `weekday`.
415
416
  *
@@ -423,7 +424,7 @@
423
424
 
424
425
  /**
425
426
  * @method getUTCFullYear
426
- * Returns the numeric value corresponding to the current time.
427
+ * Returns the year in the specified date according to universal time.
427
428
  *
428
429
  * The following example assigns the four-digit value of the current year to the variable `yr`.
429
430
  *
@@ -436,7 +437,7 @@
436
437
 
437
438
  /**
438
439
  * @method getUTCHours
439
- * Returns the numeric value corresponding to the current time.
440
+ * Returns the hours in the specified date according to universal time.
440
441
  *
441
442
  * The following example assigns the hours portion of the current time to the variable `hrs`.
442
443
  *
@@ -449,7 +450,7 @@
449
450
 
450
451
  /**
451
452
  * @method getUTCMilliseconds
452
- * Returns the numeric value corresponding to the current time.
453
+ * Returns the milliseconds in the specified date according to universal time.
453
454
  *
454
455
  * The following example assigns the milliseconds portion of the current time to the variable `ms`.
455
456
  *
@@ -462,7 +463,7 @@
462
463
 
463
464
  /**
464
465
  * @method getUTCMinutes
465
- * Returns the numeric value corresponding to the current time.
466
+ * Returns the minutes in the specified date according to universal time.
466
467
  *
467
468
  * The following example assigns the minutes portion of the current time to the variable `min`.
468
469
  *
@@ -475,7 +476,7 @@
475
476
 
476
477
  /**
477
478
  * @method getUTCMonth
478
- * Returns the numeric value corresponding to the current time.
479
+ * Returns the month of the specified date according to universal time.
479
480
  *
480
481
  * The following example assigns the month portion of the current date to the variable `mon`.
481
482
  *
@@ -488,7 +489,7 @@
488
489
 
489
490
  /**
490
491
  * @method getUTCSeconds
491
- * Returns the numeric value corresponding to the current time.
492
+ * Returns the seconds in the specified date according to universal time.
492
493
  *
493
494
  * The following example assigns the seconds portion of the current time to the variable `sec`.
494
495
  *
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
2
2
  s.required_rubygems_version = ">= 1.3.5"
3
3
 
4
4
  s.name = 'jsduck'
5
- s.version = '4.6.1'
6
- s.date = '2013-01-17'
5
+ s.version = '4.6.2'
6
+ s.date = '2013-02-25'
7
7
  s.summary = "Simple JavaScript Duckumentation generator"
8
8
  s.description = "Documentation generator for Sencha JS frameworks"
9
9
  s.homepage = "https://github.com/senchalabs/jsduck"
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'json'
24
24
  s.add_dependency 'parallel'
25
25
  s.add_dependency 'therubyracer', '>= 0.10.0', '< 0.11.0'
26
+ s.add_dependency 'dimensions'
26
27
 
27
28
  s.add_development_dependency 'rspec'
28
29
  s.add_development_dependency 'rake'
@@ -1,4 +1,5 @@
1
- require 'jsduck/images'
1
+ require 'jsduck/img/dir_set'
2
+ require 'jsduck/img/writer'
2
3
  require 'jsduck/welcome'
3
4
  require 'jsduck/guides'
4
5
  require 'jsduck/videos'
@@ -26,10 +27,9 @@ module JsDuck
26
27
  @relations = relations
27
28
  @opts = opts
28
29
 
29
- doc_formatter = DocFormatter.new(@opts)
30
- doc_formatter.relations = @relations
30
+ doc_formatter = DocFormatter.new(@relations, @opts)
31
31
 
32
- @images = Images.new(@opts.images)
32
+ @images = Img::DirSet.new(@opts.images, "images")
33
33
  @welcome = Welcome.create(@opts.welcome, doc_formatter)
34
34
  @guides = Guides.create(@opts.guides, doc_formatter, @opts)
35
35
  @videos = Videos.create(@opts.videos)
@@ -43,7 +43,7 @@ module JsDuck
43
43
  # Welcome page and categories are written in JsDuck::IndexHtml
44
44
  def write
45
45
  @guides.write(@opts.output_dir+"/guides")
46
- @images.copy(@opts.output_dir+"/images")
46
+ Img::Writer.copy(@images.all_used, @opts.output_dir+"/images")
47
47
  end
48
48
 
49
49
  end
@@ -79,7 +79,7 @@ module JsDuck
79
79
  make_class(to_s(var["id"]), var["right"])
80
80
 
81
81
  # function Foo() {}
82
- elsif function?(ast) && class_name?(to_s(ast["id"]))
82
+ elsif function?(ast) && ast["id"] && class_name?(to_s(ast["id"]))
83
83
  make_class(to_s(ast["id"]))
84
84
 
85
85
  # { ... }
@@ -88,7 +88,7 @@ module JsDuck
88
88
 
89
89
  # function foo() {}
90
90
  elsif function?(ast)
91
- make_method(to_s(ast["id"]), ast)
91
+ make_method(ast["id"] ? to_s(ast["id"]) : "", ast)
92
92
 
93
93
  # foo = function() {}
94
94
  elsif exp && assignment?(exp) && function?(exp["right"])
@@ -1,6 +1,7 @@
1
1
  require 'jsduck/util/parallel'
2
2
  require 'jsduck/class_formatter'
3
3
  require 'jsduck/doc_formatter'
4
+ require 'jsduck/img/dir_set'
4
5
  require 'jsduck/logger'
5
6
 
6
7
  module JsDuck
@@ -21,7 +22,7 @@ module JsDuck
21
22
  begin
22
23
  {
23
24
  :doc => formatter.format(cls.internal_doc),
24
- :images => formatter.images
25
+ :images => formatter.images.all_used
25
26
  }
26
27
  rescue
27
28
  Logger.fatal_backtrace("Error while formatting #{cls[:name]} #{files}", $!)
@@ -32,15 +33,20 @@ module JsDuck
32
33
  # Then merge the data back to classes sequentially
33
34
  formatted_classes.each do |cls|
34
35
  relations[cls[:doc][:name]].internal_doc = cls[:doc]
35
- cls[:images].each {|img| assets.images.add(img) }
36
+ # Perform lookup of all the images again. We're really doing
37
+ # this work twice now, but as we usually don't have excessive
38
+ # amounts of images, the performance penalty should be minimal.
39
+ cls[:images].each {|img| assets.images.get(img[:filename]) }
36
40
  end
41
+
42
+ # Print warnings for unused images
43
+ assets.images.report_unused
37
44
  end
38
45
 
39
46
  # Factory method to create new ClassFormatter instances.
40
47
  def self.create_class_formatter(relations, opts)
41
- doc_formatter = DocFormatter.new(opts)
42
- doc_formatter.relations = relations
43
- doc_formatter.img_path = "images"
48
+ doc_formatter = DocFormatter.new(relations, opts)
49
+ doc_formatter.images = Img::DirSet.new(opts.images, "images")
44
50
 
45
51
  class_formatter = ClassFormatter.new(relations, doc_formatter)
46
52
  # Don't format types when exporting
@@ -33,7 +33,7 @@ module JsDuck
33
33
  cls
34
34
  end
35
35
 
36
- # Returns the images detected by doc-formatter
36
+ # Access to the Img::DirSet object inside doc-formatter
37
37
  def images
38
38
  @formatter.images
39
39
  end
@@ -3,6 +3,8 @@ require 'strscan'
3
3
  require 'rdiscount'
4
4
  require 'jsduck/html_stack'
5
5
  require 'jsduck/inline/link'
6
+ require 'jsduck/inline/auto_link'
7
+ require 'jsduck/inline/link_renderer'
6
8
  require 'jsduck/inline/img'
7
9
  require 'jsduck/inline/video'
8
10
  require 'jsduck/inline/example'
@@ -15,21 +17,21 @@ module JsDuck
15
17
  # Creates a formatter configured with options originating from
16
18
  # command line. For the actual effect of the options see
17
19
  # Inline::* classes.
18
- def initialize(opts={})
20
+ def initialize(relations={}, opts={})
19
21
  @opts = opts
20
- @inline_link = Inline::Link.new(opts)
22
+ @link_renderer = Inline::LinkRenderer.new(relations, opts)
23
+ @inline_link = Inline::Link.new(@link_renderer)
24
+ @auto_link = Inline::AutoLink.new(@link_renderer)
21
25
  @inline_img = Inline::Img.new(opts)
22
26
  @inline_video = Inline::Video.new(opts)
23
27
  @inline_example = Inline::Example.new(opts)
24
28
  @doc_context = {}
25
29
  end
26
30
 
27
- # Sets base path to prefix images from {@img} tags.
28
- def img_path=(path)
29
- @inline_img.base_path = path
31
+ # Accessors to the images attribute of Inline::Img
32
+ def images=(images)
33
+ @inline_img.images = images
30
34
  end
31
-
32
- # Returns list of all image paths gathered from {@img} tags.
33
35
  def images
34
36
  @inline_img.images
35
37
  end
@@ -39,6 +41,7 @@ module JsDuck
39
41
  # Context#blah is meant.
40
42
  def class_context=(cls)
41
43
  @inline_link.class_context = cls
44
+ @auto_link.class_context = cls
42
45
  end
43
46
 
44
47
  # Sets up instance to work in context of particular doc object.
@@ -47,6 +50,8 @@ module JsDuck
47
50
  @doc_context = doc
48
51
  @inline_video.doc_context = doc
49
52
  @inline_link.doc_context = doc
53
+ @auto_link.doc_context = doc
54
+ @inline_img.doc_context = doc
50
55
  end
51
56
 
52
57
  # Returns the current documentation context
@@ -54,15 +59,6 @@ module JsDuck
54
59
  @doc_context
55
60
  end
56
61
 
57
- # JsDuck::Relations for looking up class names.
58
- #
59
- # When auto-creating class links from CamelCased names found from
60
- # text, we check the relations object to see if a class with that
61
- # name actually exists.
62
- def relations=(relations)
63
- @inline_link.relations = relations
64
- end
65
-
66
62
  # Formats doc-comment for placement into HTML.
67
63
  # Renders it with Markdown-formatter and replaces @link-s.
68
64
  def format(input)
@@ -114,13 +110,15 @@ module JsDuck
114
110
  # There might still be "{" that doesn't begin {@link} or {@img} - ignore it
115
111
  out += s.scan(/[{]/)
116
112
  elsif substitute = @inline_example.replace(s)
113
+ tags.push_tag("pre")
114
+ tags.push_tag("code")
117
115
  out += substitute
118
116
  elsif s.check(/<\w/)
119
117
  # Open HTML tag
120
- out += s.scan(/</) + tags.open(s.scan(/\w+/)) + s.scan_until(/>|\Z/)
118
+ out += tags.open(s)
121
119
  elsif s.check(/<\/\w+>/)
122
120
  # Close HTML tag
123
- out += s.scan(/<\//) + tags.close(s.scan(/\w+/)) + s.scan(/>/)
121
+ out += tags.close(s)
124
122
  elsif s.check(/</)
125
123
  # Ignore plain '<' char.
126
124
  out += s.scan(/</)
@@ -128,16 +126,16 @@ module JsDuck
128
126
  # Replace class names in the following text up to next "<" or "{"
129
127
  # but only when we're not inside <a>...</a>
130
128
  text = s.scan(/[^{<]+/)
131
- out += tags.open?("a") ? text : @inline_link.create_magic_links(text)
129
+ out += tags.open?("a") ? text : @auto_link.replace(text)
132
130
  end
133
131
  end
134
132
 
135
- out + tags.close_unfinished
133
+ out
136
134
  end
137
135
 
138
136
  # Creates a link based on the link template.
139
137
  def link(cls, member, anchor_text, type=nil, static=nil)
140
- @inline_link.link(cls, member, anchor_text, type, static)
138
+ @link_renderer.link(cls, member, anchor_text, type, static)
141
139
  end
142
140
 
143
141
  end
@@ -176,7 +176,7 @@ module JsDuck
176
176
  end
177
177
 
178
178
  def indented_as_code?
179
- @current_tag[:doc] =~ /^ {4,}[^\n]*\Z/
179
+ @current_tag[:doc] =~ /^ {4,}[^\n]*\z/
180
180
  end
181
181
 
182
182
  # Processes anything else beginning with @-sign.