jsduck 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -37,6 +37,10 @@ install the header files for compiling extension modules for Ruby 1.9.
37
37
  For Debian systems you'll need the `ruby1.9-dev` package. For Red Hat
38
38
  / CentOS / Fedora use the `ruby-devel` package.
39
39
 
40
+ In **OSX Mountain Lion** the compilation of `therubyracer` dependency
41
+ often fails for so far unknown reasons. Most users have found a
42
+ solution in upgrading to Ruby 1.9 using [RVM][].
43
+
40
44
  For **Windows** users out there, you can download the binary version,
41
45
  which includes Ruby interpreter and all dependencies bundled in a
42
46
  single .exe file. Grab it from the [download page][].
@@ -57,6 +61,7 @@ most sensible place to put it). Now you're ready to install JSDuck:
57
61
 
58
62
  > gem install jsduck
59
63
 
64
+ [RVM]: https://rvm.io/
60
65
  [download page]: https://github.com/senchalabs/jsduck/downloads
61
66
  [libs download]: https://github.com/stereobooster/therubyracer/downloads
62
67
 
@@ -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.0.0'
6
- s.date = '2012-08-09'
5
+ s.version = '4.0.1'
6
+ s.date = '2012-08-21'
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"
@@ -232,9 +232,15 @@ module JsDuck
232
232
  Enum.new(@classes).process_all!
233
233
  end
234
234
 
235
- # Processes all overrides
235
+ # Processes all overrides.
236
+ # Returns list of override classes.
236
237
  def process_overrides
237
- Override.new(@classes, @documentation).process_all!
238
+ Override.new(@classes).process_all!.map do |cls|
239
+ # discard each override class
240
+ @classes.delete(cls[:name])
241
+ @documentation.delete(cls)
242
+ cls
243
+ end
238
244
  end
239
245
 
240
246
  # Are we dealing with ExtJS 4?
@@ -130,7 +130,8 @@ module JsDuck
130
130
  agr.append_ext4_event_options
131
131
  end
132
132
  agr.process_enums
133
- agr.process_overrides
133
+ # Ignore override classes after applying them to actual classes
134
+ @opts.external_classes += agr.process_overrides.map {|o| o[:name] }
134
135
  agr.result
135
136
  end
136
137
 
@@ -33,6 +33,8 @@ module JsDuck
33
33
  :cfg
34
34
  elsif doc_map[:constructor]
35
35
  :method
36
+ elsif doc_map[:param] || doc_map[:return]
37
+ :method
36
38
  else
37
39
  code[:tagname]
38
40
  end
@@ -17,6 +17,8 @@ module JsDuck
17
17
  #
18
18
  # {:long => "something", :short => "SOM"}
19
19
  #
20
+ # Additionally the hash can contain a :tooltip which is the text
21
+ # to be shown when the signature bubble is hovered over in docs.
20
22
  attr_reader :signature
21
23
 
22
24
  # True to include all lines up to next @tag as part of this meta-tag
@@ -0,0 +1,34 @@
1
+ require 'jsduck/meta_tag_registry'
2
+
3
+ module JsDuck
4
+
5
+ # Performs the rendering of meta tags.
6
+ class MetaTagRenderer
7
+
8
+ # Renders full meta tags of a particular section.
9
+ #
10
+ # Returns array of rendered HTML or nil if no meta data.
11
+ def self.render(meta_data, position)
12
+ return if meta_data.size == 0
13
+
14
+ MetaTagRegistry.instance.tags(position).map do |tag|
15
+ meta_data[tag.key]
16
+ end
17
+ end
18
+
19
+ # Renders the meta-tag signatures for a class member.
20
+ # Returns a string.
21
+ def self.render_signature(member)
22
+ html = []
23
+ MetaTagRegistry.instance.signatures.each do |s|
24
+ if member[:meta][s[:key]]
25
+ title = s[:tooltip] ? "title='#{s[:tooltip]}'" : ""
26
+ html << "<strong class='#{s[:key]} signature' #{title}>#{s[:long]}</strong>"
27
+ end
28
+ end
29
+ html.join
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -79,7 +79,7 @@ module JsDuck
79
79
  @ext4_events = nil
80
80
  @meta_tag_paths = []
81
81
 
