jsduck 5.0.0.beta2 → 5.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Rakefile +14 -4
  2. data/bin/jsduck +3 -1
  3. data/jsduck.gemspec +2 -2
  4. data/lib/jsduck/app.rb +8 -0
  5. data/lib/jsduck/assets.rb +3 -0
  6. data/lib/jsduck/batch_processor.rb +2 -0
  7. data/lib/jsduck/categories/class_name.rb +2 -26
  8. data/lib/jsduck/categories/factory.rb +5 -43
  9. data/lib/jsduck/columns.rb +56 -0
  10. data/lib/jsduck/doc/delimited_parser.rb +105 -0
  11. data/lib/jsduck/doc/scanner.rb +2 -1
  12. data/lib/jsduck/doc/standard_tag_parser.rb +37 -71
  13. data/lib/jsduck/guide_anchors.rb +32 -0
  14. data/lib/jsduck/guide_toc.rb +49 -0
  15. data/lib/jsduck/guides.rb +14 -32
  16. data/lib/jsduck/inline/video.rb +2 -8
  17. data/lib/jsduck/js/ast.rb +13 -305
  18. data/lib/jsduck/js/class.rb +245 -0
  19. data/lib/jsduck/js/event.rb +34 -0
  20. data/lib/jsduck/js/fires.rb +42 -0
  21. data/lib/jsduck/js/method.rb +94 -0
  22. data/lib/jsduck/js/method_calls.rb +40 -0
  23. data/lib/jsduck/js/node.rb +29 -0
  24. data/lib/jsduck/js/property.rb +64 -0
  25. data/lib/jsduck/js/{function.rb → returns.rb} +8 -3
  26. data/lib/jsduck/js/scoped_traverser.rb +42 -0
  27. data/lib/jsduck/logger.rb +13 -1
  28. data/lib/jsduck/merger.rb +34 -27
  29. data/lib/jsduck/news.rb +128 -0
  30. data/lib/jsduck/options.rb +59 -2
  31. data/lib/jsduck/params_merger.rb +47 -0
  32. data/lib/jsduck/process/accessors.rb +8 -2
  33. data/lib/jsduck/process/fires.rb +71 -0
  34. data/lib/jsduck/process/importer.rb +19 -1
  35. data/lib/jsduck/render/class.rb +11 -4
  36. data/lib/jsduck/render/signature_util.rb +14 -0
  37. data/lib/jsduck/tag/alias.rb +0 -20
  38. data/lib/jsduck/tag/alternate_class_names.rb +0 -5
  39. data/lib/jsduck/tag/cfg.rb +30 -5
  40. data/lib/jsduck/tag/class.rb +45 -2
  41. data/lib/jsduck/tag/css_mixin.rb +8 -4
  42. data/lib/jsduck/tag/css_var.rb +26 -5
  43. data/lib/jsduck/tag/default.rb +2 -8
  44. data/lib/jsduck/tag/enum.rb +7 -10
  45. data/lib/jsduck/tag/event.rb +12 -4
  46. data/lib/jsduck/tag/extends.rb +0 -6
  47. data/lib/jsduck/tag/fires.rb +53 -0
  48. data/lib/jsduck/tag/icons/cfg.png +0 -0
  49. data/lib/jsduck/tag/icons/css_mixin.png +0 -0
  50. data/lib/jsduck/tag/icons/css_var.png +0 -0
  51. data/lib/jsduck/tag/icons/event.png +0 -0
  52. data/lib/jsduck/tag/icons/method.png +0 -0
  53. data/lib/jsduck/tag/icons/property.png +0 -0
  54. data/lib/jsduck/tag/member_tag.rb +130 -0
  55. data/lib/jsduck/tag/method.rb +44 -4
  56. data/lib/jsduck/tag/param.rb +8 -60
  57. data/lib/jsduck/tag/property.rb +28 -5
  58. data/lib/jsduck/tag/tag.rb +3 -75
  59. data/lib/jsduck/tag/type.rb +1 -11
  60. data/lib/jsduck/tag_registry.rb +6 -48
  61. data/lib/jsduck/web/css.rb +8 -1
  62. data/lib/jsduck/web/data.rb +2 -1
  63. data/lib/jsduck/web/index_html.rb +1 -0
  64. data/lib/jsduck/web/member_icons.rb +43 -0
  65. data/lib/jsduck/web/search.rb +3 -2
  66. data/lib/jsduck/web/writer.rb +8 -0
  67. metadata +31 -27
  68. data/lib/jsduck/docs_code_comparer.rb +0 -44
  69. data/lib/jsduck/render/signature.rb +0 -94
  70. data/lib/jsduck/tag/autodetected.rb +0 -21
  71. data/lib/jsduck/tag/name.rb +0 -36
