yard 0.4.0 → 0.5.0

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 (121) hide show
  1. data/ChangeLog +585 -1
  2. data/README.md +10 -2
  3. data/benchmarks/yri_cache.rb +19 -0
  4. data/bin/yri +1 -26
  5. data/docs/WhatsNew.md +99 -0
  6. data/lib/rubygems_plugin.rb +2 -0
  7. data/lib/yard.rb +2 -2
  8. data/lib/yard/autoload.rb +9 -4
  9. data/lib/yard/cli/base.rb +26 -0
  10. data/lib/yard/cli/yard_graph.rb +2 -9
  11. data/lib/yard/cli/yardoc.rb +93 -33
  12. data/lib/yard/cli/yri.rb +128 -0
  13. data/lib/yard/code_objects/base.rb +16 -5
  14. data/lib/yard/code_objects/class_object.rb +11 -4
  15. data/lib/yard/code_objects/method_object.rb +11 -1
  16. data/lib/yard/code_objects/proxy.rb +5 -2
  17. data/lib/yard/code_objects/root_object.rb +1 -0
  18. data/lib/yard/core_ext/file.rb +1 -1
  19. data/lib/yard/core_ext/hash.rb +15 -0
  20. data/lib/yard/core_ext/module.rb +2 -2
  21. data/lib/yard/core_ext/string.rb +66 -0
  22. data/lib/yard/core_ext/symbol_hash.rb +1 -1
  23. data/lib/yard/docstring.rb +5 -5
  24. data/lib/yard/handlers/base.rb +10 -4
  25. data/lib/yard/handlers/processor.rb +3 -4
  26. data/lib/yard/handlers/ruby/attribute_handler.rb +3 -2
  27. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +2 -2
  28. data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -1
  29. data/lib/yard/handlers/ruby/method_handler.rb +7 -1
  30. data/lib/yard/logging.rb +11 -1
  31. data/lib/yard/parser/c_parser.rb +407 -0
  32. data/lib/yard/parser/ruby/ast_node.rb +2 -2
  33. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +3 -4
  34. data/lib/yard/parser/source_parser.rb +18 -7
  35. data/lib/yard/rake/yardoc_task.rb +1 -1
  36. data/lib/yard/registry.rb +83 -29
  37. data/lib/yard/registry_store.rb +213 -0
  38. data/lib/yard/serializers/base.rb +1 -1
  39. data/lib/yard/serializers/yardoc_serializer.rb +113 -0
  40. data/lib/yard/tags/library.rb +4 -0
  41. data/lib/yard/tags/overload_tag.rb +16 -5
  42. data/lib/yard/tags/tag.rb +1 -2
  43. data/lib/yard/templates/engine.rb +3 -3
  44. data/lib/yard/templates/helpers/html_helper.rb +50 -16
  45. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +1 -3
  46. data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +1 -3
  47. data/lib/yard/templates/helpers/method_helper.rb +11 -4
  48. data/lib/yard/templates/helpers/text_helper.rb +24 -2
  49. data/lib/yard/verifier.rb +3 -3
  50. data/spec/cli/yardoc_spec.rb +33 -6
  51. data/spec/cli/yri_spec.rb +30 -0
  52. data/spec/code_objects/base_spec.rb +7 -0
  53. data/spec/code_objects/class_object_spec.rb +6 -1
  54. data/spec/code_objects/method_object_spec.rb +25 -0
  55. data/spec/core_ext/hash_spec.rb +10 -0
  56. data/spec/core_ext/module_spec.rb +1 -1
  57. data/spec/core_ext/string_spec.rb +50 -12
  58. data/spec/handlers/attribute_handler_spec.rb +4 -0
  59. data/spec/handlers/examples/method_handler_001.rb.txt +9 -0
  60. data/spec/handlers/method_handler_spec.rb +22 -4
  61. data/spec/parser/c_parser_spec.rb +22 -0
  62. data/spec/parser/examples/array.c.txt +3887 -0
  63. data/spec/parser/source_parser_spec.rb +29 -7
  64. data/spec/registry_spec.rb +93 -72
  65. data/spec/registry_store_spec.rb +184 -0
  66. data/spec/serializers/file_system_serializer_spec.rb +96 -75
  67. data/spec/spec_helper.rb +2 -2
  68. data/spec/tags/overload_tag_spec.rb +18 -0
  69. data/spec/templates/examples/class001.html +32 -30
  70. data/spec/templates/examples/method001.html +4 -1
  71. data/spec/templates/examples/method002.html +7 -2
  72. data/spec/templates/examples/method002.txt +1 -1
  73. data/spec/templates/examples/method003.html +30 -8
  74. data/spec/templates/examples/method003.txt +4 -4
  75. data/spec/templates/examples/method004.html +44 -0
  76. data/spec/templates/examples/method004.txt +10 -0
  77. data/spec/templates/examples/method005.html +99 -0
  78. data/spec/templates/examples/method005.txt +33 -0
  79. data/spec/templates/examples/module001.dot +1 -1
  80. data/spec/templates/examples/module001.html +391 -37
  81. data/spec/templates/examples/module001.txt +1 -1
  82. data/spec/templates/helpers/base_helper_spec.rb +2 -2
  83. data/spec/templates/helpers/html_helper_spec.rb +83 -0
  84. data/spec/templates/helpers/method_helper_spec.rb +47 -0
  85. data/spec/templates/helpers/shared_signature_examples.rb +102 -0
  86. data/spec/templates/helpers/text_helper_spec.rb +31 -0
  87. data/spec/templates/method_spec.rb +43 -18
  88. data/spec/templates/module_spec.rb +22 -1
  89. data/spec/templates/spec_helper.rb +10 -1
  90. data/spec/yard_spec.rb +4 -3
  91. data/templates/default/class/html/constructor_details.erb +1 -1
  92. data/templates/default/docstring/html/returns_void.erb +1 -0
  93. data/templates/default/docstring/setup.rb +9 -4
  94. data/templates/default/docstring/text/returns_void.erb +1 -0
  95. data/templates/default/fulldoc/html/css/style.css +4 -2
  96. data/templates/default/fulldoc/html/full_list.erb +2 -2
  97. data/templates/default/fulldoc/html/js/app.js +1 -1
  98. data/templates/default/fulldoc/html/setup.rb +14 -6
  99. data/templates/default/layout/dot/setup.rb +1 -1
  100. data/templates/default/layout/html/breadcrumb.erb +2 -2
  101. data/templates/default/layout/html/index.erb +2 -2
  102. data/templates/default/layout/html/setup.rb +5 -5
  103. data/templates/default/method/html/header.erb +6 -4
  104. data/templates/default/method_details/html/method_signature.erb +2 -1
  105. data/templates/default/method_details/html/source.erb +1 -1
  106. data/templates/default/method_details/setup.rb +2 -1
  107. data/templates/default/method_details/text/setup.rb +1 -1
  108. data/templates/default/module/html/attribute_details.erb +4 -4
  109. data/templates/default/module/html/attribute_summary.erb +3 -3
  110. data/templates/default/module/html/box_info.erb +2 -2
  111. data/templates/default/module/html/defines.erb +1 -1
  112. data/templates/default/module/html/inherited_constants.erb +1 -1
  113. data/templates/default/module/html/inherited_methods.erb +1 -1
  114. data/templates/default/module/html/item_summary.erb +13 -4
  115. data/templates/default/module/html/method_details_list.erb +5 -4
  116. data/templates/default/module/html/method_summary.erb +5 -4
  117. data/templates/default/module/html/methodmissing.erb +1 -1
  118. data/templates/default/module/setup.rb +14 -5
  119. data/templates/default/tags/html/overload.erb +3 -2
  120. data/templates/default/tags/setup.rb +4 -0
  121. metadata +23 -2
