yard 0.8.7.6 → 0.9.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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/LICENSE +2 -2
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/bin/yard +0 -0
  7. data/bin/yardoc +0 -0
  8. data/bin/yri +0 -0
  9. data/docs/GettingStarted.md +88 -6
  10. data/docs/images/handlers-class-diagram.png +0 -0
  11. data/docs/images/overview-class-diagram.png +0 -0
  12. data/docs/images/parser-class-diagram.png +0 -0
  13. data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
  14. data/lib/yard/autoload.rb +3 -0
  15. data/lib/yard/cli/yardoc.rb +1 -1
  16. data/lib/yard/code_objects/base.rb +4 -1
  17. data/lib/yard/code_objects/extra_file_object.rb +3 -1
  18. data/lib/yard/code_objects/proxy.rb +2 -2
  19. data/lib/yard/docstring.rb +11 -6
  20. data/lib/yard/handlers/base.rb +1 -2
  21. data/lib/yard/handlers/c/base.rb +19 -0
  22. data/lib/yard/handlers/c/handler_methods.rb +42 -8
  23. data/lib/yard/handlers/c/init_handler.rb +1 -1
  24. data/lib/yard/handlers/c/method_handler.rb +3 -3
  25. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
  26. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
  27. data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
  28. data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
  29. data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
  30. data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
  31. data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
  32. data/lib/yard/logging.rb +1 -0
  33. data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
  34. data/lib/yard/parser/source_parser.rb +6 -6
  35. data/lib/yard/rake/yardoc_task.rb +2 -2
  36. data/lib/yard/serializers/file_system_serializer.rb +33 -1
  37. data/lib/yard/server/commands/display_file_command.rb +8 -3
  38. data/lib/yard/server/commands/display_object_command.rb +7 -3
  39. data/lib/yard/server/doc_server_helper.rb +2 -8
  40. data/lib/yard/server/doc_server_serializer.rb +2 -4
  41. data/lib/yard/server/router.rb +1 -1
  42. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
  43. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
  44. data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
  45. data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
  46. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
  47. data/lib/yard/tags/directives.rb +1 -0
  48. data/lib/yard/tags/library.rb +9 -7
  49. data/lib/yard/tags/overload_tag.rb +4 -1
  50. data/lib/yard/templates/helpers/html_helper.rb +4 -3
  51. data/lib/yard/templates/template_options.rb +3 -0
  52. data/lib/yard/version.rb +1 -1
  53. data/spec/cli/command_parser_spec.rb +14 -14
  54. data/spec/cli/command_spec.rb +11 -11
  55. data/spec/cli/config_spec.rb +32 -32
  56. data/spec/cli/diff_spec.rb +86 -90
  57. data/spec/cli/display_spec.rb +6 -6
  58. data/spec/cli/gems_spec.rb +28 -28
  59. data/spec/cli/graph_spec.rb +8 -8
  60. data/spec/cli/help_spec.rb +8 -8
  61. data/spec/cli/i18n_spec.rb +33 -37
  62. data/spec/cli/list_spec.rb +2 -2
  63. data/spec/cli/markup_types_spec.rb +3 -3
  64. data/spec/cli/server_spec.rb +74 -88
  65. data/spec/cli/stats_spec.rb +14 -14
  66. data/spec/cli/yardoc_spec.rb +316 -321
  67. data/spec/cli/yri_spec.rb +45 -45
  68. data/spec/code_objects/base_spec.rb +174 -173
  69. data/spec/code_objects/class_object_spec.rb +65 -65
  70. data/spec/code_objects/code_object_list_spec.rb +13 -11
  71. data/spec/code_objects/constants_spec.rb +68 -58
  72. data/spec/code_objects/extra_file_object_spec.rb +71 -59
  73. data/spec/code_objects/macro_object_spec.rb +64 -64
  74. data/spec/code_objects/method_object_spec.rb +80 -72
  75. data/spec/code_objects/module_object_spec.rb +47 -47
  76. data/spec/code_objects/namespace_object_spec.rb +51 -51
  77. data/spec/code_objects/proxy_spec.rb +54 -54
  78. data/spec/config_spec.rb +104 -104
  79. data/spec/core_ext/array_spec.rb +5 -5
  80. data/spec/core_ext/file_spec.rb +33 -33
  81. data/spec/core_ext/hash_spec.rb +5 -5
  82. data/spec/core_ext/insertion_spec.rb +18 -18
  83. data/spec/core_ext/module_spec.rb +6 -6
  84. data/spec/core_ext/string_spec.rb +17 -17
  85. data/spec/core_ext/symbol_hash_spec.rb +42 -39
  86. data/spec/docstring_parser_spec.rb +65 -65
  87. data/spec/docstring_spec.rb +137 -130
  88. data/spec/handlers/alias_handler_spec.rb +39 -39
  89. data/spec/handlers/attribute_handler_spec.rb +35 -35
  90. data/spec/handlers/base_spec.rb +60 -51
  91. data/spec/handlers/c/alias_handler_spec.rb +6 -6
  92. data/spec/handlers/c/attribute_handler_spec.rb +12 -12
  93. data/spec/handlers/c/class_handler_spec.rb +35 -22
  94. data/spec/handlers/c/constant_handler_spec.rb +24 -22
  95. data/spec/handlers/c/init_handler_spec.rb +10 -10
  96. data/spec/handlers/c/method_handler_spec.rb +150 -65
  97. data/spec/handlers/c/mixin_handler_spec.rb +5 -5
  98. data/spec/handlers/c/module_handler_spec.rb +27 -15
  99. data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
  100. data/spec/handlers/c/path_handler_spec.rb +8 -8
  101. data/spec/handlers/c/spec_helper.rb +10 -0
  102. data/spec/handlers/c/struct_handler_spec.rb +3 -3
  103. data/spec/handlers/class_condition_handler_spec.rb +18 -18
  104. data/spec/handlers/class_handler_spec.rb +97 -97
  105. data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
  106. data/spec/handlers/class_variable_handler_spec.rb +3 -3
  107. data/spec/handlers/constant_handler_spec.rb +32 -29
  108. data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
  109. data/spec/handlers/dsl_handler_spec.rb +108 -109
  110. data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
  111. data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
  112. data/spec/handlers/exception_handler_spec.rb +23 -23
  113. data/spec/handlers/extend_handler_spec.rb +9 -9
  114. data/spec/handlers/legacy_base_spec.rb +60 -60
  115. data/spec/handlers/method_condition_handler_spec.rb +5 -5
  116. data/spec/handlers/method_handler_spec.rb +92 -92
  117. data/spec/handlers/mixin_handler_spec.rb +25 -25
  118. data/spec/handlers/module_function_handler_spec.rb +24 -24
  119. data/spec/handlers/module_handler_spec.rb +15 -15
  120. data/spec/handlers/private_class_method_handler_spec.rb +4 -48
  121. data/spec/handlers/private_constant_handler_spec.rb +8 -8
  122. data/spec/handlers/processor_spec.rb +12 -12
  123. data/spec/handlers/public_class_method_handler_spec.rb +10 -0
  124. data/spec/handlers/ruby/base_spec.rb +16 -16
  125. data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
  126. data/spec/handlers/spec_helper.rb +1 -1
  127. data/spec/handlers/visibility_handler_spec.rb +25 -21
  128. data/spec/handlers/yield_handler_spec.rb +28 -28
  129. data/spec/i18n/locale_spec.rb +16 -16
  130. data/spec/i18n/message_spec.rb +8 -8
  131. data/spec/i18n/messages_spec.rb +14 -14
  132. data/spec/i18n/pot_generator_spec.rb +32 -32
  133. data/spec/i18n/text_spec.rb +22 -22
  134. data/spec/logging_spec.rb +12 -12
  135. data/spec/options_spec.rb +56 -56
  136. data/spec/parser/base_spec.rb +9 -9
  137. data/spec/parser/c_parser_spec.rb +50 -50
  138. data/spec/parser/ruby/ast_node_spec.rb +7 -7
  139. data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
  140. data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
  141. data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
  142. data/spec/parser/source_parser_spec.rb +224 -224
  143. data/spec/parser/tag_parsing_spec.rb +6 -7
  144. data/spec/rake/yardoc_task_spec.rb +38 -48
  145. data/spec/registry_spec.rb +143 -143
  146. data/spec/registry_store_spec.rb +165 -165
  147. data/spec/rubygems/doc_manager_spec.rb +38 -38
  148. data/spec/serializers/file_system_serializer_spec.rb +53 -33
  149. data/spec/serializers/yardoc_serializer_spec.rb +15 -15
  150. data/spec/server/adapter_spec.rb +15 -15
  151. data/spec/server/commands/base_spec.rb +29 -29
  152. data/spec/server/commands/library_command_spec.rb +12 -12
  153. data/spec/server/commands/static_file_command_spec.rb +28 -28
  154. data/spec/server/doc_server_helper_spec.rb +8 -8
  155. data/spec/server/doc_server_serializer_spec.rb +23 -18
  156. data/spec/server/rack_adapter_spec.rb +6 -6
  157. data/spec/server/router_spec.rb +39 -39
  158. data/spec/server/static_caching_spec.rb +16 -16
  159. data/spec/server/webrick_servlet_spec.rb +6 -7
  160. data/spec/server_spec.rb +3 -3
  161. data/spec/spec_helper.rb +11 -2
  162. data/spec/tags/default_factory_spec.rb +64 -64
  163. data/spec/tags/default_tag_spec.rb +5 -5
  164. data/spec/tags/directives_spec.rb +121 -121
  165. data/spec/tags/library_spec.rb +14 -14
  166. data/spec/tags/overload_tag_spec.rb +24 -24
  167. data/spec/tags/ref_tag_list_spec.rb +12 -12
  168. data/spec/templates/class_spec.rb +3 -3
  169. data/spec/templates/constant_spec.rb +4 -4
  170. data/spec/templates/engine_spec.rb +47 -48
  171. data/spec/templates/examples/class001.html +129 -101
  172. data/spec/templates/examples/class002.html +31 -27
  173. data/spec/templates/examples/method001.html +54 -47
  174. data/spec/templates/examples/method002.html +33 -28
  175. data/spec/templates/examples/method003.html +70 -64
  176. data/spec/templates/examples/method004.html +13 -9
  177. data/spec/templates/examples/method005.html +38 -32
  178. data/spec/templates/examples/module001.html +343 -339
  179. data/spec/templates/examples/module002.html +147 -124
  180. data/spec/templates/examples/module003.html +94 -81
  181. data/spec/templates/examples/module004.html +40 -33
  182. data/spec/templates/helpers/base_helper_spec.rb +91 -95
  183. data/spec/templates/helpers/html_helper_spec.rb +276 -279
  184. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
  185. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
  186. data/spec/templates/helpers/markup_helper_spec.rb +57 -57
  187. data/spec/templates/helpers/method_helper_spec.rb +20 -20
  188. data/spec/templates/helpers/shared_signature_examples.rb +33 -31
  189. data/spec/templates/helpers/text_helper_spec.rb +6 -6
  190. data/spec/templates/method_spec.rb +7 -7
  191. data/spec/templates/module_spec.rb +7 -7
  192. data/spec/templates/onefile_spec.rb +7 -7
  193. data/spec/templates/section_spec.rb +66 -69
  194. data/spec/templates/spec_helper.rb +1 -1
  195. data/spec/templates/tag_spec.rb +5 -5
  196. data/spec/templates/template_spec.rb +158 -158
  197. data/spec/verifier_spec.rb +52 -52
  198. data/templates/default/fulldoc/html/css/full_list.css +32 -31
  199. data/templates/default/fulldoc/html/css/style.css +212 -77
  200. data/templates/default/fulldoc/html/frames.erb +6 -15
  201. data/templates/default/fulldoc/html/full_list.erb +14 -21
  202. data/templates/default/fulldoc/html/full_list_class.erb +1 -1
  203. data/templates/default/fulldoc/html/full_list_file.erb +6 -4
  204. data/templates/default/fulldoc/html/full_list_method.erb +8 -6
  205. data/templates/default/fulldoc/html/js/app.js +100 -76
  206. data/templates/default/fulldoc/html/js/full_list.js +170 -135
  207. data/templates/default/fulldoc/html/setup.rb +50 -7
  208. data/templates/default/layout/html/breadcrumb.erb +0 -2
  209. data/templates/default/layout/html/headers.erb +2 -1
  210. data/templates/default/layout/html/layout.erb +16 -10
  211. data/templates/default/layout/html/script_setup.erb +1 -2
  212. data/templates/default/layout/html/search.erb +7 -2
  213. data/templates/default/layout/html/setup.rb +16 -0
  214. data/templates/default/method/html/header.erb +7 -6
  215. data/templates/default/module/html/attribute_summary.erb +1 -1
  216. data/templates/default/module/html/box_info.erb +24 -18
  217. data/templates/default/module/html/constant_summary.erb +9 -11
  218. data/templates/default/module/html/item_summary.erb +1 -1
  219. data/templates/default/module/html/method_summary.erb +1 -1
  220. data/templates/guide/fulldoc/html/setup.rb +1 -1
  221. data/yard.gemspec +1 -2
  222. metadata +10 -7
  223. data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
  224. data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
  225. data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f723063cf267909777160a18d322d5dd78acace