82
- @version = "4.0.0"
82
+ @version = "4.0.1"
83
83
 
84
84
  # Customizing output
85
85
  @title = "Documentation - JSDuck"
@@ -138,6 +138,7 @@ module JsDuck
138
138
 
139
139
  reg = MetaTagRegistry.new
140
140
  reg.load([:builtins] + @meta_tag_paths)
141
+ reg[:new].create_tooltip!(@imports, @new_since)
141
142
  MetaTagRegistry.instance = reg
142
143
  end
143
144
 
@@ -1,27 +1,23 @@
1
1
  module JsDuck
2
2
 
3
3
  class Override
4
- def initialize(classes_hash, classes_array)
4
+ def initialize(classes_hash)
5
5
  @classes_hash = classes_hash
6
- @classes_array = classes_array
7
6
  end
8
7
 
9
8
  # Applies all override classes to target classes
9
+ # Returns all the processed override classes.
10
10
  def process_all!
11
11
  overrides = []
12
12
 
13
- @classes_array.each do |cls|
13
+ @classes_hash.each_value do |cls|
14
14
  if cls[:override]
15
15
  process(cls)
16
16
  overrides << cls
17
17
  end
18
18
  end
19
19
 
20
- # Discard override classes
21
- overrides.each do |cls|
22
- @classes_hash.delete(cls[:name])
23
- @classes_array.delete(cls)
24
- end
20
+ overrides
25
21
  end
26
22
 
27
23
  private
@@ -1,5 +1,6 @@
1
- require 'jsduck/meta_tag_registry'
2
1
  require 'jsduck/html'
2
+ require 'jsduck/meta_tag_renderer'
3
+ require 'jsduck/signature_renderer'
3
4
 
4
5
  module JsDuck
5
6
 
@@ -12,6 +13,7 @@ module JsDuck
12
13
 
13
14
  def render(cls)
14
15
  @cls = cls
16
+ @signature = SignatureRenderer.new(cls)
15
17
 
