yard 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (68) hide show
  1. data/README.md +14 -2
  2. data/Rakefile +5 -10
  3. data/benchmarks/parsing.rb +2 -2
  4. data/docs/WhatsNew.md +43 -5
  5. data/lib/rubygems_plugin.rb +49 -45
  6. data/lib/yard.rb +1 -1
  7. data/lib/yard/cli/base.rb +4 -0
  8. data/lib/yard/cli/yard_graph.rb +1 -0
  9. data/lib/yard/cli/yardoc.rb +24 -2
  10. data/lib/yard/cli/yri.rb +1 -0
  11. data/lib/yard/code_objects/base.rb +9 -0
  12. data/lib/yard/code_objects/class_object.rb +1 -1
  13. data/lib/yard/code_objects/method_object.rb +20 -4
  14. data/lib/yard/core_ext/file.rb +6 -0
  15. data/lib/yard/core_ext/hash.rb +1 -1
  16. data/lib/yard/core_ext/string.rb +3 -1
  17. data/lib/yard/handlers/ruby/attribute_handler.rb +22 -18
  18. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +21 -17
  19. data/lib/yard/handlers/ruby/legacy/method_handler.rb +8 -0
  20. data/lib/yard/handlers/ruby/method_handler.rb +8 -1
  21. data/lib/yard/logging.rb +1 -1
  22. data/lib/yard/parser/c_parser.rb +10 -17
  23. data/lib/yard/parser/ruby/legacy/statement_list.rb +7 -0
  24. data/lib/yard/parser/ruby/ruby_parser.rb +2 -1
  25. data/lib/yard/parser/source_parser.rb +20 -3
  26. data/lib/yard/templates/helpers/html_helper.rb +48 -22
  27. data/lib/yard/templates/template.rb +6 -1
  28. data/spec/cli/yardoc_spec.rb +22 -0
  29. data/spec/code_objects/base_spec.rb +34 -1
  30. data/spec/code_objects/method_object_spec.rb +35 -0
  31. data/spec/core_ext/hash_spec.rb +4 -0
  32. data/spec/core_ext/string_spec.rb +5 -1
  33. data/spec/handlers/attribute_handler_spec.rb +9 -1
  34. data/spec/handlers/examples/attribute_handler_001.rb.txt +8 -0
  35. data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
  36. data/spec/handlers/method_handler_spec.rb +10 -0
  37. data/spec/parser/source_parser_spec.rb +29 -26
  38. data/spec/spec_helper.rb +1 -1
  39. data/spec/templates/engine_spec.rb +1 -0
  40. data/spec/templates/examples/class001.html +4 -0
  41. data/spec/templates/examples/class001.txt +5 -0
  42. data/spec/templates/examples/module001.dot +1 -1
  43. data/spec/templates/examples/module001.html +92 -12
  44. data/spec/templates/helpers/html_helper_spec.rb +25 -5
  45. data/spec/templates/module_spec.rb +3 -1
  46. data/spec/templates/template_spec.rb +11 -1
  47. data/templates/default/class/html/subclasses.erb +1 -1
  48. data/templates/default/class/setup.rb +10 -3
  49. data/templates/default/class/text/subclasses.erb +1 -1
  50. data/templates/default/fulldoc/html/css/full_list.css +38 -11
  51. data/templates/default/fulldoc/html/css/style.css +6 -1
  52. data/templates/default/fulldoc/html/frames.erb +13 -0
  53. data/templates/default/fulldoc/html/full_list.erb +20 -22
  54. data/templates/default/fulldoc/html/full_list_class.erb +2 -0
  55. data/templates/default/fulldoc/html/full_list_files.erb +5 -0
  56. data/templates/default/fulldoc/html/full_list_methods.erb +12 -0
  57. data/templates/default/fulldoc/html/js/app.js +10 -2
  58. data/templates/default/fulldoc/html/js/full_list.js +76 -9
  59. data/templates/default/fulldoc/html/setup.rb +37 -2
  60. data/templates/default/layout/html/breadcrumb.erb +3 -1
  61. data/templates/default/layout/html/layout.erb +4 -0
  62. data/templates/default/layout/html/search.erb +1 -1
  63. data/templates/default/layout/html/setup.rb +13 -2
  64. data/templates/default/module/dot/info.erb +1 -1
  65. data/templates/default/module/html/attribute_details.erb +1 -1
  66. data/templates/default/module/html/constant_summary.erb +1 -1
  67. data/templates/default/module/html/item_summary.erb +2 -2
  68. metadata +6 -2
@@ -69,6 +69,7 @@ def generate_assets
69
69
  generate_method_list
70
70
  generate_class_list
71
71
  generate_file_list
72
+ generate_frameset
72
73
  end