data/spec/spec_helper.rb CHANGED
@@ -3,9 +3,9 @@ require "spec"
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'yard'))
5
5
 
6
- def parse_file(file, thisfile = __FILE__, log_level = log.level)
6
+ def parse_file(file, thisfile = __FILE__, log_level = log.level, ext = '.rb.txt')
7
7
  Registry.clear
8
- path = File.join(File.dirname(thisfile), 'examples', file.to_s + '.rb.txt')
8
+ path = File.join(File.dirname(thisfile), 'examples', file.to_s + ext)
9
9
  YARD::Parser::SourceParser.parse(path, log_level)
10
10
  end
11
11
 
@@ -32,4 +32,22 @@ describe YARD::Tags::OverloadTag do
32
32
  @tag.tag(:param).name.should == "a"
33
33
  @tag.has_tag?(:return).should == true
34
34
  end
35
+
36
+ it "should not be a CodeObjects::Base when not hooked up to an object" do
37
+ @tag.object = nil
38
+ @tag.is_a?(CodeObjects::Base).should == false
39
+ end
40
+
41
+ it "should be a CodeObjects::Base when hooked up to an object" do
42
+ @tag.object = mock(:object)
43
+ @tag.object.should_receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
44
+ @tag.is_a?(CodeObjects::Base).should == true
45
+ @tag.kind_of?(CodeObjects::Base).should == true
46
+ (CodeObjects::Base === @tag).should == true
47
+ end
48
+
49
+ it "should not parse 'def' out of method name" do
50
+ tag = Tags::OverloadTag.new(:overload, nil, "default")
51
+ tag.signature.should == "default"
52
+ end
35
53
  end
