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
@@ -1,7 +1,36 @@
|
|
1
1
|
module YARD::CodeObjects
|
2
|
+
# Represents a Ruby method in source
|
2
3
|
class MethodObject < Base
|
3
|
-
|
4
|
+
# The visibility of the method (+:public:+, +:protected+, +:private+)
|
5
|
+
#
|
6
|
+
# @return [Symbol] the method visibility
|
7
|
+
attr_accessor :visibility
|
4
8
|
|
9
|
+
# The scope of the method (+:class+ or +:instance+)
|
10
|
+
#
|
11
|
+
# @return [Symbol] the scope
|
12
|
+
attr_accessor :scope
|
13
|
+
|
14
|
+
# Whether the object is explicitly defined in source or whether it was
|
15
|
+
# inferred by a handler. For instance, attribute methods are generally
|
16
|
+
# inferred and therefore not explicitly defined in source.
|
17
|
+
#
|
18
|
+
# @return [Boolean] whether the object is explicitly defined in source.
|
19
|
+
attr_accessor :explicit
|
20
|
+
|
21
|
+
# Returns the list of parameters parsed out of the method signature
|
22
|
+
# with their default values.
|
23
|
+
#
|
24
|
+
# @return [Array<Array(String, String)>] a list of parameter names followed
|
25
|
+
# by their default values (or nil)
|
26
|
+
attr_accessor :parameters
|
27
|
+
|
28
|
+
# Creates a new method object in +namespace+ with +name+ and an instance
|
29
|
+
# or class +scope+
|
30
|
+
#
|
31
|
+
# @param [NamespaceObject] namespace the namespace
|
32
|
+
# @param [String, Symbol] name the method name
|
33
|
+
# @param [Symbol] scope +:instance+ or +:class+
|
5
34
|
def initialize(namespace, name, scope = :instance)
|
6
35
|
self.visibility = :public
|
7
36
|
self.scope = scope
|
@@ -10,6 +39,8 @@ module YARD::CodeObjects
|
|
10
39
|
super
|
11
40
|
end
|
12
41
|
|
42
|
+
# Changes the scope of an object from :instance or :class
|
43
|
+
# @param [Symbol] v the new scope
|
13
44
|
def scope=(v)
|
14
45
|
reregister = @scope ? true : false
|
15
46
|
YARD::Registry.delete(self) if reregister
|
@@ -17,20 +48,31 @@ module YARD::CodeObjects
|
|
17
48
|
YARD::Registry.register(self) if reregister
|
18
49
|
end
|
19
50
|
|
51
|
+
# Sets the visibility
|
52
|
+
# @param [Symbol] v the new visibility (:public, :private, or :protected)
|
20
53
|
def visibility=(v) @visibility = v.to_sym end
|
21
54
|
|
55
|
+
# Tests if the object is defined as an attribute in the namespace
|
56
|
+
# @return [Boolean] whether the object is an attribute
|
22
57
|
def is_attribute?
|
23
58
|
namespace.attributes[scope].has_key? name.to_s.gsub(/=$/, '')
|
24
59
|
end
|
25
60
|
|
61
|
+
# Tests if the object is defined as an alias of another method
|
62
|
+
# @return [Boolean] whether the object is an alias
|
26
63
|
def is_alias?
|
27
64
|
namespace.aliases.has_key? self
|
28
65
|
end
|
29
66
|
|
67
|
+
# Tests boolean {#explicit} value.
|
68
|
+
#
|
69
|
+
# @return [Boolean] whether the method is explicitly defined in source
|
30
70
|
def is_explicit?
|
31
71
|
explicit ? true : false
|
32
72
|
end
|
33
73
|
|
74
|
+
# Returns all alias names of the object
|
75
|
+
# @return [Array<Symbol>] the alias names
|
34
76
|
def aliases
|
35
77
|
list = []
|
36
78
|
namespace.aliases.each do |o, aname|
|
@@ -39,6 +81,9 @@ module YARD::CodeObjects
|
|
39
81
|
list
|
40
82
|
end
|
41
83
|
|
84
|
+
# Override path handling for instance methods in the root namespace
|
85
|
+
# (they should still have a separator as a prefix).
|
86
|
+
# @return [String] the path of a method
|
42
87
|
def path
|
43
88
|
if !namespace || namespace.path == ""
|
44
89
|
sep + super
|
@@ -47,12 +92,25 @@ module YARD::CodeObjects
|
|
47
92
|
end
|
48
93
|
end
|
49
94
|
|
95
|
+
# Returns the name of the object.
|
96
|
+
#
|
97
|
+
# @example The name of an instance method (with prefix)
|
98
|
+
# an_instance_method.name(true) # => "#mymethod"
|
99
|
+
# @example The name of a class method (with prefix)
|
100
|
+
# a_class_method.name(true) # => "mymethod"
|
101
|
+
# @param [Boolean] prefix whether or not to show the prefix
|
102
|
+
# @return [String] returns {#sep} + +name+ for an instance method if
|
103
|
+
# prefix is true
|
104
|
+
# @return [Symbol] the name without {#sep} if prefix is set to false
|
50
105
|
def name(prefix = false)
|
51
|
-
|
106
|
+
prefix ? (sep == ISEP ? "#{sep}#{super}" : super.to_s) : super
|
52
107
|
end
|
53
108
|
|
54
109
|
protected
|
55
110
|
|
111
|
+
# Override separator to differentiate between class and instance
|
112
|
+
# methods.
|
113
|
+
# @return [String] "#" for an instance method, "." for class
|
56
114
|
def sep
|
57
115
|
if scope == :class
|
58
116
|
namespace && namespace != YARD::Registry.root ? CSEP : NSEP
|
@@ -1,5 +1,11 @@
|
|
1
1
|
module YARD::CodeObjects
|
2
|
+
# Represents a Ruby module.
|
2
3
|
class ModuleObject < NamespaceObject
|
4
|
+
# Returns the inheritance tree of mixins.
|
5
|
+
#
|
6
|
+
# @param [Boolean] include_mods if true, will include mixed in
|
7
|
+
# modules (which is likely what is wanted).
|
8
|
+
# @return [Array<NamespaceObject>] a list of namespace objects
|
3
9
|
def inheritance_tree(include_mods = false)
|
4
10
|
return [self] unless include_mods
|
5
11
|
[self] + mixins(:instance).map do |m|
|
@@ -1,8 +1,54 @@
|
|
1
1
|
module YARD::CodeObjects
|
2
|
+
# A "namespace" is any object that can store other objects within itself.
|
3
|
+
# The two main Ruby objects that can act as namespaces are modules
|
4
|
+
# ({ModuleObject}) and classes ({ClassObject}).
|
2
5
|
class NamespaceObject < Base
|
3
|
-
attr_reader :
|
4
|
-
attr_reader :
|
6
|
+
attr_reader :constants, :meths, :cvars, :mixins, :child
|
7
|
+
attr_reader :class_attributes, :instance_attributes
|
8
|
+
attr_reader :included_constants, :included_meths
|
9
|
+
|
10
|
+
# The list of objects defined in this namespace
|
11
|
+
# @return [Array<Base>] a list of objects
|
12
|
+
attr_reader :children
|
13
|
+
|
14
|
+
# A hash containing two keys, class and instance, each containing
|
15
|
+
# the attribute name with a { :read, :write } hash for the read and
|
16
|
+
# write objects respectively.
|
17
|
+
#
|
18
|
+
# @example The attributes of an object
|
19
|
+
# >> Registry.at('YARD::Docstring').attributes
|
20
|
+
# => {
|
21
|
+
# :class => { },
|
22
|
+
# :instance => {
|
23
|
+
# :ref_tags => {
|
24
|
+
# :read => #<yardoc method YARD::Docstring#ref_tags>,
|
25
|
+
# :write => nil
|
26
|
+
# },
|
27
|
+
# :object => {
|
28
|
+
# :read => #<yardoc method YARD::Docstring#object>,
|
29
|
+
# :write => #<yardoc method YARD::Docstring#object=>
|
30
|
+
# },
|
31
|
+
# ...
|
32
|
+
# }
|
33
|
+
# }
|
34
|
+
# @return [Hash] a list of methods
|
35
|
+
attr_reader :attributes
|
36
|
+
|
37
|
+
# A hash containing two keys, :class and :instance, each containing
|
38
|
+
# a hash of objects and their alias names.
|
39
|
+
# @return [Hash] a list of methods
|
40
|
+
attr_reader :aliases
|
41
|
+
|
42
|
+
# Class mixins
|
43
|
+
# @return [Array<ModuleObject>] a list of mixins
|
44
|
+
attr_reader :class_mixins
|
45
|
+
|
46
|
+
# Instance mixins
|
47
|
+
# @return [Array<ModuleObject>] a list of mixins
|
48
|
+
attr_reader :instance_mixins
|
5
49
|
|
50
|
+
# Creates a new namespace object inside +namespace+ with +name+.
|
51
|
+
# @see Base#initialize
|
6
52
|
def initialize(namespace, name, *args, &block)
|
7
53
|
@children = CodeObjectList.new(self)
|
8
54
|
@class_mixins = CodeObjectList.new(self)
|
@@ -12,14 +58,26 @@ module YARD::CodeObjects
|
|
12
58
|
super
|
13
59
|
end
|
14
60
|
|
61
|
+
# Only the class attributes
|
62
|
+
# @return [Hash] a list of method names and their read/write objects
|
63
|
+
# @see #attributes
|
15
64
|
def class_attributes
|
16
65
|
attributes[:class]
|
17
66
|
end
|
18
67
|
|
68
|
+
# Only the instance attributes
|
69
|
+
# @return [Hash] a list of method names and their read/write objects
|
70
|
+
# @see #attributes
|
19
71
|
def instance_attributes
|
20
72
|
attributes[:instance]
|
21
73
|
end
|
22
74
|
|
75
|
+
# Looks for a child that matches the attributes specified by +opts+.
|
76
|
+
#
|
77
|
+
# @example Finds a child by name and scope
|
78
|
+
# namespace.child(:name => :to_s, :scope => :instance)
|
79
|
+
# # => #<yardoc method MyClass#to_s>
|
80
|
+
# @return [Base, nil] the first matched child object, or nil
|
23
81
|
def child(opts = {})
|
24
82
|
if !opts.is_a?(Hash)
|
25
83
|
children.find {|o| o.name == opts.to_sym }
|
@@ -33,6 +91,20 @@ module YARD::CodeObjects
|
|
33
91
|
end
|
34
92
|
end
|
35
93
|
|
94
|
+
# Returns all methods that match the attributes specified by +opts+. If
|
95
|
+
# no options are provided, returns all methods.
|
96
|
+
#
|
97
|
+
# @example Finds all private and protected class methods
|
98
|
+
# namespace.meths(:visibility => [:private, :protected], :scope => :class)
|
99
|
+
# # => [#<yardoc method MyClass.privmeth>, #<yardoc method MyClass.protmeth>]
|
100
|
+
# @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
|
101
|
+
# :protected]) the visibility of the methods to list. Can be an array or
|
102
|
+
# single value.
|
103
|
+
# @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
|
104
|
+
# scope of the methods to list. Can be an array or single value.
|
105
|
+
# @option opts [Boolean] :included (true) whether to include mixed in
|
106
|
+
# methods in the list.
|
107
|
+
# @return [Array<MethodObject>] a list of method objects
|
36
108
|
def meths(opts = {})
|
37
109
|
opts = SymbolHash[
|
38
110
|
:visibility => [:public, :private, :protected],
|
@@ -52,6 +124,18 @@ module YARD::CodeObjects
|
|
52
124
|
ourmeths + (opts[:included] ? included_meths(opts) : [])
|
53
125
|
end
|
54
126
|
|
127
|
+
# Returns methods included from any mixins that match the attributes
|
128
|
+
# specified by +opts+. If no options are specified, returns all included
|
129
|
+
# methods.
|
130
|
+
#
|
131
|
+
# @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
|
132
|
+
# :protected]) the visibility of the methods to list. Can be an array or
|
133
|
+
# single value.
|
134
|
+
# @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
|
135
|
+
# scope of the methods to list. Can be an array or single value.
|
136
|
+
# @option opts [Boolean] :included (true) whether to include mixed in
|
137
|
+
# methods in the list.
|
138
|
+
# @see #meths
|
55
139
|
def included_meths(opts = {})
|
56
140
|
opts = SymbolHash[:scope => [:instance, :class]].update(opts)
|
57
141
|
[opts[:scope]].flatten.map do |scope|
|
@@ -66,12 +150,19 @@ module YARD::CodeObjects
|
|
66
150
|
end.flatten
|
67
151
|
end
|
68
152
|
|
153
|
+
# Returns all constants in the namespace
|
154
|
+
#
|
155
|
+
# @option opts [Boolean] :included (true) whether or not to include
|
156
|
+
# mixed in constants in list
|
157
|
+
# @return [Array<ConstantObject>] a list of constant objects
|
69
158
|
def constants(opts = {})
|
70
159
|
opts = SymbolHash[:included => true].update(opts)
|
71
160
|
consts = children.select {|o| o.is_a? ConstantObject }
|
72
161
|
consts + (opts[:included] ? included_constants : [])
|
73
162
|
end
|
74
163
|
|
164
|
+
# Returns constants included from any mixins
|
165
|
+
# @return [Array<ConstantObject>] a list of constant objects
|
75
166
|
def included_constants
|
76
167
|
instance_mixins.reverse.inject([]) do |list, mixin|
|
77
168
|
if mixin.respond_to? :constants
|
@@ -84,10 +175,16 @@ module YARD::CodeObjects
|
|
84
175
|
end
|
85
176
|
end
|
86
177
|
|
178
|
+
# Returns class variables defined in this namespace.
|
179
|
+
# @return [Array<ClassVariableObject>] a list of class variable objects
|
87
180
|
def cvars
|
88
181
|
children.select {|o| o.is_a? ClassVariableObject }
|
89
182
|
end
|
90
183
|
|
184
|
+
# Returns for specific scopes. If no scopes are provided, returns all mixins.
|
185
|
+
# @param [Array<Symbol>] scopes a list of scopes (:class, :instance) to
|
186
|
+
# return mixins for. If this is empty, all scopes will be returned.
|
187
|
+
# @return [Array<ModuleObject>] a list of mixins
|
91
188
|
def mixins(*scopes)
|
92
189
|
return class_mixins if scopes == [:class]
|
93
190
|
return instance_mixins if scopes == [:instance]
|
@@ -1,14 +1,30 @@
|
|
1
1
|
module YARD
|
2
2
|
module CodeObjects
|
3
|
+
# A special type of +NoMethodError+ when raised from a {Proxy}
|
3
4
|
class ProxyMethodError < NoMethodError; end
|
4
5
|
|
5
|
-
class
|
6
|
+
# The Proxy class is a way to lazily resolve code objects in
|
7
|
+
# cases where the object may not yet exist. A proxy simply stores
|
8
|
+
# an unresolved path until a method is called on the object, at which
|
9
|
+
# point it does a lookup using {Registry#resolve}. If the object is
|
10
|
+
# not found, a warning is raised and {ProxyMethodError} might be raised.
|
11
|
+
#
|
12
|
+
# @example Creates a Proxy to the String class from a module
|
13
|
+
# # When the String class is parsed this method will
|
14
|
+
# # begin to act like the String ClassObject.
|
15
|
+
# Proxy.new(mymoduleobj, "String")
|
16
|
+
# @see Registry#resolve
|
17
|
+
# @see ProxyMethodError
|
18
|
+
class Proxy
|
6
19
|
def self.===(other) other.is_a?(self) end
|
7
20
|
|
8
21
|
attr_reader :namespace, :name
|
9
22
|
alias_method :parent, :namespace
|
10
23
|
|
11
|
-
#
|
24
|
+
# Creates a new Proxy
|
25
|
+
#
|
26
|
+
# @raise [ArgumentError] if namespace is not a NamespaceObject
|
27
|
+
# @return [Proxy] self
|
12
28
|
def initialize(namespace, name)
|
13
29
|
namespace = Registry.root if !namespace || namespace == :root
|
14
30
|
|
@@ -39,7 +55,9 @@ module YARD
|
|
39
55
|
@namespace = Registry.root
|
40
56
|
end
|
41
57
|
end
|
42
|
-
|
58
|
+
|
59
|
+
# Returns a text representation of the Proxy
|
60
|
+
# @return [String] the object's #inspect method or P(OBJECTPATH)
|
43
61
|
def inspect
|
44
62
|
if obj = to_obj
|
45
63
|
obj.inspect
|
@@ -48,6 +66,11 @@ module YARD
|
|
48
66
|
end
|
49
67
|
end
|
50
68
|
|
69
|
+
# If the proxy resolves to an object, returns its path, otherwise
|
70
|
+
# guesses at the correct path using the original namespace and name.
|
71
|
+
#
|
72
|
+
# @return [String] the assumed path of the proxy (or the real path
|
73
|
+
# of the resolved object)
|
51
74
|
def path
|
52
75
|
if obj = to_obj
|
53
76
|
obj.path
|
@@ -69,6 +92,7 @@ module YARD
|
|
69
92
|
end
|
70
93
|
alias to_s path
|
71
94
|
|
95
|
+
# @return [Boolean]
|
72
96
|
def is_a?(klass)
|
73
97
|
if obj = to_obj
|
74
98
|
obj.is_a?(klass)
|
@@ -77,6 +101,7 @@ module YARD
|
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
104
|
+
# @return [Boolean]
|
80
105
|
def ===(other)
|
81
106
|
if obj = to_obj
|
82
107
|
obj === other
|
@@ -85,6 +110,7 @@ module YARD
|
|
85
110
|
end
|
86
111
|
end
|
87
112
|
|
113
|
+
# @return [Boolean]
|
88
114
|
def <=>(other)
|
89
115
|
if other.respond_to? :path
|
90
116
|
path <=> other.path
|
@@ -93,6 +119,7 @@ module YARD
|
|
93
119
|
end
|
94
120
|
end
|
95
121
|
|
122
|
+
# @return [Boolean]
|
96
123
|
def ==(other)
|
97
124
|
if other.respond_to? :path
|
98
125
|
path == other.path
|
@@ -101,6 +128,9 @@ module YARD
|
|
101
128
|
end
|
102
129
|
end
|
103
130
|
|
131
|
+
# Returns the class name of the object the proxy is mimicking, if
|
132
|
+
# resolved. Otherwise returns +Proxy+.
|
133
|
+
# @return [Class] the resolved object's class or +Proxy+
|
104
134
|
def class
|
105
135
|
if obj = to_obj
|
106
136
|
obj.class
|
@@ -109,6 +139,11 @@ module YARD
|
|
109
139
|
end
|
110
140
|
end
|
111
141
|
|
142
|
+
# Returns the type of the proxy. If it cannot be resolved at the
|
143
|
+
# time of the call, it will either return the inferred proxy type
|
144
|
+
# (see {#type=}) or +:proxy+
|
145
|
+
# @return [Symbol] the Proxy's type
|
146
|
+
# @see #type=
|
112
147
|
def type
|
113
148
|
if obj = to_obj
|
114
149
|
obj.type
|
@@ -116,16 +151,23 @@ module YARD
|
|
116
151
|
Registry.proxy_types[path] || :proxy
|
117
152
|
end
|
118
153
|
end
|
154
|
+
|
155
|
+
# Allows a parser to infer the type of the proxy by its path.
|
156
|
+
# @param [#to_sym] type the proxy's inferred type
|
157
|
+
# @return [nil]
|
119
158
|
def type=(type) Registry.proxy_types[path] = type.to_sym end
|
120
159
|
|
160
|
+
# @return [Boolean]
|
121
161
|
def instance_of?(klass)
|
122
162
|
self.class == klass
|
123
163
|
end
|
124
164
|
|
165
|
+
# @return [Boolean]
|
125
166
|
def kind_of?(klass)
|
126
167
|
self.class <= klass
|
127
168
|
end
|
128
169
|
|
170
|
+
# @return [Boolean]
|
129
171
|
def respond_to?(meth, include_private = false)
|
130
172
|
if obj = to_obj
|
131
173
|
obj.respond_to?(meth, include_private)
|
@@ -134,9 +176,9 @@ module YARD
|
|
134
176
|
end
|
135
177
|
end
|
136
178
|
|
137
|
-
# Dispatches the method to the resolved object
|
179
|
+
# Dispatches the method to the resolved object.
|
138
180
|
#
|
139
|
-
# @raise
|
181
|
+
# @raise [ProxyMethodError] if the proxy cannot find the real object
|
140
182
|
def method_missing(meth, *args, &block)
|
141
183
|
if obj = to_obj
|
142
184
|
obj.__send__(meth, *args, &block)
|
@@ -166,7 +208,12 @@ module YARD
|
|
166
208
|
#
|
167
209
|
# @return [Base, nil] the registered code object or nil
|
168
210
|
def to_obj
|
169
|
-
@obj
|
211
|
+
return @obj if @obj
|
212
|
+
if @obj = Registry.resolve(@namespace, (@imethod ? ISEP : '') + @name.to_s)
|
213
|
+
@namespace = @obj.namespace
|
214
|
+
@name = @obj.name
|
215
|
+
end
|
216
|
+
@obj
|
170
217
|
end
|
171
218
|
end
|
172
219
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Array
|
2
|
+
# Places a value before or after another object (by value) in
|
3
|
+
# an array. This is used in tandem with the before and after
|
4
|
+
# methods of the {Insertion} class.
|
5
|
+
#
|
6
|
+
# @example Places an item before another
|
7
|
+
# [1, 2, 3].place(4).before(3) # => [1, 2, 4, 3]
|
8
|
+
# @example Places an item after another
|
9
|
+
# [:a, :b, :c].place(:x).after(:a) # => [:a, :x, :b, :c]
|
10
|
+
# @param [Object] value value to insert
|
11
|
+
# @return [Insertion] an insertion object to
|
12
|
+
# @see Insertion#before
|
13
|
+
# @see Insertion#after
|
14
|
+
def place(value) Insertion.new(self, value) end
|
15
|
+
end
|
16
|
+
|
17
|
+
# The Insertion class inserts a value before or after another
|
18
|
+
# value in a list.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# Insertion.new([1, 2, 3], 4).before(3) # => [1, 2, 4, 3]
|
22
|
+
class Insertion
|
23
|
+
# Creates an insertion object on a list with a value to be
|
24
|
+
# inserted. To finalize the insertion, call {#before} or
|
25
|
+
# {#after} on the object.
|
26
|
+
#
|
27
|
+
# @param [Array] list the list to perform the insertion on
|
28
|
+
# @param [Object] value the value to insert
|
29
|
+
def initialize(list, value) @list, @value = list, value end
|
30
|
+
|
31
|
+
# Inserts the value before +val+
|
32
|
+
# @param [Object] val the object the value will be inserted before
|
33
|
+
def before(val) insertion(val, 0) end
|
34
|
+
|
35
|
+
# Inserts the value after +val+.
|
36
|
+
#
|
37
|
+
# @example If subsections are ignored
|
38
|
+
# Insertion.new([1, [2], 3], :X).after(1) # => [1, [2], :X, 3]
|
39
|
+
# @param [Object] val the object the value will be inserted after
|
40
|
+
# @param [Boolean] ignore_subsections treat any Array objects that follow val as
|
41
|
+
# associated and do not split them up.
|
42
|
+
def after(val, ignore_subsections = true) insertion(val, 1, ignore_subsections) end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# This method performs the actual insertion
|
47
|
+
#
|
48
|
+
# @param [Object] val the value to insert
|
49
|
+
# @param [Fixnum] rel the relative index (0 or 1) of where the object
|
50
|
+
# should be placed
|
51
|
+
# @param [Boolean] ignore_subsections see {#after} for an explanation.
|
52
|
+
def insertion(val, rel, ignore_subsections = true)
|
53
|
+
if index = @list.index(val)
|
54
|
+
if ignore_subsections && rel == 1 && @list[index + 1].is_a?(Array)
|
55
|
+
rel += 1
|
56
|
+
end
|
57
|
+
@list[index+rel,0] = @value
|
58
|
+
end
|
59
|
+
@list
|
60
|
+
end
|
61
|
+
end
|