yard 0.2.3.5 → 0.4.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.
- data/.yardopts +12 -10
- data/ChangeLog +5686 -0
- data/{README.markdown → README.md} +65 -11
- data/Rakefile +25 -13
- data/benchmarks/concat_vs_join.rb +12 -0
- data/benchmarks/erb_vs_erubis.rb +14 -14
- data/benchmarks/marshal_vs_dbm.rb +1 -1
- data/benchmarks/pathname_vs_string.rb +50 -0
- data/benchmarks/template_erb.rb +22 -0
- data/benchmarks/template_format.rb +6 -0
- data/benchmarks/template_profile.rb +17 -0
- data/bin/yri +16 -7
- data/docs/{CODE_OBJECTS.markdown → CodeObjects.md} +0 -0
- data/docs/{GETTING_STARTED.markdown → GettingStarted.md} +49 -11
- data/docs/{GLOSSARY.markdown → Glossary.md} +0 -0
- data/docs/{HANDLERS.markdown → Handlers.md} +5 -5
- data/docs/{OVERVIEW.markdown → Overview.md} +9 -13
- data/docs/{PARSER.markdown → Parser.md} +1 -1
- data/docs/{TAGS.markdown → Tags.md} +1 -1
- data/docs/Templates.md +286 -0
- data/docs/{WHATSNEW.markdown → WhatsNew.md} +82 -2
- data/lib/rubygems_plugin.rb +17 -20
- data/lib/yard.rb +47 -1
- data/lib/yard/autoload.rb +38 -47
- data/lib/yard/cli/yard_graph.rb +36 -13
- data/lib/yard/cli/yardoc.rb +74 -12
- data/lib/yard/code_objects/base.rb +182 -14
- data/lib/yard/code_objects/class_object.rb +39 -2
- data/lib/yard/code_objects/class_variable_object.rb +4 -0
- data/lib/yard/code_objects/constant_object.rb +8 -0
- data/lib/yard/code_objects/extended_method_object.rb +14 -0
- data/lib/yard/code_objects/method_object.rb +60 -2
- data/lib/yard/code_objects/module_object.rb +6 -0
- data/lib/yard/code_objects/namespace_object.rb +99 -2
- data/lib/yard/code_objects/proxy.rb +53 -6
- data/lib/yard/code_objects/root_object.rb +2 -0
- data/lib/yard/core_ext/array.rb +61 -0
- data/lib/yard/core_ext/file.rb +21 -4
- data/lib/yard/core_ext/module.rb +11 -1
- data/lib/yard/core_ext/string.rb +13 -2
- data/lib/yard/core_ext/symbol_hash.rb +51 -3
- data/lib/yard/docstring.rb +68 -19
- data/lib/yard/globals.rb +5 -2
- data/lib/yard/handlers/base.rb +13 -3
- data/lib/yard/handlers/processor.rb +64 -2
- data/lib/yard/handlers/ruby/class_handler.rb +1 -1
- data/lib/yard/handlers/ruby/class_variable_handler.rb +5 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +38 -4
- data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/base.rb +2 -2
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +6 -3
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +21 -2
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -0
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +2 -1
- data/lib/yard/handlers/ruby/method_handler.rb +10 -0
- data/lib/yard/handlers/ruby/yield_handler.rb +2 -1
- data/lib/yard/logging.rb +17 -0
- data/lib/yard/parser/ruby/ast_node.rb +101 -0
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +2 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +10 -9
- data/lib/yard/parser/ruby/ruby_parser.rb +32 -3
- data/lib/yard/parser/source_parser.rb +82 -5
- data/lib/yard/rake/yardoc_task.rb +38 -3
- data/lib/yard/registry.rb +112 -2
- data/lib/yard/serializers/base.rb +48 -1
- data/lib/yard/serializers/file_system_serializer.rb +23 -2
- data/lib/yard/serializers/process_serializer.rb +10 -0
- data/lib/yard/serializers/stdout_serializer.rb +11 -0
- data/lib/yard/tags/library.rb +4 -1
- data/lib/yard/tags/overload_tag.rb +3 -12
- data/lib/yard/templates/engine.rb +162 -0
- data/lib/yard/{generators → templates}/helpers/base_helper.rb +14 -13
- data/lib/yard/{generators → templates}/helpers/filter_helper.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +287 -0
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +29 -0
- data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +27 -0
- data/lib/yard/{generators → templates}/helpers/markup_helper.rb +15 -11
- data/lib/yard/{generators → templates}/helpers/method_helper.rb +8 -1
- data/lib/yard/templates/helpers/module_helper.rb +15 -0
- data/lib/yard/templates/helpers/text_helper.rb +60 -0
- data/lib/yard/templates/helpers/uml_helper.rb +33 -0
- data/lib/yard/templates/template.rb +355 -0
- data/lib/yard/verifier.rb +110 -0
- data/spec/cli/yardoc_spec.rb +23 -1
- data/spec/code_objects/base_spec.rb +8 -0
- data/spec/code_objects/class_object_spec.rb +166 -156
- data/spec/code_objects/method_object_spec.rb +2 -2
- data/spec/code_objects/module_object_spec.rb +112 -110
- data/spec/code_objects/proxy_spec.rb +9 -0
- data/spec/core_ext/array_spec.rb +33 -0
- data/spec/core_ext/file_spec.rb +40 -12
- data/spec/core_ext/module_spec.rb +15 -0
- data/spec/core_ext/string_spec.rb +10 -2
- data/spec/docstring_spec.rb +157 -135
- data/spec/handlers/class_handler_spec.rb +3 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -1
- data/spec/handlers/constant_handler_spec.rb +38 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +14 -1
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +1 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +10 -1
- data/spec/handlers/examples/exception_handler_001.rb.txt +5 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +15 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +13 -0
- data/spec/handlers/exception_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +22 -0
- data/spec/handlers/mixin_handler_spec.rb +5 -3
- data/spec/handlers/yield_handler_spec.rb +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +16 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +36 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +80 -0
- data/spec/parser/source_parser_spec.rb +48 -2
- data/spec/rake/yardoc_task_spec.rb +62 -25
- data/spec/serializers/file_system_serializer_spec.rb +1 -1
- data/spec/templates/class_spec.rb +34 -0
- data/spec/templates/engine_spec.rb +121 -0
- data/spec/templates/examples/class001.html +271 -0
- data/spec/templates/examples/class001.txt +31 -0
- data/spec/templates/examples/method001.html +96 -0
- data/spec/templates/examples/method001.txt +28 -0
- data/spec/templates/examples/method002.html +81 -0
- data/spec/templates/examples/method002.txt +20 -0
- data/spec/templates/examples/method003.html +137 -0
- data/spec/templates/examples/method003.txt +45 -0
- data/spec/templates/examples/module001.dot +31 -0
- data/spec/templates/examples/module001.html +294 -0
- data/spec/templates/examples/module001.txt +33 -0
- data/spec/templates/examples/tag001.txt +82 -0
- data/spec/templates/helpers/base_helper_spec.rb +129 -0
- data/spec/{generators → templates}/helpers/html_helper_spec.rb +73 -16
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +39 -0
- data/spec/{generators → templates}/helpers/markup_helper_spec.rb +6 -7
- data/spec/templates/method_spec.rb +75 -0
- data/spec/templates/module_spec.rb +50 -0
- data/spec/templates/spec_helper.rb +33 -0
- data/spec/templates/tag_spec.rb +39 -0
- data/spec/templates/template_spec.rb +398 -0
- data/spec/verifier_spec.rb +51 -0
- data/spec/yard_spec.rb +46 -0
- data/templates/default/class/dot/setup.rb +6 -0
- data/templates/default/class/dot/superklass.erb +3 -0
- data/templates/default/class/html/constructor_details.erb +8 -0
- data/templates/default/class/html/setup.rb +1 -0
- data/templates/default/class/html/subclasses.erb +4 -0
- data/templates/default/class/setup.rb +29 -0
- data/templates/default/class/text/setup.rb +11 -0
- data/templates/default/class/text/subclasses.erb +5 -0
- data/templates/default/docstring/html/abstract.erb +4 -0
- data/templates/default/docstring/html/deprecated.erb +1 -0
- data/templates/default/docstring/html/index.erb +5 -0
- data/templates/default/docstring/html/note.erb +6 -0
- data/templates/default/docstring/html/text.erb +1 -0
- data/templates/default/docstring/html/todo.erb +6 -0
- data/templates/default/docstring/setup.rb +39 -0
- data/templates/default/docstring/text/abstract.erb +2 -0
- data/templates/default/docstring/text/deprecated.erb +2 -0
- data/templates/default/docstring/text/index.erb +2 -0
- data/templates/default/docstring/text/note.erb +4 -0
- data/templates/default/docstring/text/text.erb +1 -0
- data/templates/default/docstring/text/todo.erb +4 -0
- data/templates/default/fulldoc/html/css/common.css +1 -0
- data/templates/default/fulldoc/html/css/full_list.css +23 -0
- data/templates/default/fulldoc/html/css/style.css +261 -0
- data/templates/default/fulldoc/html/full_list.erb +36 -0
- data/templates/default/fulldoc/html/js/app.js +91 -0
- data/templates/default/fulldoc/html/js/full_list.js +39 -0
- data/templates/default/fulldoc/html/js/jquery.js +19 -0
- data/templates/default/fulldoc/html/setup.rb +86 -0
- data/templates/default/{uml → layout}/dot/header.erb +2 -2
- data/templates/default/layout/dot/setup.rb +14 -0
- data/templates/default/layout/html/breadcrumb.erb +11 -0
- data/templates/default/layout/html/footer.erb +5 -0
- data/templates/default/layout/html/headers.erb +13 -0
- data/templates/default/layout/html/index.erb +49 -0
- data/templates/default/layout/html/layout.erb +20 -0
- data/templates/default/layout/html/search.erb +5 -0
- data/templates/default/layout/html/setup.rb +58 -0
- data/templates/default/method/html/header.erb +14 -3
- data/templates/default/method/setup.rb +3 -0
- data/templates/default/method/text/header.erb +1 -1
- data/templates/default/method_details/html/header.erb +3 -0
- data/templates/default/method_details/html/method_signature.erb +17 -0
- data/templates/default/method_details/html/source.erb +10 -0
- data/templates/default/method_details/setup.rb +8 -0
- data/templates/default/method_details/text/header.erb +10 -0
- data/templates/default/method_details/text/method_signature.erb +12 -0
- data/templates/default/method_details/text/setup.rb +10 -0
- data/templates/default/module/dot/child.erb +1 -0
- data/templates/default/module/dot/dependencies.erb +3 -0
- data/templates/default/{uml/dot/subgraph.erb → module/dot/header.erb} +3 -3
- data/templates/default/{uml → module}/dot/info.erb +4 -4
- data/templates/default/module/dot/setup.rb +14 -0
- data/templates/default/module/html/attribute_details.erb +11 -0
- data/templates/default/module/html/attribute_summary.erb +8 -0
- data/templates/default/module/html/box_info.erb +32 -0
- data/templates/default/module/html/children.erb +8 -0
- data/templates/default/module/html/constant_summary.erb +13 -0
- data/templates/default/module/html/defines.erb +3 -0
- data/templates/default/module/html/header.erb +4 -4
- data/templates/default/module/html/inherited_constants.erb +8 -0
- data/templates/default/module/html/inherited_methods.erb +9 -0
- data/templates/default/module/html/item_summary.erb +20 -0
- data/templates/default/module/html/method_details_list.erb +8 -0
- data/templates/default/module/html/method_summary.erb +8 -0
- data/templates/default/module/html/methodmissing.erb +12 -0
- data/templates/default/module/html/pre_docstring.erb +1 -0
- data/templates/default/module/setup.rb +83 -0
- data/templates/default/module/text/children.erb +10 -0
- data/templates/default/module/text/class_meths_list.erb +8 -0
- data/templates/default/module/text/extends.erb +8 -0
- data/templates/default/module/text/header.erb +7 -0
- data/templates/default/module/text/includes.erb +8 -0
- data/templates/default/module/text/instance_meths_list.erb +8 -0
- data/templates/default/module/text/setup.rb +12 -0
- data/templates/default/root/dot/child.erb +3 -0
- data/templates/default/root/dot/setup.rb +5 -0
- data/templates/default/tags/html/example.erb +5 -16
- data/templates/default/tags/html/index.erb +3 -0
- data/templates/default/tags/html/option.erb +17 -20
- data/templates/default/tags/html/overload.erb +13 -0
- data/templates/default/tags/html/see.erb +5 -10
- data/templates/default/tags/html/tag.erb +20 -0
- data/templates/default/tags/setup.rb +50 -0
- data/templates/default/tags/text/example.erb +8 -10
- data/templates/default/tags/text/index.erb +1 -0
- data/templates/default/tags/text/option.erb +18 -3
- data/templates/default/tags/text/overload.erb +19 -0
- data/templates/default/tags/text/see.erb +8 -2
- data/templates/default/tags/text/tag.erb +13 -0
- metadata +142 -158
- data/bin/view_generator +0 -17
- data/docs/FAQ.markdown +0 -34
- data/docs/GENERATORS.markdown +0 -211
- data/lib/yard/generators/attributes_generator.rb +0 -22
- data/lib/yard/generators/base.rb +0 -305
- data/lib/yard/generators/class_generator.rb +0 -27
- data/lib/yard/generators/constants_generator.rb +0 -74
- data/lib/yard/generators/constructor_generator.rb +0 -25
- data/lib/yard/generators/deprecated_generator.rb +0 -15
- data/lib/yard/generators/docstring_generator.rb +0 -15
- data/lib/yard/generators/full_doc_generator.rb +0 -127
- data/lib/yard/generators/helpers/html_helper.rb +0 -196
- data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +0 -49
- data/lib/yard/generators/helpers/uml_helper.rb +0 -16
- data/lib/yard/generators/inheritance_generator.rb +0 -16
- data/lib/yard/generators/method_details_generator.rb +0 -18
- data/lib/yard/generators/method_generator.rb +0 -43
- data/lib/yard/generators/method_listing_generator.rb +0 -105
- data/lib/yard/generators/method_missing_generator.rb +0 -25
- data/lib/yard/generators/method_signature_generator.rb +0 -19
- data/lib/yard/generators/method_summary_generator.rb +0 -21
- data/lib/yard/generators/mixins_generator.rb +0 -21
- data/lib/yard/generators/module_generator.rb +0 -23
- data/lib/yard/generators/overloads_generator.rb +0 -20
- data/lib/yard/generators/quick_doc_generator.rb +0 -25
- data/lib/yard/generators/root_generator.rb +0 -32
- data/lib/yard/generators/source_generator.rb +0 -11
- data/lib/yard/generators/tags_generator.rb +0 -99
- data/lib/yard/generators/uml_generator.rb +0 -102
- data/lib/yard/generators/visibility_group_generator.rb +0 -26
- data/spec/generators/base_spec.rb +0 -64
- data/spec/generators/full_doc_generator_spec.rb +0 -29
- data/spec/generators/helpers/base_helper_spec.rb +0 -15
- data/spec/generators/quick_doc_generator_spec.rb +0 -13
- data/templates/default/attributes/html/header.erb +0 -47
- data/templates/default/attributes/text/header.erb +0 -10
- data/templates/default/class/html/header.erb +0 -4
- data/templates/default/constants/html/constants.erb +0 -9
- data/templates/default/constants/html/header.erb +0 -3
- data/templates/default/constants/html/included.erb +0 -9
- data/templates/default/constants/html/inherited.erb +0 -9
- data/templates/default/constructor/html/header.erb +0 -10
- data/templates/default/deprecated/html/main.erb +0 -6
- data/templates/default/deprecated/text/main.erb +0 -3
- data/templates/default/docstring/html/main.erb +0 -3
- data/templates/default/docstring/text/main.erb +0 -3
- data/templates/default/fulldoc/html/all_files.erb +0 -19
- data/templates/default/fulldoc/html/all_methods.erb +0 -26
- data/templates/default/fulldoc/html/all_namespaces.erb +0 -22
- data/templates/default/fulldoc/html/app.js +0 -18
- data/templates/default/fulldoc/html/custom.css +0 -1
- data/templates/default/fulldoc/html/file.erb +0 -16
- data/templates/default/fulldoc/html/footer.erb +0 -5
- data/templates/default/fulldoc/html/header.erb +0 -16
- data/templates/default/fulldoc/html/html_head.erb +0 -4
- data/templates/default/fulldoc/html/index.erb +0 -19
- data/templates/default/fulldoc/html/jquery.js +0 -11
- data/templates/default/fulldoc/html/style.css +0 -81
- data/templates/default/fulldoc/html/syntax_highlight.css +0 -24
- data/templates/default/inheritance/html/header.erb +0 -8
- data/templates/default/inheritance/text/header.erb +0 -3
- data/templates/default/method/html/aliases.erb +0 -6
- data/templates/default/method/html/title.erb +0 -3
- data/templates/default/method/text/title.erb +0 -1
- data/templates/default/methoddetails/html/header.erb +0 -8
- data/templates/default/methoddetails/html/method_header.erb +0 -3
- data/templates/default/methodmissing/html/header.erb +0 -12
- data/templates/default/methodsignature/html/main.erb +0 -10
- data/templates/default/methodsignature/text/main.erb +0 -8
- data/templates/default/methodsummary/html/header.erb +0 -5
- data/templates/default/methodsummary/html/included.erb +0 -9
- data/templates/default/methodsummary/html/inherited.erb +0 -9
- data/templates/default/methodsummary/html/summary.erb +0 -29
- data/templates/default/methodsummary/text/header.erb +0 -5
- data/templates/default/methodsummary/text/included.erb +0 -0
- data/templates/default/methodsummary/text/inherited.erb +0 -0
- data/templates/default/methodsummary/text/summary.erb +0 -6
- data/templates/default/mixins/html/header.erb +0 -4
- data/templates/default/overloads/html/header.erb +0 -8
- data/templates/default/overloads/text/header.erb +0 -8
- data/templates/default/quickdoc/html/header.erb +0 -15
- data/templates/default/quickdoc/text/header.erb +0 -12
- data/templates/default/root/html/header.erb +0 -4
- data/templates/default/source/html/main.erb +0 -15
- data/templates/default/source/text/main.erb +0 -4
- data/templates/default/tags/html/header.erb +0 -4
- data/templates/default/tags/html/param.erb +0 -21
- data/templates/default/tags/html/tags.erb +0 -23
- data/templates/default/tags/html/todo.erb +0 -8
- data/templates/default/tags/text/header.erb +0 -3
- data/templates/default/tags/text/param.erb +0 -9
- data/templates/default/tags/text/tags.erb +0 -7
- data/templates/default/uml/dot/child.erb +0 -1
- data/templates/default/uml/dot/dependencies.erb +0 -10
- data/templates/default/uml/dot/superclasses.erb +0 -9
- data/templates/default/uml/dot/unknown.erb +0 -3
- data/templates/default/uml/dot/unknown_child.erb +0 -1
- data/templates/default/visibilitygroup/html/header.erb +0 -6
- data/templates/javadoc/attributes/html/header.erb +0 -16
- data/templates/javadoc/class/html/header.erb +0 -4
- data/templates/javadoc/constants/html/constants.erb +0 -9
- data/templates/javadoc/constants/html/header.erb +0 -3
- data/templates/javadoc/constants/html/included.erb +0 -12
- data/templates/javadoc/constants/html/inherited.erb +0 -12
- data/templates/javadoc/constructor/html/header.erb +0 -10
- data/templates/javadoc/deprecated/html/main.erb +0 -0
- data/templates/javadoc/docstring/html/main.erb +0 -6
- data/templates/javadoc/fulldoc/html/all_methods.erb +0 -25
- data/templates/javadoc/fulldoc/html/all_namespaces.erb +0 -19
- data/templates/javadoc/fulldoc/html/app.js +0 -18
- data/templates/javadoc/fulldoc/html/header.erb +0 -15
- data/templates/javadoc/fulldoc/html/html_head.erb +0 -3
- data/templates/javadoc/fulldoc/html/index.erb +0 -18
- data/templates/javadoc/fulldoc/html/jquery.js +0 -11
- data/templates/javadoc/fulldoc/html/readme.erb +0 -15
- data/templates/javadoc/fulldoc/html/style.css +0 -22
- data/templates/javadoc/fulldoc/html/syntax_highlight.css +0 -21
- data/templates/javadoc/inheritance/html/header.erb +0 -6
- data/templates/javadoc/method/html/aliases.erb +0 -6
- data/templates/javadoc/method/html/header.erb +0 -4
- data/templates/javadoc/method/html/title.erb +0 -4
- data/templates/javadoc/methoddetails/html/header.erb +0 -8
- data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
- data/templates/javadoc/methodmissing/html/header.erb +0 -12
- data/templates/javadoc/methodsignature/html/main.erb +0 -8
- data/templates/javadoc/methodsummary/html/header.erb +0 -5
- data/templates/javadoc/methodsummary/html/included.erb +0 -12
- data/templates/javadoc/methodsummary/html/inherited.erb +0 -12
- data/templates/javadoc/methodsummary/html/summary.erb +0 -25
- data/templates/javadoc/mixins/html/header.erb +0 -5
- data/templates/javadoc/module/html/header.erb +0 -4
- data/templates/javadoc/source/html/main.erb +0 -15
- data/templates/javadoc/tags/html/header.erb +0 -5
- data/templates/javadoc/tags/html/see.erb +0 -8
- data/templates/javadoc/tags/html/tags.erb +0 -19
- data/templates/javadoc/visibilitygroup/html/header.erb +0 -5
@@ -0,0 +1,110 @@
|
|
1
|
+
module YARD
|
2
|
+
# Similar to a Proc, but runs a set of Ruby expressions using a small
|
3
|
+
# DSL to make tag lookups easier.
|
4
|
+
#
|
5
|
+
# The syntax is as follows:
|
6
|
+
# * All syntax is Ruby compatible
|
7
|
+
# * +object+ (+o+ for short) exist to access the object being verified
|
8
|
+
# * +@TAGNAME+ is translated into +object.tag('TAGNAME')+
|
9
|
+
# * +@@TAGNAME+ is translated into +object.tags('TAGNAME')+
|
10
|
+
# * +object+ can be omitted as target for method calls (it is implied)
|
11
|
+
#
|
12
|
+
# @example Create a verifier to check for objects that don't have @private tags
|
13
|
+
# verifier = Verifier.new('!@private')
|
14
|
+
# verifier.call(object) # => true (no @private tag)
|
15
|
+
# @example Create a verifier to find any return tag with an empty description
|
16
|
+
# Verifier.new('@return.text.empty?')
|
17
|
+
# # Equivalent to:
|
18
|
+
# Verifier.new('object.tag(:return).text.empty?')
|
19
|
+
# @example Check if there are any @param tags
|
20
|
+
# Verifier.new('@@param.empty?')
|
21
|
+
# # Equivalent to:
|
22
|
+
# Verifier.new('object.tags(:param).empty?')
|
23
|
+
# @example Using +object+ or +o+ to look up object attributes directly
|
24
|
+
# Verifier.new('object.docstring == "hello world"')
|
25
|
+
# # Equivalent to:
|
26
|
+
# Verifier.new('o.docstring == "hello world"')
|
27
|
+
# @example Without using +object+ or +o+
|
28
|
+
# Verifier.new('tag(:return).size == 1 || has_tag?(:author)')
|
29
|
+
# @example Specifying multiple expressions
|
30
|
+
# Verifier.new('@return', '@param', '@yield')
|
31
|
+
# # Equivalent to:
|
32
|
+
# Verifier.new('@return && @param && @yield')
|
33
|
+
class Verifier
|
34
|
+
# Creates a verifier from a set of expressions
|
35
|
+
#
|
36
|
+
# @param [Array<String>] expressions a list of Ruby expressions to
|
37
|
+
# parse.
|
38
|
+
def initialize(*expressions)
|
39
|
+
create_method_from_expressions(expressions.flatten)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Passes any method calls to the object from the {#call}
|
43
|
+
def method_missing(sym, *args, &block)
|
44
|
+
if object.respond_to?(sym)
|
45
|
+
object.send(sym, *args, &block)
|
46
|
+
else
|
47
|
+
super
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Tests the expressions on the object
|
52
|
+
#
|
53
|
+
# @param [CodeObjects::Base] object the object to verify
|
54
|
+
# @return [Boolean] the result of the expressions
|
55
|
+
def call(object)
|
56
|
+
modify_nilclass
|
57
|
+
@object = object
|
58
|
+
retval = __execute ? true : false
|
59
|
+
unmodify_nilclass
|
60
|
+
retval
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
# @return [CodeObjects::Base] the current object being tested
|
66
|
+
attr_reader :object
|
67
|
+
alias o object
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# Modifies nil to not throw NoMethodErrors. This allows
|
72
|
+
# syntax like object.tag(:return).text to work if the #tag
|
73
|
+
# call returns nil, which means users don't need to perform
|
74
|
+
# stringent nil checking
|
75
|
+
#
|
76
|
+
# @return [nil]
|
77
|
+
def modify_nilclass
|
78
|
+
NilClass.send(:define_method, :method_missing) {|*args| }
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns the state of NilClass back to normal
|
82
|
+
# @return [nil]
|
83
|
+
def unmodify_nilclass
|
84
|
+
NilClass.send(:undef_method, :method_missing)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Creates the +__execute+ method by evaluating the expressions
|
88
|
+
# as Ruby code
|
89
|
+
# @return [nil]
|
90
|
+
def create_method_from_expressions(exprs)
|
91
|
+
expr = exprs.flatten.map {|e| "(#{parse_expression(e)})" }.join(" && ")
|
92
|
+
|
93
|
+
instance_eval(<<-eof, __FILE__, __LINE__ + 1)
|
94
|
+
def __execute; #{expr}; end
|
95
|
+
eof
|
96
|
+
end
|
97
|
+
|
98
|
+
# Parses a single expression, handling some of the DSL syntax.
|
99
|
+
#
|
100
|
+
# The syntax "@tag" should be turned into object.tag(:tag),
|
101
|
+
# and "@@tag" should be turned into object.tags(:tag)
|
102
|
+
#
|
103
|
+
# @return [String] the parsed expression
|
104
|
+
def parse_expression(expr)
|
105
|
+
expr = expr.gsub(/@@(\w+)/, 'object.tags("\1")')
|
106
|
+
expr = expr.gsub(/@(\w+)/, 'object.tag("\1")')
|
107
|
+
expr
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/spec/cli/yardoc_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe YARD::CLI::Yardoc do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should alias --main to the --readme flag" do
|
18
|
-
readme = File.join(File.dirname(__FILE__),'..','..','README.
|
18
|
+
readme = File.join(File.dirname(__FILE__),'..','..','README.md')
|
19
19
|
|
20
20
|
@yardoc.optparse('--main', readme)
|
21
21
|
@yardoc.options[:readme].should == readme.to_sym
|
@@ -68,6 +68,7 @@ describe YARD::CLI::Yardoc do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should accept globs as extra files" do
|
71
|
+
Dir.should_receive(:glob).with('README*').and_return []
|
71
72
|
Dir.should_receive(:glob).with('*.txt').and_return ['a.txt', 'b.txt']
|
72
73
|
File.should_receive(:file?).with('a.txt').and_return(true)
|
73
74
|
File.should_receive(:file?).with('b.txt').and_return(true)
|
@@ -80,4 +81,25 @@ describe YARD::CLI::Yardoc do
|
|
80
81
|
@yardoc.optparse
|
81
82
|
@yardoc.files.should == %w( lib/**/*.rb )
|
82
83
|
end
|
84
|
+
|
85
|
+
it "should accept a --query" do
|
86
|
+
@yardoc.optparse *%w( --query @return )
|
87
|
+
@yardoc.options[:verifier].should be_a(Verifier)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should accept multiple --query arguments" do
|
91
|
+
obj = mock(:object)
|
92
|
+
obj.should_receive(:tag).ordered.with('return').and_return(true)
|
93
|
+
obj.should_receive(:tag).ordered.with('tag').and_return(false)
|
94
|
+
@yardoc.optparse *%w( --query @return --query @tag )
|
95
|
+
@yardoc.options[:verifier].should be_a(Verifier)
|
96
|
+
@yardoc.options[:verifier].call(obj).should == false
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should accept --no-private" do
|
100
|
+
obj = mock(:object)
|
101
|
+
obj.should_receive(:tag).ordered.with('private').and_return(true)
|
102
|
+
@yardoc.optparse *%w( --no-private )
|
103
|
+
@yardoc.options[:verifier].call(obj).should == false
|
104
|
+
end
|
83
105
|
end
|
@@ -204,4 +204,12 @@ describe YARD::CodeObjects::Base do
|
|
204
204
|
Registry.at(:X).line.should == 4
|
205
205
|
Registry.at(:X).files.should == [['(stdin)', 4], ['(stdin)', 1], ['(stdin)', 2]]
|
206
206
|
end
|
207
|
+
|
208
|
+
describe '#format' do
|
209
|
+
it "should send to Templates.render" do
|
210
|
+
object = MethodObject.new(:root, :method)
|
211
|
+
Templates::Engine.should_receive(:render).with(:x => 1, :object => object)
|
212
|
+
object.format :x => 1
|
213
|
+
end
|
214
|
+
end
|
207
215
|
end
|
@@ -1,188 +1,198 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe YARD::CodeObjects::ClassObject do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
4
|
+
describe '#inheritance_tree' do
|
5
|
+
before(:all) do
|
6
|
+
Registry.clear
|
7
|
+
@mixin = ModuleObject.new(:root, :SomeMixin)
|
8
|
+
@mixin2 = ModuleObject.new(:root, :SomeMixin2)
|
9
|
+
@mixin3 = ModuleObject.new(:root, :SomeMixin3)
|
10
|
+
@mixin4 = ModuleObject.new(:root, :SomeMixin4)
|
11
|
+
@mixin2.instance_mixins << @mixin3
|
12
|
+
@superyard = ClassObject.new(:root, :SuperYard)
|
13
|
+
@superyard.superclass = P("String")
|
14
|
+
@superyard.instance_mixins << @mixin2
|
15
|
+
@superyard.class_mixins << @mixin4
|
16
|
+
@yard = ClassObject.new(:root, :YARD)
|
17
|
+
@yard.superclass = @superyard
|
18
|
+
@yard.instance_mixins << @mixin
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should show the proper inheritance tree" do
|
22
|
+
@yard.inheritance_tree.should == [@yard, @superyard, P(:String)]
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should show proper inheritance tree when mixins are included" do
|
26
|
+
@yard.inheritance_tree(true).should == [@yard, @mixin, @superyard, @mixin2, @mixin3, P(:String)]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not modify the object's mixin list when mixins are included" do
|
30
|
+
@class1 = ClassObject.new(:root, :A)
|
31
|
+
@class2 = ClassObject.new(:root, :B)
|
32
|
+
@class2.superclass = @class1
|
33
|
+
|
34
|
+
@class2.inheritance_tree(true)
|
35
|
+
@class2.mixins.should == []
|
36
|
+
end
|
26
37
|
end
|
27
|
-
end
|
28
38
|
|
29
|
-
describe
|
30
|
-
|
31
|
-
|
39
|
+
describe "#meths / #inherited_meths" do
|
40
|
+
before(:all) do
|
41
|
+
Registry.clear
|
32
42
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
Parser::SourceParser.parse_string <<-eof
|
44
|
+
class SuperYard < String
|
45
|
+
def foo; end
|
46
|
+
def foo2; end
|
47
|
+
def bar; end
|
48
|
+
def middle; end
|
49
|
+
protected :foo2
|
50
|
+
private
|
51
|
+
def self.bar; end
|
52
|
+
end
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
class MiddleYard < SuperYard
|
55
|
+
def middle; end
|
56
|
+
end
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
class YARD < MiddleYard
|
59
|
+
def mymethod; end
|
60
|
+
def bar; end
|
61
|
+
end
|
62
|
+
eof
|
63
|
+
end
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
it "should show inherited methods by default" do
|
66
|
+
meths = P(:YARD).meths
|
67
|
+
meths.should include(P("YARD#mymethod"))
|
68
|
+
meths.should include(P("SuperYard#foo"))
|
69
|
+
meths.should include(P("SuperYard#foo2"))
|
70
|
+
meths.should include(P("SuperYard.bar"))
|
71
|
+
end
|
62
72
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
it "should allow :inherited to be set to false" do
|
74
|
+
meths = P(:YARD).meths(:inherited => false)
|
75
|
+
meths.should include(P("YARD#mymethod"))
|
76
|
+
meths.should_not include(P("SuperYard#foo"))
|
77
|
+
meths.should_not include(P("SuperYard#foo2"))
|
78
|
+
meths.should_not include(P("SuperYard.bar"))
|
79
|
+
end
|
70
80
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
81
|
+
it "should not show overridden methods" do
|
82
|
+
meths = P(:YARD).meths
|
83
|
+
meths.should include(P("YARD#bar"))
|
84
|
+
meths.should_not include(P("SuperYard#bar"))
|
75
85
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
86
|
+
meths = P(:YARD).inherited_meths
|
87
|
+
meths.should_not include(P("YARD#bar"))
|
88
|
+
meths.should_not include(P("YARD#mymethod"))
|
89
|
+
meths.should include(P("SuperYard#foo"))
|
90
|
+
meths.should include(P("SuperYard#foo2"))
|
91
|
+
meths.should include(P("SuperYard.bar"))
|
92
|
+
end
|
83
93
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
94
|
+
it "should not show inherited methods overridden by other subclasses" do
|
95
|
+
meths = P(:YARD).inherited_meths
|
96
|
+
meths.should include(P('MiddleYard#middle'))
|
97
|
+
meths.should_not include(P('SuperYard#middle'))
|
98
|
+
end
|
88
99
|
end
|
89
|
-
end
|
90
100
|
|
91
|
-
describe
|
92
|
-
|
93
|
-
|
101
|
+
describe "#constants / #inherited_constants" do
|
102
|
+
before(:all) do
|
103
|
+
Registry.clear
|
94
104
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
105
|
+
Parser::SourceParser.parse_string <<-eof
|
106
|
+
class YARD
|
107
|
+
CONST1 = 1
|
108
|
+
CONST2 = "hello"
|
109
|
+
CONST4 = 0
|
110
|
+
end
|
101
111
|
|
102
|
-
|
103
|
-
|
104
|
-
|
112
|
+
class SUPERYARD < YARD
|
113
|
+
CONST4 = 5
|
114
|
+
end
|
105
115
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
116
|
+
class SubYard < SUPERYARD
|
117
|
+
CONST2 = "hi"
|
118
|
+
CONST3 = "foo"
|
119
|
+
end
|
120
|
+
eof
|
121
|
+
end
|
112
122
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
123
|
+
it "should list inherited constants by default" do
|
124
|
+
consts = P(:SubYard).constants
|
125
|
+
consts.should include(P("YARD::CONST1"))
|
126
|
+
consts.should include(P("SubYard::CONST3"))
|
117
127
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
128
|
+
consts = P(:SubYard).inherited_constants
|
129
|
+
consts.should include(P("YARD::CONST1"))
|
130
|
+
consts.should_not include(P("YARD::CONST2"))
|
131
|
+
consts.should_not include(P("SubYard::CONST2"))
|
132
|
+
consts.should_not include(P("SubYard::CONST3"))
|
133
|
+
end
|
124
134
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
135
|
+
it "should not list inherited constants if turned off" do
|
136
|
+
consts = P(:SubYard).constants(:inherited => false)
|
137
|
+
consts.should_not include(P("YARD::CONST1"))
|
138
|
+
consts.should include(P("SubYard::CONST3"))
|
139
|
+
end
|
130
140
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
141
|
+
it "should not include an inherited constant if it is overridden by the object" do
|
142
|
+
consts = P(:SubYard).constants
|
143
|
+
consts.should include(P("SubYard::CONST2"))
|
144
|
+
consts.should_not include(P("YARD::CONST2"))
|
145
|
+
end
|
136
146
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
147
|
+
it "should not include an inherited constant if it is overridden by another subclass" do
|
148
|
+
consts = P(:SubYard).inherited_constants
|
149
|
+
consts.should include(P("SUPERYARD::CONST4"))
|
150
|
+
consts.should_not include(P("YARD::CONST4"))
|
151
|
+
end
|
142
152
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
153
|
+
it "should not set a superclass on Object class" do
|
154
|
+
o = ClassObject.new(:root, :Object)
|
155
|
+
o.superclass.should be_nil
|
156
|
+
end
|
147
157
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
158
|
+
it "should raise ArgumentError if superclass == self" do
|
159
|
+
lambda do
|
160
|
+
o = ClassObject.new(:root, :Object) do |o|
|
161
|
+
o.superclass = :Object
|
162
|
+
end
|
163
|
+
end.should raise_error(ArgumentError)
|
164
|
+
end
|
155
165
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
166
|
+
it "should tell the world if it is an exception class" do
|
167
|
+
o = ClassObject.new(:root, :MyClass)
|
168
|
+
o2 = ClassObject.new(:root, :OtherClass)
|
169
|
+
o2.superclass = :SystemCallError
|
170
|
+
o3 = ClassObject.new(:root, :StandardError)
|
171
|
+
o3.superclass = :Object
|
172
|
+
o4 = ClassObject.new(:root, :Object)
|
163
173
|
|
164
|
-
|
165
|
-
|
174
|
+
o.superclass = :Object
|
175
|
+
o.is_exception?.should == false
|
166
176
|
|
167
|
-
|
168
|
-
|
177
|
+
o.superclass = :Exception
|
178
|
+
o.is_exception?.should == true
|
169
179
|
|
170
|
-
|
171
|
-
|
180
|
+
o.superclass = :NoMethodError
|
181
|
+
o.is_exception?.should == true
|
172
182
|
|
173
|
-
|
174
|
-
|
183
|
+
o.superclass = o2
|
184
|
+
o.is_exception?.should == true
|
175
185
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
it "should not raise ArgumentError if superclass is proxy in different namespace" do
|
181
|
-
lambda do
|
182
|
-
o = ClassObject.new(:root, :X) do |o|
|
183
|
-
o.superclass = P('OTHER::X')
|
184
|
-
end
|
185
|
-
end.should_not raise_error(ArgumentError)
|
186
|
-
end
|
187
|
-
end
|
186
|
+
o.superclass = o3
|
187
|
+
o.is_exception?.should == true
|
188
|
+
end
|
188
189
|
|
190
|
+
it "should not raise ArgumentError if superclass is proxy in different namespace" do
|
191
|
+
lambda do
|
192
|
+
o = ClassObject.new(:root, :X) do |o|
|
193
|
+
o.superclass = P('OTHER::X')
|
194
|
+
end
|
195
|
+
end.should_not raise_error(ArgumentError)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|