@@ -87,16 +87,22 @@ Comments
87
87
 
88
88
 
89
89
 
90
- <h2>Method Summary</h2>
90
+ <h2>Instance Method Summary</h2>
91
+
91
92
  <ul class="summary">
92
93
 
93
94
  <li class="public deprecated">
94
- <span class="summary_signature"><a title="#a (instance method)">- (Object) <strong>a</strong> </a>
95
-
95
+ <span class="summary_signature">
96
+
97
+ <a title="#a (instance method)">- <strong>a</strong> </a>
98
+
99
+
100
+
96
101
  </span>
97
102
 
98
103
 
99
104
 
105
+
100
106
  <span class="deprecated note title">Deprecated</span>
101
107
 
102
108
 
@@ -106,10 +112,17 @@ Comments
106
112
 
107
113
 
108
114
  <li class="public ">
109
- <span class="summary_signature"><a title="#initialize (instance method)">- (A) <strong>initialize</strong>(test) </a>
110
-
115
+ <span class="summary_signature">
116
+
117
+ <a title="#initialize (instance method)">- (A) <strong>initialize</strong>(test) </a>
118
+
119
+
120
+
111
121
  </span>
112
122
 
123
+ <span class="note title constructor">constructor</span>
124
+
125
+
113
126
 
114
127
 
115
128
 
@@ -121,13 +134,18 @@ Comments
121
134
 
122
135
 
123
136
  <li class="public ">
124
- <span class="summary_signature"><a title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(*args) </a>
125
-
137
+ <span class="summary_signature">
138
+
139
+ <a title="#method_missing (instance method)">- <strong>method_missing</strong>(*args) </a>
140
+
141
+
142
+
126
143
  </span>
127
144
 
128
145
 
129
146
 
130
147
 
148
+
131
149
 
132
150
 
133
151
  <span class="summary_desc">HI.</span>
@@ -137,8 +155,7 @@ Comments
137
155
 
138
156
  </ul>
139
157
 
140
-
141
- <div id="constructor_details">
158
+ <div id="constructor_details" class="method_details_list">
142
159
  <h2>Constructor Details</h2>
143
160
 
144
161
  <div class="method_details first">
@@ -155,23 +172,7 @@ Comments
155
172
  </div>
156
173
  </div>
157
174
  <div class="tags">
158
- <h3>Returns:</h3>
159
- <ul class="return">
160
-
161
- <li>
162
-
163
- <span class='type'>(<tt>A</tt>)</span>
164
-
165
-
166
-
167
-
168
- &mdash;
169
- a new instance of +A+
170
-
171
- </li>
172
175
 