4
- data.tar.gz: 8ff1809f4067f82eafc3667601f75882b1a1aabc
3
+ metadata.gz: 601891a952ecd1662fcfaceb1160b3b664bf56d2
4
+ data.tar.gz: 979f166173832405bfcea7ba9b2aae33de865f5f
5
5
  SHA512:
6
- metadata.gz: de4c7904f326053e2ad7dc88d3e63c2915689e74216b9f94df603fb20b39dd35a52d398882dfd3c8d73a2a0e7b74727a17420db745d05e1f6d732d265c65cddd
7
- data.tar.gz: d75edfe99a18af7a74638c490501b328682f2aeb8d216624e8a4b1d48a25d2be66779eedca64d263b73addd6385af70782a672cb62087435a8a8dd9fd9a0e348
6
+ metadata.gz: 8753f755361ae434ae739fd354182f8c5ed6fc5469b6c50d2af9a99bd73694d246b1c4e200cec05f8cc84f674070c2921e6bf8bd947836684f8679ab4896ec8a
7
+ data.tar.gz: 1ef05a31710af7aba1837cdbbfa54cad528b7e412e02c37433a8ebb07e6dfc8691e522f17a0ff2e90d4cb5a1d581af383bafb0b43b954c7841a21bc5b15faf0f
@@ -1,4 +1,23 @@
1
- # HEAD
1
+ # 0.9.0 - July 4th, 2016
2
+
3
+ Special thanks to Alex Dowad, MSP-Greg, and Alex McLain for their extended
4
+ contributions to this version.
5
+
6
+ - (Breaking Change): Replaced default template with an updated "frameless" version.
7
+ This change may affect backward compatibility if custom templates made modifications
8
+ to `default/fulldoc/html`, specifically the index or navigation lists.
9
+ - Added support for Ruby 2.1+ decorator style method declaration syntax. YARD now
10
+ supports:
11
+ private def foo(x, y) end
12
+ - Metadata headers in extra files can now be escaped from rendering by enclosing them
13
+ in HTML comment blocks (`<!--\n @metadata here... \n-->`). Ensure that the opening
14
+ comment tag is alone on the first line of the file to use this functionality.
15
+ - Improved parsing of various CRuby coding styles.
16
+ - Fixed issue with binary image assets when using `yard server`.
17
+ - Fixed deprecation warnings from Rake 10.x.
18
+ - Tests updated for RSpec 3.
19
+
20
+ # 0.8.7.6 - October 26, 2014
2
21
 