16
18
  return [
17
19
  "<div>",
@@ -60,9 +62,7 @@ module JsDuck
60
62
  end
61
63
 
62
64
  def render_meta_data(meta_data, position)
63
- return if meta_data.size == 0
64
-
65
- MetaTagRegistry.instance.tags(position).map {|tag| meta_data[tag.key] }
65
+ MetaTagRenderer.render(meta_data, position)
66
66
  end
67
67
 
68
68
  def render_sidebar
@@ -241,43 +241,7 @@ module JsDuck
241
241
  end
242
242
 
243
243
  def render_signature(m)
244
- expandable = m[:shortDoc] ? "expandable" : "not-expandable"
245
-
246
- name = m[:name]
247
- before = ""
248
- if m[:tagname] == :method && m[:name] == "constructor"
249
- before = "<strong class='new-keyword'>new</strong>"
250
- name = @cls[:name]
251
- end
252
-
253
- if m[:tagname] == :cfg || m[:tagname] == :property || m[:tagname] == :css_var
254
- params = "<span> : #{m[:html_type]}</span>"
255
- else
256
- ps = m[:params].map {|p| render_short_param(p) }.join(", ")
257
- params = "( <span class='pre'>#{ps}</span> )"
258
- if m[:tagname] == :method && m[:return][:type] != "undefined"
259
- params += " : " + m[:return][:html_type]
260
- end
261
- end
262
-
263
- after = ""
264
- MetaTagRegistry.instance.signatures.each do |s|
265
- after += "<strong class='#{s[:key]} signature'>#{s[:long]}</strong>" if m[:meta][s[:key]]
266
- end
267
-
268
- uri = "#!/api/#{m[:owner]}-#{m[:id]}"
269
-
270
- return [
271
- before,
272
- "<a href='#{uri}' class='name #{expandable}'>#{name}</a>",
273
- params,
274
- after
275
- ]
276
- end
277
-
278
- def render_short_param(param)
279
- p = param[:html_type] + " " + param[:name]
280
- return param[:optional] ? "["+p+"]" : p
244
+ @signature.render(m)
281
245
  end
282
246
 
283
247
  def render_long_doc(m)
@@ -0,0 +1,92 @@
1
+ require 'jsduck/meta_tag_renderer'
2
+
3
+ module JsDuck
4
+
5
+ # Performs the rendering of member signatures.
6
+ class SignatureRenderer
7
+ # Initializes the renderer for rendering members of the given
8
+ # class.
9
+ def initialize(cls)
10
+ @cls = cls
11
+ end
12
+
13
+ # Renders signature of the given member.
14
+ def render(member)
15
+ # Keep the code simpler by not passing around the member hash
16
+ @m = member
17
+
18
+ return [
19
+ render_new,
20
+ render_link,
21
+ render_type,
22
+ render_meta,
23
+ ]
24
+ end
25
+
26
+ private
27
+
28
+ def render_new
29
+ constructor? ? "<strong class='new-keyword'>new</strong>" : ""
30
+ end
31
+
32
+ def render_link
33
+ "<a href='#{render_url}' class='name #{render_expandable}'>#{render_name}</a>"
34
+ end
35
+
36
+ def render_url
37
+ "#!/api/#{@m[:owner]}-#{@m[:id]}"
38
+ end
39
+
40
+ def render_expandable
41
+ @m[:shortDoc] ? "expandable" : "not-expandable"
42
+ end
43
+
44
+ def render_name
45
+ constructor? ? @cls[:name] : @m[:name]
46
+ end
47
+
48
+ def constructor?
49
+ @m[:tagname] == :method && @m[:name] == "constructor"
50
+ end
51
+
52
+ def render_type
53
+ if like_property?
54
+ render_property_type
55
+ else
56
+ render_params + render_return
57
+ end
58
+ end
59
+
60
+ def like_property?
61
+ @m[:tagname] == :cfg || @m[:tagname] == :property || @m[:tagname] == :css_var
62
+ end
63
+
64
+ def render_property_type
65
+ "<span> : #{@m[:html_type]}</span>"
66
+ end
67
+
68
+ def render_params
69
+ ps = @m[:params].map {|p| render_single_param(p) }.join(", ")
70
+ "( <span class='pre'>#{ps}</span> )"
71
+ end
72
+
73
+ def render_single_param(param)
74
+ p = param[:html_type] + " " + param[:name]
75
+ param[:optional] ? "["+p+"]" : p
76
+ end
77
+
78
+ def render_return
79
+ method_with_return? ? (" : " + @m[:return][:html_type]) : ""
80
+ end
81
+
82
+ def method_with_return?
83
+ @m[:tagname] == :method && @m[:return][:type] != "undefined"
84
+ end
85
+
86
+ def render_meta
87
+ MetaTagRenderer.render_signature(@m)
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -11,6 +11,19 @@ module JsDuck::Tag
11
11
  @boolean = true
12
12
  end
13
13
 
14
+ # Initializes the tooltip text.
15
+ #
16
+ # HACK: This is a special method that's only called for the @new
17
+ # tag. It doesn't fit well into the current meta-tags system. But
18
+ # until we rework the meta-tags system, this will have to do.
19
+ def create_tooltip!(imports, new_since)
20
+ if new_since
21
+ @signature[:tooltip] = "New since #{new_since}"
22
+ elsif imports.length > 0
23
+ @signature[:tooltip] = "New since #{imports.last[:version]}"
24
+ end
25
+ end
26
+
14
27
  def to_value(contents)
15
28
  true
16
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsduck
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-09 00:00:00.000000000 Z
13
+ date: 2012-08-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdiscount
@@ -197,6 +197,7 @@ files:
197
197
  - lib/jsduck/meta_tag.rb
198
198
  - lib/jsduck/meta_tag_loader.rb
199
199
  - lib/jsduck/meta_tag_registry.rb
200
+ - lib/jsduck/meta_tag_renderer.rb
200
201
  - lib/jsduck/null_object.rb
201
202
  - lib/jsduck/option_parser.rb
202
203
  - lib/jsduck/options.rb
@@ -207,6 +208,7 @@ files:
207
208
  - lib/jsduck/renderer.rb
208
209
  - lib/jsduck/search_data.rb
209
210
  - lib/jsduck/serializer.rb
211
+ - lib/jsduck/signature_renderer.rb
210
212
  - lib/jsduck/source_file.rb
211
213
  - lib/jsduck/source_file_parser.rb
212
214
  - lib/jsduck/source_writer.rb