173
- </ul>
174
-
175
176
  </div><table class="source_code">
176
177
  <tr>
177
178
  <td>
@@ -190,7 +191,7 @@ def initialize(test) end</pre>
190
191
  </div>
191
192
 
192
193
  </div>
193
- <div id="method_missing_details">
194
+ <div id="method_missing_details" class="method_details_list">
194
195
  <h2>Dynamic Method Handling</h2>
195
196
  <p class="notice this">
196
197
  This class handles dynamic methods through the <tt>method_missing</tt> method
@@ -200,7 +201,7 @@ def initialize(test) end</pre>
200
201
  <div class="method_details first">
201
202
  <p class="signature first" id="method_missing-instance_method">
202
203
 
203
- - (<tt>Object</tt>) <strong>method_missing</strong>(*args)
204
+ - <strong>method_missing</strong>(*args)
204
205
 
205
206
 
206
207
 
@@ -232,13 +233,14 @@ def method_missing(*args) end</pre>
232
233
  </div>
233
234
 
234
235
 
235
- <div id="method_details">
236
- <h2>Method Details</h2>
236
+ <div id="instance_method_details" class="method_details_list">
237
+ <h2>Instance Method Details</h2>
238
+
237
239
 
238
240
  <div class="method_details first">
239
241
  <p class="signature first" id="a-instance_method">
240
242
 
241
- - (<tt>Object</tt>) <strong>a</strong>
243
+ - <strong>a</strong>
242
244
 
243
245
 
244
246
 
@@ -7,6 +7,7 @@
7
7
  </dl>
8
8
  <div class="clear"></div>
9
9
 
10
+ <div class="method_details_list">
10
11
  <div id="method_details">
11
12
  <div class="method_details first">
12
13
  <p class="signature first" id="m-instance_method">
@@ -16,13 +17,14 @@
16
17
 
17
18
 
18
19
  <span class="aliases">Also known as:
19
- <span class="names">x</span>
20
+ <span class="names"><span id='x-instance_method'>x</span></span>
20
21
  </span>
21
22
 
22
23
  </p><div class="docstring">
23
24
  <div class="discussion">
24
25
  <p class="note deprecated"><strong>Deprecated.</strong> for great justice</p>
25
26
  Comments
27
+
26
28
  </div>
27
29
  </div>
28
30
  <div class="tags">
@@ -94,3 +96,4 @@ def m(x) end</pre>
94
96
  </table>
95
97
  </div>
96
98
  </div>
99
+ </div>
@@ -7,23 +7,27 @@
7
7
  </dl>
8
8
  <div class="clear"></div>
9
9
 
10
+ <div class="method_details_list">
10
11
  <div id="method_details">
11
12
  <div class="method_details first">
12
13
  <p class="signature first" id="m-instance_method">
13
14
 
14
- - (<tt>Object</tt>) <strong>m</strong>(x, y) <span class="extras">(private)</span>
15
+ - <strong>m</strong>(x, y) <span class="extras">(private)</span>
15
16
 
16
17
 
17
18
 
18
19
  </p><div class="docstring">
19
20
  <div class="discussion">
20
21
  Comments
22
+
21
23
  </div>
22
24
  </div>
23
25
  <div class="tags">
24
- <div class="docstring">
26
+
27
+ <div class="docstring">
25
28
  <div class="discussion">
26
29
 
30
+
27
31
  </div>
28
32
  </div>
29
33
  <div class="tags">
@@ -79,3 +83,4 @@ def m(x) end</pre>
79
83
  </table>
80
84
  </div>
81
85
  </div>
86
+ </div>
@@ -1,7 +1,7 @@
1
1
  ------------------------------------------------------------- Method: #m
2
2
  (Defined in: (stdin))
3
3
 
4
- root.m(x, y) -> Object (private)
4
+ root.m(x, y) (private)
5
5
  ------------------------------------------------------------------------
6
6
 
7
7
  Comments
@@ -7,14 +7,15 @@
7
7
  </dl>
8
8
  <div class="clear"></div>