3
22
  - Support using `@option` tag on keyword arg splat parameter. (#729)
4
23
  - Add `.stats_options` for `YardocTask`. (#800, #801)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2013 Loren Segal
1
+ Copyright (c) 2007-2016 Loren Segal
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
19
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Homepage](http://img.shields.io/badge/home-yardoc.org-blue.svg)](http://yardoc.org)
4
4
  [![GitHub](http://img.shields.io/badge/github-lsegal/yard-blue.svg)](http://github.com/lsegal/yard)
5
5
  [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/gems/yard/frames)
6
- [![Gitter Chat](http://img.shields.io/badge/chat-gitter.im-orange.svg)](https://gitter.im/lsegal/yard)
6
+ [![IRC Chat](https://img.shields.io/badge/chat-%23yard%20@%20freenode-orange.svg)](irc://irc.freenode.net/yard)
7
7
 
8
8
  [![Gem Version](https://badge.fury.io/rb/yard.svg)](http://github.com/lsegal/yard/releases)
9
9
  [![Build Status](https://travis-ci.org/lsegal/yard.svg?branch=master)](https://travis-ci.org/lsegal/yard)
@@ -288,7 +288,7 @@ See {file:CHANGELOG.md} for a list of changes.
288
288
 
289
289
  ## License
290
290
 
291
- YARD &copy; 2007-2014 by [Loren Segal](mailto:lsegal@soen.ca). YARD is
291
+ YARD &copy; 2007-2016 by [Loren Segal](mailto:lsegal@soen.ca). YARD is
292
292
  licensed under the MIT license except for some files which come from the
293
293
  RDoc/Ruby distributions. Please see the {file:LICENSE} and {file:LEGAL}
294
294
  documents for more information.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  desc "Installs the gem"
15
15
  task :install => :gem do
16
- sh "gem install yard-#{YARD::VERSION}.gem --no-rdoc --no-ri"
16
+ sh "gem install yard-#{YARD::VERSION}.gem --no-document"
17
17
  end
18
18
 
19
19
  begin
data/bin/yard CHANGED
File without changes
data/bin/yardoc CHANGED
File without changes
data/bin/yri CHANGED
File without changes
@@ -186,7 +186,62 @@ and recommended conventions for writing type specifications, see
186
186
  conventions may change every now and then, although we are working on a more
187
187
  "formal" type specification proposal.
188
188
 
189
- ## Documenting DSL Methods
189
+ ## Documenting Attributes
190
+
191
+ To document a Ruby attribute, add documentation text above the attribute
192
+ definition.
193
+
194
+ # Controls the amplitude of the waveform.
195
+ # @return [Numeric] the amplitude of the waveform
196
+ attr_accessor :amplitude
197
+
198
+ As a short-hand syntax for declaring reader and writer attribute pairs,
199
+ YARD will automatically wire up the correct method types and information
200
+ by simply defining documentation in the `@return` tag. For example,
201
+ the following declaration will show the correct information for the
202
+ `waveform` attribute, both for the getter's return type and the
203
+ setter's value parameter type:
204
+
205
+ # @return [Numeric] the amplitude of the waveform
206
+ attr_accessor :amplitude
207
+
208
+ In this case, the most important details for the attribute are the
209
+ object type declaration and its descriptive text.
210
+
211
+ ### Documentation for a Separate Attribute Writer
212
+
213
+ Usually an attribute will get and set a value using the same syntax,
214
+ so there is no reason to have separate documentation for an attribute
215
+ writer. In the above `amplitude` case, the `Numeric` type is both used
216
+ for the getter and setter types.
217
+
218
+ Sometimes, however, you might want to have separate documentation
219
+ for the getter and setter. In this case, you would still add
220
+ the documentation text to the getter declaration (or `attr_accessor`)
221
+ and use `@overload` tags to declare the separate docstrings. For example:
222
+
223
+ # @overload amplitude
224
+ # Gets the current waveform amplitude.
225
+ # @return [Numeric] the amplitude of the waveform
226
+ # @overload amplitude=(value)
227
+ # Sets the new amplitude.
228
+ # @param value [Numeric] the new amplitude value
229
+ # @note The new amplitude will only take effect if {#restart}
230
+ # is called on the stream.
231
+
232
+ Note that by default, YARD exposes the reader portion of the attribute
233
+ in HTML output. If you have separate `attr_reader` and `attr_writer`
234
+ declarations, make sure to put your documentation (for both reader
235
+ and writer methods) on the reader declaration using `@overload`
236
+ tags as described above. For example:
237
+
238
+ # @overload ...documentation here...
239
+ attr_reader :amplitude
240
+
241
+ # This documentation will be ignored by YARD.
242
+ attr_writer :amplitude
243
+
244
+ ## Documenting Custom DSL Methods
190
245
 
191
246
  Application code in Ruby often makes use of DSL style metaprogrammed methods.
192
247
  The most common is the `attr_accessor` method, which of course has built-in
@@ -520,6 +575,17 @@ might not be descriptive enough, so YARD allows you to specify a full title:
520
575
  Currently all other meta-data is hidden from view, though accessible
521
576
  programmatically using the {YARD::CodeObjects::ExtraFileObject} class.
522
577
 
578
+ You can wrap the meta data section in an HTML comment to prevent it
579
+ from being displayed in rendered markdown on GitHub:
580
+
581
+ <!--
582
+ # @markup markdown
583
+ # @title The Best Library in the World!
584
+ # @author The Author Name
585
+ -->
586
+
587
+ This is the best library you will ever meet. Lipsum ...
588
+
523
589
  <a name="config"></a>
524
590
 
525
591
  ## Configuring YARD
@@ -571,16 +637,32 @@ document covers the basics of how YARD's templating system works.
571
637
 
572
638
  ## Plugin Support
573
639
 
574
- As of 0.4, YARD will automatically load any gem named with the prefix of
575
- `yard-` or `yard_`. You can use this to load a custom plugin that
640
+ YARD will allow any RubyGem installed on your system (or in your Gemfile)
641
+ to be loaded as a plugin provided it has a name with the prefix of
642
+ `yard-` or `yard_`. In order to load a plugin, use the `--plugin`
643
+ switch with the short-name (name minus the `yard-` prefix) or full-name
644
+ of the gem:
645
+
646
+ $ gem install yard-custom-plugin
647
+ ...
648
+ $ yard doc --plugin custom-plugin
649
+ or
650
+ $ yard doc --plugin yard-custom-plugin
651
+
652
+ Note: you can also put this switch in your `.yardopts` file. See the
653
+ `.yardopts` section above for more information.
654
+
655
+ You can use this functionality to load a custom plugin that
576
656
  [extend](#extending) YARD's functionality. A good example of this
577
657
  is the [yard-rspec][yard-rspec] plugin, which adds [RSpec][rspec] specifications
578
658
  to your documentation (`yardoc` and `yri`). You can try it out by installing
579
659
  the gem or cloning the project and trying the example:
580
660
 
581
- $ gem install yard-rspec -s http://gemcutter.org
582
- or
583
- $ git clone git://github.com/lsegal/yard-spec-plugin
661
+ $ gem install yard-rspec
662
+
663
+ You can then load the plugin with:
664
+
665
+ $ yard doc --plugin rspec
584
666
 
585
667
  YARD also provides a way to temporarily disable plugins on a per-user basis.
586
668
  To disable a plugin create the file `~/.yard/ignored_plugins` with a list
File without changes
File without changes
File without changes
@@ -1,7 +1,9 @@
1
- <% n = 1 %>
1
+ <% even_odd = 'odd' %>
2
2
  <% collect_tags.each do |tag| %>
3
- <li class="r<%= n %> <%= tag.object.has_tag?(:deprecated) ? 'deprecated' : '' %>">
4
- <span class="object_link"><%= tag_link(tag) %></span>
3
+ <li class="<%= even_odd %> <%= tag.object.has_tag?(:deprecated) ? 'deprecated' : '' %>">
4
+ <div class="item">
5
+ <span class="object_link"><%= tag_link(tag) %></span>
6
+ </div>
5
7
  </li>
6
- <% n = n == 2 ? 1 : 2 %>
8
+ <% even_odd = (even_odd == 'even' ? 'odd' : 'even') %>
7
9
  <% end %>
@@ -46,6 +46,7 @@ module YARD
46
46
  autoload :BUILTIN_MODULES, __p('code_objects/base')
47
47
  autoload :BUILTIN_EXCEPTIONS, __p('code_objects/base')
48
48
  autoload :CONSTANTMATCH, __p('code_objects/base')
49
+ autoload :CONSTANTSTART, __p('code_objects/base')
49
50
  autoload :METHODMATCH, __p('code_objects/base')
50
51
  autoload :METHODNAMEMATCH, __p('code_objects/base')
51
52
  autoload :NAMESPACEMATCH, __p('code_objects/base')
@@ -114,6 +115,7 @@ module YARD
114
115
  autoload :ClassVariableHandler, __p('handlers/ruby/class_variable_handler')
115
116
  autoload :CommentHandler, __p('handlers/ruby/comment_handler')
116
117
  autoload :ConstantHandler, __p('handlers/ruby/constant_handler')
118
+ autoload :DecoratorHandlerMethods, __p('handlers/ruby/decorator_handler_methods')
117
119
  autoload :DSLHandler, __p('handlers/ruby/dsl_handler')
118
120
  autoload :DSLHandlerMethods, __p('handlers/ruby/dsl_handler_methods')
119
121
  autoload :ExceptionHandler, __p('handlers/ruby/exception_handler')
@@ -125,6 +127,7 @@ module YARD
125
127
  autoload :ModuleFunctionHandler, __p('handlers/ruby/module_function_handler')
126
128
  autoload :PrivateClassMethodHandler, __p('handlers/ruby/private_class_method_handler')
127
129
  autoload :PrivateConstantHandler, __p('handlers/ruby/private_constant_handler')
130
+ autoload :PublicClassMethodHandler, __p('handlers/ruby/public_class_method_handler')
128
131
  autoload :StructHandlerMethods, __p('handlers/ruby/struct_handler_methods')
129
132
  autoload :VisibilityHandler, __p('handlers/ruby/visibility_handler')
130
133
  autoload :YieldHandler, __p('handlers/ruby/yield_handler')
@@ -276,7 +276,7 @@ module YARD
276
276
  super(*args)
277
277
 
278
278
  # Last minute modifications
279
- self.files = ['{lib,app}/**/*.rb', 'ext/**/*.c'] if self.files.empty?
279
+ self.files = Parser::SourceParser::DEFAULT_PATH_GLOB if self.files.empty?
280
280
  self.files.delete_if {|x| x =~ /\A\s*\Z/ } # remove empty ones
281
281
  readme = Dir.glob('README{,*[^~]}').first
282
282
  readme ||= Dir.glob(files.first).first if options.onefile
@@ -49,11 +49,14 @@ module YARD
49
49
  # Regular expression to match constant name
50
50
  CONSTANTMATCH = /[A-Z]\w*/
51
51
 
52
+ # Regular expression to match the beginning of a constant
53
+ CONSTANTSTART = /^[A-Z]/
54
+
52
55
  # Regular expression to match namespaces (const A or complex path A::B)
53
56
  NAMESPACEMATCH = /(?:(?:#{NSEPQ}\s*)?#{CONSTANTMATCH})+/
54
57
 
55
58
  # Regular expression to match a method name
56
- METHODNAMEMATCH = /[a-zA-Z_]\w*[!?=]?|[-+~]\@|<<|>>|=~|===?|<=>|[<>]=?|\*\*|[-\/+%^&*~`|]|\[\]=?/
59
+ METHODNAMEMATCH = /[a-zA-Z_]\w*[!?=]?|[-+~]\@|<<|>>|=~|===?|![=~]?|<=>|[<>]=?|\*\*|[-\/+%^&*~`|]|\[\]=?/
57
60
 
58
61
  # Regular expression to match a fully qualified method def (self.foo, Class.foo).
59
62
  METHODMATCH = /(?:(?:#{NAMESPACEMATCH}|[a-z]\w*)\s*(?:#{CSEPQ}|#{NSEPQ})\s*)?#{METHODNAMEMATCH}/
@@ -93,6 +93,8 @@ module YARD::CodeObjects
93
93
  end
94
94
  when /^\s*#\s*@(\S+)\s*(.+?)\s*$/
95
95
  attributes[$1] = $2
96
+ when /^\s*<!--\s*$/, /^\s*-->\s*$/
97
+ # Ignore HTML comments
96
98
  else
97
99
  cut_index = index
98
100
  break
@@ -125,4 +127,4 @@ module YARD::CodeObjects
125
127
  text.translate(YARD::Registry.locale(locale))
126
128
  end
127
129
  end
128
- end
130
+ end
@@ -242,12 +242,12 @@ module YARD
242
242
  if @namespace.root?
243
243
  (@imethod ? ISEP : "") + name.to_s
244
244
  elsif @origname
245
- if @origname =~ /^[A-Z]/
245
+ if @origname =~ CONSTANTSTART
246
246
  @origname
247
247
  else
248
248
  [namespace.path, @origname].join
249
249
  end
250
- elsif name.to_s =~ /^[A-Z]/ # const
250
+ elsif name.to_s =~ CONSTANTSTART
251
251
  name.to_s
252
252
  else # class meth?
253
253
  [namespace.path, name.to_s].join(CSEP)
@@ -172,15 +172,20 @@ module YARD
172
172
  resolve_reference
173
173
  return @summary if @summary
174
174
  stripped = self.gsub(/<.+?>/m, '').gsub(/[\r\n](?![\r\n])/, ' ').strip
175
- open_parens = ['{', '(', '[']
176
- close_parens = ['}', ')', ']']
177
175
  num_parens = 0
178
176
  idx = length.times do |index|
179
177
  case stripped[index, 1]
180
- when ".", "\r", "\n"
178
+ when "."
181
179
  next_char = stripped[index + 1, 1].to_s
182
- if num_parens == 0 && next_char =~ /^\s*$/
183
- break index - 1
180
+ break index - 1 if num_parens <= 0 && next_char =~ /^\s*$/
181
+ when "\r", "\n"
182
+ next_char = stripped[index + 1, 1].to_s
183
+ if next_char =~ /^\s*$/
184
+ if stripped[index - 1, 1] == '.'
185
+ break index - 2
186
+ else
187
+ break index - 1
188
+ end
184
189
  end
185
190
  when "{", "(", "["
186
191
  num_parens += 1
@@ -207,7 +212,7 @@ module YARD
207
212
  when Tags::OverloadTag
208
213
  tag_text = "@#{tag.tag_name} #{tag.signature}\n"
209
214
  unless tag.docstring.blank?
210
- tag_text += "\n" + tag.docstring.all.gsub(/\r?\n/, "\n ")
215
+ tag_text += "\n " + tag.docstring.all.gsub(/\r?\n/, "\n ")
211
216
  end
212
217
  when Tags::OptionTag
213
218
  tag_text = "@#{tag.tag_name} #{tag.name}"
@@ -483,9 +483,8 @@ module YARD
483
483
  # @return [void]
484
484
  # @since 0.8.0
485
485
  def register_transitive_tags(object)
486
- return unless object
486
+ return unless object && !object.namespace.is_a?(Proxy)
487
487
  Tags::Library.transitive_tags.each do |tag|
488
- next if object.namespace.is_a?(Proxy)
489
488
  next unless object.namespace.has_tag?(tag)
490
489
  next if object.has_tag?(tag)
491
490
  object.add_tag(*object.namespace.tags(tag))
@@ -65,6 +65,25 @@ module YARD
65
65
  var.empty? ? nil : P(var)
66
66
  end
67
67
 
68
+ def ensure_variable_defined!(var, max_retries = 1)
69
+ retries, object = 0, nil
70
+
71
+ loop do
72
+ object = namespace_for_variable(var)
73
+ break unless object.is_a?(Proxy)
74
+
75
+ if retries <= max_retries
76
+ log.debug "Missing namespace variable #{var} in file `#{parser.file}', moving it to the back of the line."
77
+ parser.parse_remaining_files
78
+ else
79
+ raise NamespaceMissingError, object
80
+ end
81
+ retries += 1
82
+ end
83
+
84
+ object
85
+ end
86
+
68
87
  def namespaces
69
88
  globals.cruby_namespaces ||= {}
70
89
  end
@@ -7,7 +7,7 @@ module YARD
7
7
 
8
8
  def handle_class(var_name, class_name, parent, in_module = nil)
9
9
  parent = nil if parent == "0"
10
- namespace = in_module ? namespace_for_variable(in_module) : Registry.root
10
+ namespace = in_module ? ensure_variable_defined!(in_module) : Registry.root
11
11
  if namespace.nil?
12
12
  raise Parser::UndocumentableError, "class #{class_name}. " +
13
13
  "Cannot find definition for parent namespace."
@@ -29,7 +29,7 @@ module YARD
29
29
  end
30
30
 
31
31
  def handle_module(var_name, module_name, in_module = nil)
32
- namespace = in_module ? namespace_for_variable(in_module) : Registry.root
32
+ namespace = in_module ? ensure_variable_defined!(in_module) : Registry.root
33
33
  if namespace.nil?
34
34
  raise Parser::UndocumentableError, "module #{module_name}. " +
35
35
  "Cannot find definition for parent namespace."
@@ -51,6 +51,16 @@ module YARD
51
51
  end
52
52
 
53
53
  namespace = namespace_for_variable(var_name)
54
+
55
+ # Is this method being defined on a core Ruby class or module?
56
+ if namespace.is_a?(Proxy)
57
+ if var_name =~ /^rb_c(\w+)/ && YARD::CodeObjects::BUILTIN_CLASSES.include?($1)
58
+ namespace = namespaces[var_name] = YARD::CodeObjects::ClassObject.new(:root, $1)
59
+ elsif var_name =~ /^rb_m(\w+)/ && YARD::CodeObjects::BUILTIN_MODULES.include?($1)
60
+ namespace = namespaces[var_name] = YARD::CodeObjects::ModuleObject.new(:root, $1)
61
+ end
62
+ end
63
+
54
64
  return if namespace.nil? # XXX: raise UndocumentableError might be too noisy.
55
65
  register MethodObject.new(namespace, name, scope) do |obj|
56
66
  register_visibility(obj, visibility)
@@ -93,8 +103,12 @@ module YARD
93
103
  end
94
104
 
95
105
  def handle_constants(type, var_name, const_name, value)
96
- return unless type == 'const'
97
- namespace = namespace_for_variable(var_name)
106
+ return unless type =~ /^const$|^global_const$/
107
+ if type == 'global_const'
108
+ namespace = :root
109
+ else
110
+ namespace = namespace_for_variable(var_name)
111
+ end
98
112
  register ConstantObject.new(namespace, const_name) do |obj|
99
113
  obj.source_type = :c
100
114
  obj.value = value
@@ -147,6 +161,7 @@ module YARD
147
161
  if src_stmt = symbols[symbol]
148
162
  register_file_info(object, src_stmt.file, src_stmt.line, true)
149
163
  register_source(object, src_stmt)
164
+ record_parameters(object, symbol, src_stmt)
150
165
  unless src_stmt.comments.nil? || src_stmt.comments.source.empty?
151
166
  register_docstring(object, src_stmt.comments.source, src_stmt)
152
167
  return # found docstring
@@ -157,10 +172,15 @@ module YARD
157
172
  # so look in overrides
158
173
  override_comments.each do |name, override_comment|
159
174
  next unless override_comment.file == file
160
- name = name.gsub(/::([^:]+?)\Z/, '.\1')
161
- just_method_name = name.gsub(/\A.+(#|::|\.)/, '')
162
- just_method_name = 'initialize' if just_method_name == 'new'
163
- if object.path == name || object.name.to_s == just_method_name
175
+ name = name.gsub(/::([^:\.#]+?)\Z/, '.\1')
176
+
177
+ path = if name =~ /\.|#/ # explicit namespace in override comment
178
+ object.path
179
+ else
180
+ object.name.to_s
181
+ end
182
+
183
+ if path == name || path == name.sub(/new$/, 'initialize') || path == name.sub('.', '#')
164
184
  register_docstring(object, override_comment.source, override_comment)
165
185
  return
166
186
  end
@@ -171,6 +191,20 @@ module YARD
171
191
  register_docstring(object, statement.comments.source, statement)
172
192
  end
173
193
  end
194
+
195
+ def record_parameters(object, symbol, src)
196
+ # use regex to extract comma-delimited list of parameters from cfunc definition
197
+ if src.source =~ /VALUE\s+#{symbol}\(([^)]*)\)\s*\{/m
198
+ params = $~[1].split(/\s*,\s*/)
199
+ # cfunc for a "varargs" method has params "int argc, VALUE *argv"
200
+ if params[0] =~ /int\s+argc/ && params[1] =~ /VALUE\s*\*\s*argv/
201
+ object.parameters = [['*args', nil]]
202
+ else
203
+ # the first cfunc argument is the 'self' argument, we don't need that
204
+ object.parameters = params.drop(1).map { |s| [s[/VALUE\s+(\S+)/, 1], nil] }
205
+ end
206
+ end
207
+ end
174
208
  end
175
209
  end
176
210
  end