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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 601891a952ecd1662fcfaceb1160b3b664bf56d2
|
4
|
+
data.tar.gz: 979f166173832405bfcea7ba9b2aae33de865f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8753f755361ae434ae739fd354182f8c5ed6fc5469b6c50d2af9a99bd73694d246b1c4e200cec05f8cc84f674070c2921e6bf8bd947836684f8679ab4896ec8a
|
7
|
+
data.tar.gz: 1ef05a31710af7aba1837cdbbfa54cad528b7e412e02c37433a8ebb07e6dfc8691e522f17a0ff2e90d4cb5a1d581af383bafb0b43b954c7841a21bc5b15faf0f
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
#
|
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-
|
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
|
-
[![
|
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 © 2007-
|
291
|
+
YARD © 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
data/bin/yard
CHANGED
File without changes
|
data/bin/yardoc
CHANGED
File without changes
|
data/bin/yri
CHANGED
File without changes
|
data/docs/GettingStarted.md
CHANGED
@@ -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
|
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
|
-
|
575
|
-
|
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
|
582
|
-
|
583
|
-
|
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
|
-
<%
|
1
|
+
<% even_odd = 'odd' %>
|
2
2
|
<% collect_tags.each do |tag| %>
|
3
|
-
<li class="
|
4
|
-
<
|
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
|
-
<%
|
8
|
+
<% even_odd = (even_odd == 'even' ? 'odd' : 'even') %>
|
7
9
|
<% end %>
|
data/lib/yard/autoload.rb
CHANGED
@@ -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')
|
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -276,7 +276,7 @@ module YARD
|
|
276
276
|
super(*args)
|
277
277
|
|
278
278
|
# Last minute modifications
|
279
|
-
self.files =
|
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 =~
|
245
|
+
if @origname =~ CONSTANTSTART
|
246
246
|
@origname
|
247
247
|
else
|
248
248
|
[namespace.path, @origname].join
|
249
249
|
end
|
250
|
-
elsif name.to_s =~
|
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)
|
data/lib/yard/docstring.rb
CHANGED
@@ -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 "."
|
178
|
+
when "."
|
181
179
|
next_char = stripped[index + 1, 1].to_s
|
182
|
-
if num_parens
|
183
|
-
|
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}"
|
data/lib/yard/handlers/base.rb
CHANGED
@@ -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))
|
data/lib/yard/handlers/c/base.rb
CHANGED
@@ -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 ?
|
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 ?
|
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
|
97
|
-
|
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(/::([
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|