9
9
 
10
- <div id="method_details">
11
- <div class="method_details first">
10
+ <div class="method_details_list">
11
+ <div id="method_details">
12
+ <div class="method_details first">
12
13
  <p class="signature first" id="m-instance_method">
13
14
 
14
15
 
15
- <span class="overload">- (<tt>Object</tt>) <strong>m</strong>(x, y) <span class="extras">(private)</span></span>
16
+ <span class="overload">- <strong>m</strong>(x, y) <span class="extras">(private)</span></span>
16
17
 
17
- <span class="overload">- (<tt>Object</tt>) <strong>m</strong>(x, y, z) <span class="extras">(private)</span></span>
18
+ <span class="overload">- <strong>m</strong>(x, y, z) <span class="extras">(private)</span></span>
18
19
 
19
20
 
20
21
 
@@ -22,17 +23,21 @@
22
23
  </p><div class="docstring">
23
24
  <div class="discussion">
24
25
  Method comments
26
+
25
27
  </div>
26
28
  </div>
27
29
  <div class="tags">
28
- <h3>Overloads:</h3>
30
+
31
+ <h3>Overloads:</h3>
29
32
  <ul class="overload">
30
33
 
34
+
31
35
  <li class="overload_item">
32
- <span class="signature">- (<tt>Object</tt>) <strong>m</strong>(x, y) <span class="extras">(private)</span></span>
36
+ <span class="signature">- <strong>m</strong>(x, y) </span>
33
37
  <div class="docstring">
34
38
  <div class="discussion">
35
39
  Overload docstring
40
+
36
41
  </div>
37
42
  </div>
38
43
  <div class="tags">
@@ -72,11 +77,13 @@
72
77
  </div>
73
78
  </li>
74
79
 
80
+
75
81
  <li class="overload_item">
76
- <span class="signature">- (<tt>Object</tt>) <strong>m</strong>(x, y, z) <span class="extras">(private)</span></span>
82
+ <span class="signature">- <strong>m</strong>(x, y, z) </span>
77
83
  <div class="docstring">
78
84
  <div class="discussion">
79
85
 
86
+
80
87
  </div>
81
88
  </div>
82
89
  <div class="tags">
@@ -132,6 +139,21 @@
132
139
 
133
140
  </ul>
134
141
 
142
+ </div><table class="source_code">
143
+ <tr>
144
+ <td>
145
+ <pre class="lines">
146
+
147
+
148
+ 11</pre>
149
+ </td>
150
+ <td>
151
+ <pre class="code"><span class="info file"># File '(stdin)', line 11</span>
152
+
153
+ def m(*args) end</pre>
154
+ </td>
155
+ </tr>
156
+ </table>
135
157
  </div>
136
- </div>
158
+ </div>
137
159
  </div>
@@ -1,8 +1,8 @@
1
1
  ------------------------------------------------------------- Method: #m
2
2
  (Defined in: (stdin))
3
3
 
4
- root.m(x, y) -> Object (private)
5
- root.m(x, y, z) -> Object (private)
4
+ root.m(x, y) (private)
5
+ root.m(x, y, z) (private)
6
6
  ------------------------------------------------------------------------
7
7
 
8
8
  Method comments
@@ -11,7 +11,7 @@ Overloads:
11
11
  ----------
12
12
 
13
13
  ------------------------------------------------------------------------
14
- root.m(x, y) -> Object (private)
14
+ root.m(x, y) (private)
15
15
  ------------------------------------------------------------------------
16
16
 
17
17
  Overload docstring
@@ -26,7 +26,7 @@ Overloads:
26
26
 
27
27
 
28
28
  ------------------------------------------------------------------------
29
- root.m(x, y, z) -> Object (private)
29
+ root.m(x, y, z) (private)
30
30
  ------------------------------------------------------------------------
31
31
 
32
32
 