73
74
 
74
75
  def generate_method_list
@@ -76,12 +77,13 @@ def generate_method_list
76
77
  @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
77
78
  @items = @items.sort_by {|m| m.name.to_s }
78
79
  @list_title = "Method List"
80
+ @list_type = "methods"
79
81
  asset('method_list.html', erb(:full_list))
80
82
  end
81
83
 
82
84
  def generate_class_list
83
- @items = [Registry.root] + options[:objects].reject {|o| o.type == :root }.sort_by {|m| m.name.to_s }
84
- @list_title = "Namespace List"
85
+ @list_title = "Class List"
86
+ @list_type = "class"
85
87
  asset('class_list.html', erb(:full_list))
86
88
  end
87
89
 
@@ -89,6 +91,39 @@ def generate_file_list
89
91
  @file_list = true
90
92
  @items = options[:files]
91
93
  @list_title = "File List"
94
+ @list_type = "files"
92
95
  asset('file_list.html', erb(:full_list))
93
96
  @file_list = nil
97
+ end
98
+
99
+ def generate_frameset
100
+ asset('frames.html', erb(:frames))
101
+ end
102
+
103
+ def class_list(root = Registry.root)
104
+ out = ""
105
+ children = run_verifier(root.children)
106
+ if root == Registry.root
107
+ children += Registry.all(:class, :module).select {|o| o.namespace.is_a?(CodeObjects::Proxy) }
108
+ end
109
+ children.sort_by {|child| child.path }.map do |child|
110
+ if child.is_a?(CodeObjects::NamespaceObject)
111
+ name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
112
+ has_children = child.children.any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
113
+ out << "<li>"
114
+ out << "<a class='toggle'></a> " if has_children
115
+ out << linkify(child, name)
116
+ out << " &lt; #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass
117
+ out << "<small class='search_info'>"
118
+ if !child.namespace || child.namespace.root?
119
+ out << "Top Level Namespace"
120
+ else
121
+ out << child.namespace.path
122
+ end
123
+ out << "</small>"
124
+ out << "</li>"
125
+ out << "<ul>#{class_list(child)}</ul>" if has_children
126
+ end
127
+ end
128
+ out
94
129
  end
@@ -1,11 +1,13 @@
1
1
  <div id="menu">
2
2
  <% if object.is_a?(CodeObjects::Base) && @file.nil? %>
3
3
  <a href="<%= url_for('_index.html') %>"><% if object.root? || object.type == :method %>Index<% else %>Index (<%= object.name.to_s[0,1] %>)<% end %></a> &raquo;
4
- <%= @breadcrumb.map {|obj| linkify obj, obj.name }.join(" &raquo; ") %>
4
+ <%= @breadcrumb.map {|obj| "<span class='title'>" + linkify(obj, obj.name) + "</span>" }.join(" &raquo; ") %>
5
5
  <%= @breadcrumb.size > 0 ? " &raquo; " : "" %>
6
6
  <span class="title"><%= object.root? ? "Top Level Namespace" : object.name(true) %></span>
7
7
  <% else %>
8
8
  <% if object != '_index.html' %><%= link_url('_index.html', 'Index') %> &raquo; <% end %>
9
9
  <span class="title"><%= @breadcrumb_title %></span>
10
10
  <% end %>
11
+
12
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
11
13
  </div>
@@ -5,6 +5,10 @@
5
5
  <%= erb(:headers) %>
6
6
  </head>
7
7
  <body>
8
+ <script type="text/javascript" charset="utf-8">
9
+ if (window.top.frames.main) document.body.className = 'frames';
10
+ </script>
11
+
8
12
  <div id="header">
9
13
  <%= erb(:breadcrumb) %>
10
14
  <%= erb(:search) %>
@@ -1,5 +1,5 @@
1
1
  <div id="search">
2
- <a id="class_list_link" href="#">Namespace List</a>
2
+ <a id="class_list_link" href="#">Class List</a>
3
3
  <a id="method_list_link" href="#">Method List</a>
4
4
  <a id ="file_list_link" href="#">File List</a>
5
5
  </div>
@@ -2,7 +2,7 @@ def init
2
2
  @breadcrumb = []
3
3
 
4
4
  if @file
5
- @contents = IO.read(@file)
5
+ @contents = File.read_binary(@file)
6
6
  @file = File.basename(@file)
7
7
  @fname = @file.gsub(/\.[^.]+$/, '')
8
8
  @breadcrumb_title = "File: " + @fname
@@ -45,6 +45,8 @@ end
45
45
  def diskfile
46
46
  "<div id='filecontents'>" +
47
47
  case (File.extname(@file)[1..-1] || '').downcase
48
+ when 'htm', 'html'
49
+ @contents
48
50
  when 'txt'