@@ -1,44 +0,0 @@
1
- require 'jsduck/util/singleton'
2
-
3
- module JsDuck
4
-
5
- # Compares documentation and code hashes.
6
- # Provides an utility method to help with merging.
7
- class DocsCodeComparer
8
- include Util::Singleton
9
-
10
- # Sets the value of a field in result hash based on its value in
11
- # docs and code hashes.
12
- #
13
- # - When docs has the key, gets value from there.
14
- #
15
- # - When code has the key and matches with docs, gets value from
16
- # there, and also remembers the fact that we're using
17
- # auto-detected value by recording it in :autodetected field.
18
- #
19
- def merge_if_matches(h, key, docs, code)
20
- if docs[key]
21
- h[key] = docs[key]
22
- elsif code[key] && matches?(docs, code)
23
- h[key] = code[key]
24
- mark_autodetected(h, key)
25
- else
26
- # nothing
27
- end
28
- end
29
-
30
- # True if the name detected from code matches with explicitly
31
- # documented name. Also true when no explicit name documented.
32
- def matches?(docs, code)
33
- return docs[:name] == nil || docs[:name] == code[:name]
34
- end
35
-
36
- # Stores the key as flag into h[:autodetcted]
37
- def mark_autodetected(h, key)
38
- h[:autodetected] = {} unless h[:autodetected]
39
- h[:autodetected][key] = true
40
- end
41
-
42
- end
43
-
44
- end
@@ -1,94 +0,0 @@
1
- require 'jsduck/render/tags'
2
- require 'jsduck/tag_registry'
3
-
4
- module JsDuck
5
- module Render
6
-
7
- # Performs the rendering of member signatures.
8
- class Signature
9
- # Initializes the renderer for rendering members of the given
10
- # class.
11
- def initialize(cls)
12
- @cls = cls
13
- end
14
-
15
- # Renders signature of the given member.
16
- def render(member)
17
- # Keep the code simpler by not passing around the member hash
18
- @m = member
19
-
20
- return [
21
- render_new,
22
- render_link,
23
- render_type,
24
- render_tag_signature,
25
- ]
26
- end
27
-
28
- private
29
-
30
- def render_new
31
- constructor? ? "<strong class='new-keyword'>new</strong>" : ""
32
- end
33
-
34
- def render_link
35
- "<a href='#{render_url}' class='name #{render_expandable}'>#{render_name}</a>"
36
- end
37
-
38
- def render_url
39
- "#!/api/#{@m[:owner]}-#{@m[:id]}"
40
- end
41
-
42
- def render_expandable
43
- @m[:short_doc] ? "expandable" : "not-expandable"
44
- end
45
-
46
- def render_name
47
- constructor? ? @cls[:name] : @m[:name]
48
- end
49
-
50
- def constructor?
51
- @m[:tagname] == :method && @m[:name] == "constructor"
52
- end
53
-
54
- def render_type
55
- if like_property?
56
- render_property_type
57
- else
58
- render_params + render_return
59
- end
60
- end
61
-
62
- def like_property?
63
- TagRegistry.member_type_names(:property_like).include?(@m[:tagname])
64
- end
65
-
66
- def render_property_type
67
- "<span> : #{@m[:html_type]}</span>"
68
- end
69
-
70
- def render_params
71
- ps = @m[:params].map {|p| render_single_param(p) }.join(", ")
72
- "( <span class='pre'>#{ps}</span> )"
73
- end
74
-
75
- def render_single_param(param)
76
- param[:optional] ? "["+param[:name]+"]" : param[:name]
77
- end
78
-
79
- def render_return
80
- method_with_return? ? (" : " + @m[:return][:html_type]) : ""
81
- end
82
-
83
- def method_with_return?
84
- @m[:tagname] == :method && @m[:return] != nil
85
- end
86
-
87
- def render_tag_signature
88
- Render::Tags.render_signature(@m)
89
- end
90
-
91
- end
92
-
93
- end
94
- end
@@ -1,21 +0,0 @@
1
- require "jsduck/tag/tag"
2
- require "jsduck/docs_code_comparer"
3
-
4
- module JsDuck::Tag
5
- # There is no @autodetected tag.
6
- #
7
- # This tag class exists to take care of the merging of :autodetected
8
- # field.
9
- class Autodetected < Tag
10
- def initialize
11
- @tagname = :autodetected
12
- @merge_context = [:class, :member]
13
- end
14
-
15
- def merge(h, docs, code)
16
- if docs[:autodetected] || code[:autodetected]
17
- h[:autodetected] = (code[:autodetected] || {}).merge(docs[:autodetected] || {})
18
- end
19
- end
20
- end
21
- end
@@ -1,36 +0,0 @@
1
- require "jsduck/tag/tag"
2
-
3
- module JsDuck::Tag
4
- # There is no @name tag.
5
- #
6
- # The :name field is generated by several tags like @class, @method,
7
- # @cfg, ...
8
- #
9
- # This class exists to take care of the merging of :name field.
10
- class Name < Tag
11
- def initialize
12
- @merge_context = [:class, :member]
13
- end
14
-
15
- # When docs contains :name, it's taken from there.
16
- #
17
- # When code contains :name, we only take the full name when
18
- # dealing with a class, otherwise we just take the last part of
19
- # the dot.separate.name.
20
- #
21
- # :name defaults to empty string.
22
- def merge(h, docs, code)
23
- if docs[:name]
24
- h[:name] = docs[:name]
25
- elsif code[:name]
26
- if h[:tagname] == :class
27
- h[:name] = code[:name]
28
- else
29
- h[:name] = code[:name].split(/\./).last
30
- end
31
- else
32
- h[:name] = ""
33
- end
34
- end
35
- end
36
- end