@@ -0,0 +1,44 @@
1
+ <h1>Method: #m</h1>
2
+ <dl class="box">
3
+ <dt class="r1 last">Defined in:</dt>
4
+ <dd class="r1 last">
5
+ (stdin)
6
+ </dd>
7
+ </dl>
8
+ <div class="clear"></div>
9
+
10
+ <div class="method_details_list">
11
+ <div id="method_details">
12
+ <div class="method_details first">
13
+ <p class="signature first" id="m-instance_method">
14
+
15
+ - (<tt>void</tt>) <strong>m</strong>(*args)
16
+
17
+
18
+
19
+ </p><div class="docstring">
20
+ <div class="discussion">
21
+ <p class="note returns_void">This method returns an undefined value.</p>
22
+
23
+ </div>
24
+ </div>
25
+ <div class="tags">
26
+
27
+ </div><table class="source_code">
28
+ <tr>
29
+ <td>
30
+ <pre class="lines">
31
+
32
+
33
+ 2</pre>
34
+ </td>
35
+ <td>
36
+ <pre class="code"><span class="info file"># File '(stdin)', line 2</span>
37
+
38
+ def m(*args) end</pre>
39
+ </td>
40
+ </tr>
41
+ </table>
42
+ </div>
43
+ </div>
44
+ </div>
@@ -0,0 +1,10 @@
1
+ ------------------------------------------------------------- Method: #m
2
+ (Defined in: (stdin))
3
+
4
+ root.m(*args) -> void
5
+ ------------------------------------------------------------------------
6
+
7
+ This method returns an undefined value.
8
+
9
+
10
+
@@ -0,0 +1,99 @@
1
+ <h1>Method: #m</h1>
2
+ <dl class="box">
3
+ <dt class="r1 last">Defined in:</dt>
4
+ <dd class="r1 last">
5
+ (stdin)
6
+ </dd>
7
+ </dl>
8
+ <div class="clear"></div>
9
+
10
+ <div class="method_details_list">
11
+ <div id="method_details">
12
+ <div class="method_details first">
13
+ <p class="signature first" id="m-instance_method">
14
+
15
+
16
+ <span class="overload">- (<tt>void</tt>) <strong>m</strong>(a) </span>
17
+
18
+ <span class="overload">- <strong>m</strong>(b) </span>
19
+
20
+
21
+
22
+
23
+ </p><div class="docstring">
24
+ <div class="discussion">
25
+
26
+
27
+ </div>
28
+ </div>
29
+ <div class="tags">
30
+
31
+ <h3>Overloads:</h3>
32
+ <ul class="overload">
33
+
34
+
35
+ <li class="overload_item">
36
+ <span class="signature">- (<tt>void</tt>) <strong>m</strong>(a) </span>
37
+ <div class="docstring">
38
+ <div class="discussion">
39
+ <p class="note returns_void">This method returns an undefined value.</p>
40
+
41
+ </div>
42
+ </div>
43
+ <div class="tags">
44
+
45
+ </div>
46
+ </li>
47
+
48
+
49
+ <li class="overload_item">
50
+ <span class="signature">- <strong>m</strong>(b) </span>
51
+ <div class="docstring">
52
+ <div class="discussion">
53
+
54
+
55
+ </div>
56
+ </div>
57
+ <div class="tags">
58
+ <h3>Parameters:</h3>
59
+ <ul class="param">
60
+
61
+ <li>
62
+
63
+ <span class='type'>(<tt>String</tt>)</span>
64
+
65
+
66
+ <span class='name'>b</span>
67
+
68
+
69
+
70
+ &mdash;
71
+ hi
72
+
73
+ </li>
74
+
75
+ </ul>
76
+
77
+ </div>
78
+ </li>
79
+
80
+ </ul>
81
+
82
+ </div><table class="source_code">
83
+ <tr>
84
+ <td>
85
+ <pre class="lines">
86
+
87
+
88
+ 5</pre>
89
+ </td>
90
+ <td>
91
+ <pre class="code"><span class="info file"># File '(stdin)', line 5</span>
92
+
93
+ def m(*args) end</pre>
94
+ </td>
95
+ </tr>
96
+ </table>
97
+ </div>
98
+ </div>
99
+ </div>