49
51
  "<pre>#{@contents}</pre>"
50
52
  when 'textile', 'txtile'
@@ -52,7 +54,16 @@ def diskfile
52
54
  when 'markdown', 'md', 'mdown'
53
55
  htmlify(@contents, :markdown)
54
56
  else
55
- htmlify(@contents, :rdoc)
57
+ htmlify(@contents, diskfile_shebang_or_default)
56
58
  end +
57
59
  "</div>"
60
+ end
61
+
62
+ def diskfile_shebang_or_default
63
+ if @contents =~ /\A#!(\S+)\s*$/ # Shebang support
64
+ @contents = $'
65
+ $1.to_sym
66
+ else
67
+ options[:markup]
68
+ end
58
69
  end
@@ -3,7 +3,7 @@
3
3
  |
4
4
  <% object.attributes.each do |scope, list| %>
5
5
  <% list.sort_by {|name, rw| name.to_s }.each do |name, rw| %>
6
- <%= uml_visibility(rw.values.compact.first) %> <%= h (rw[:read]||rw[:write]).name(true) %> [<%= 'R' if rw[:read] %><%= 'W' if rw[:write] %>]\l
6
+ <%= uml_visibility(rw.values.compact.first) %> <%= h (rw[:read]||rw[:write]).name(true).gsub(/=$/,'') %> [<%= 'R' if rw[:read] %><%= 'W' if rw[:write] %>]\l
7
7
  <% end %>
8
8
  <% end %>
9
9
  |
@@ -2,7 +2,7 @@
2
2
  <div id="<%= scope %>_attr_details" class="attr_details">
3
3
  <h2><%= scope.to_s.capitalize %> Attribute Details</h2>
4
4
  <% list.each_with_index do |meth, i| %>
5
- <% rw = meth.namespace.attributes[meth.scope][meth.name.to_s.gsub(/=$/, '').to_sym] %>
5
+ <% rw = meth.attr_info %>
6
6
  <span id="<%= anchor_for(rw[:write]) %>"></span>
7
7
  <span id="<%= anchor_for(rw[:read]) %>"></span>
8
8
  <%= yieldall :object => meth, :index => i %>
@@ -3,7 +3,7 @@
3
3
  <% if constant_listing.size > 0 %>
4
4
  <dl class="constants">
5
5
  <% constant_listing.each do |cnst| %>
6
- <dt id="<%= anchor_for(cnst) %> <%= cnst.has_tag?(:deprecated) ? 'deprecated' : '' %>"><%= cnst.name %> =
6
+ <dt id="<%= anchor_for(cnst) %>" class="<%= cnst.has_tag?(:deprecated) ? 'deprecated' : '' %>"><%= cnst.name %> =
7
7
  <span class="summary_desc"><%= htmlify_line docstring_summary(cnst) %></span>
8
8
  </dt>
9
9
  <dd><pre class="code"><%= format_constant cnst.value %></pre></dd>
@@ -3,7 +3,7 @@
3
3
  <% if @item.tags(:overload).size == 1 %>
4
4
  <%= signature(@item.tag(:overload), true, false) %>
5
5
  <% else %>
6
- <%= signature(@item, true, false) %>
6
+ <%= signature(@item, true, false, false) %>
7
7
  <% end %>
8
8
 
9
9
  <% if @item.aliases.size > 0 %>
@@ -13,7 +13,7 @@
13
13
  <% if @item.constructor? %>
14
14
  <span class="note title constructor">constructor</span>
15
15
  <% end %>
16
- <% if rw = @item.namespace.attributes[@item.scope][@item.name] %>
16
+ <% if rw = @item.attr_info %>
17
17
  <% if rw[:read] && !rw[:write] %><span class="note title readonly">readonly</span><% end %>
18
18
  <% if rw[:write] && !rw[:read] %><span class="note title writeonly">writeonly</span><% end %>
19
19
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 -05:00
12
+ date: 2010-01-11 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -268,7 +268,11 @@ files:
268
268
  - templates/default/fulldoc/html/css/common.css
269
269
  - templates/default/fulldoc/html/css/full_list.css
270
270
  - templates/default/fulldoc/html/css/style.css
271
+ - templates/default/fulldoc/html/frames.erb
271
272
  - templates/default/fulldoc/html/full_list.erb
273
+ - templates/default/fulldoc/html/full_list_class.erb
274
+ - templates/default/fulldoc/html/full_list_files.erb
275
+ - templates/default/fulldoc/html/full_list_methods.erb
272
276
  - templates/default/fulldoc/html/js/app.js
273
277
  - templates/default/fulldoc/html/js/full_list.js
274
278
  - templates/default/fulldoc/html/js/jquery.js