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
data/lib/yard/core_ext/file.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
class File
|
2
2
|
RELATIVE_PARENTDIR = '..'
|
3
|
+
RELATIVE_SAMEDIR = '.'
|
3
4
|
|
4
5
|
# Turns a path +to+ into a relative path from starting
|
5
6
|
# point +from+. The argument +from+ is assumed to be
|
6
7
|
# a filename. To treat it as a directory, make sure it
|
7
|
-
# ends in
|
8
|
+
# ends in +File::SEPARATOR+ ('/' on UNIX filesystems).
|
8
9
|
#
|
9
10
|
# @param [String] from the starting filename
|
10
11
|
# (or directory with +from_isdir+ set to +true+).
|
11
|
-
#
|
12
12
|
# @param [String] to the final path that should be made relative.
|
13
|
-
#
|
14
13
|
# @return [String] the relative path from +from+ to +to+.
|
15
|
-
#
|
16
14
|
def self.relative_path(from, to)
|
17
15
|
from = expand_path(from).split(SEPARATOR)
|
18
16
|
to = expand_path(to).split(SEPARATOR)
|
@@ -23,4 +21,23 @@ class File
|
|
23
21
|
fname = from.pop
|
24
22
|
join *(from.map { RELATIVE_PARENTDIR } + to)
|
25
23
|
end
|
24
|
+
|
25
|
+
# Cleans a path by removing extraneous '..', '.' and '/' characters
|
26
|
+
#
|
27
|
+
# @example Clean a path
|
28
|
+
# File.cleanpath('a/b//./c/../e') # => "a/b/e"
|
29
|
+
# @param [String] path the path to clean
|
30
|
+
# @return [String] the sanitized path
|
31
|
+
def self.cleanpath(path)
|
32
|
+
path = path.split(SEPARATOR)
|
33
|
+
path = path.inject([]) do |acc, comp|
|
34
|
+
next acc if comp == RELATIVE_SAMEDIR
|
35
|
+
if comp == RELATIVE_PARENTDIR && acc.size > 0
|
36
|
+
acc.pop
|
37
|
+
next acc
|
38
|
+
end
|
39
|
+
acc << comp
|
40
|
+
end
|
41
|
+
File.join(*path)
|
42
|
+
end
|
26
43
|
end
|
data/lib/yard/core_ext/module.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
class Module
|
2
|
+
# Returns the class name of a full module namespace path
|
3
|
+
#
|
4
|
+
# @example
|
5
|
+
# module A::B::C; class_name end # => "C"
|
6
|
+
# @return [String] the last part of a module path
|
2
7
|
def class_name
|
3
8
|
name.split("::").last
|
4
9
|
end
|
5
|
-
|
10
|
+
|
11
|
+
# Returns the module namespace path minus the class/module name
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# module A::B::C; namespace end # => "A::B"
|
15
|
+
# @return [String] the namespace minus the class/module name
|
6
16
|
def namespace
|
7
17
|
name.split("::")[0..-2].join("::")
|
8
18
|
end
|
data/lib/yard/core_ext/string.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
class String
|
2
|
+
# Separates capital letters following lower case letters by an underscore
|
3
|
+
# and returns the entire string in lower case
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# "FooBar".underscore # => "foo_bar"
|
7
|
+
# @return [String] the underscored lower case string
|
2
8
|
def underscore
|
3
|
-
gsub(/([a-z])([A-Z])/, '\1_\2').downcase
|
9
|
+
gsub(/([a-z])([A-Z])/, '\1_\2').downcase.gsub('::', '/')
|
4
10
|
end
|
5
11
|
|
12
|
+
# Camel cases any underscored text.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# "foo_bar_baz".camelcase # => "FooBarBaz"
|
16
|
+
# @return [String] the camel cased text
|
6
17
|
def camelcase
|
7
|
-
gsub(/([a-z])_([a-z])/i) { $1 + $2.upcase }.sub(/^(.)/) { $1.upcase }
|
18
|
+
gsub(/([a-z])_([a-z])/i) { $1 + $2.upcase }.sub(/^(.)/) { $1.upcase }.gsub('/', '::')
|
8
19
|
end
|
9
20
|
end
|
@@ -1,8 +1,29 @@
|
|
1
|
+
# A subclass of Hash where all keys are converted into Symbols, and
|
2
|
+
# optionally, all String values are converted into Symbols.
|
1
3
|
class SymbolHash < Hash
|
4
|
+
# Creates a new SymbolHash object
|
5
|
+
#
|
6
|
+
# @param [Boolean] symbolize_value converts any String values into Symbols
|
7
|
+
# if this is set to +true+.
|
2
8
|
def initialize(symbolize_value = true)
|
3
9
|
@symbolize_value = symbolize_value
|
4
10
|
end
|
5
|
-
|
11
|
+
|
12
|
+
# @overload [](hash)
|
13
|
+
# Creates a SymbolHash object from an existing Hash
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# SymbolHash['x' => 1, :y => 2] # => #<SymbolHash:0x...>
|
17
|
+
# @param [Hash] hash the hash object
|
18
|
+
# @return [SymbolHash] a new SymbolHash from a hash object
|
19
|
+
#
|
20
|
+
# @overload [](*list)
|
21
|
+
# Creates a SymbolHash from an even list of keys and values
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# SymbolHash[key1, value1, key2, value2, ...]
|
25
|
+
# @param [Array] list an even list of key followed by value
|
26
|
+
# @return [SymbolHash] a new SymbolHash object
|
6
27
|
def self.[](*hsh)
|
7
28
|
obj = new;
|
8
29
|
if hsh.size == 1 && hsh.first.is_a?(Hash)
|
@@ -13,13 +34,40 @@ class SymbolHash < Hash
|
|
13
34
|
obj
|
14
35
|
end
|
15
36
|
|
37
|
+
# Assigns a value to a symbolized key
|
38
|
+
# @param [#to_sym] key the key
|
39
|
+
# @param [Object] value the value to be assigned. If this is a String and
|
40
|
+
# values are set to be symbolized, it will be converted into a Symbol.
|
16
41
|
def []=(key, value)
|
17
42
|
super(key.to_sym, value.instance_of?(String) && @symbolize_value ? value.to_sym : value)
|
18
43
|
end
|
44
|
+
|
45
|
+
# Accessed a symbolized key
|
46
|
+
# @param [#to_sym] key the key to access
|
47
|
+
# @return [Object] the value associated with the key
|
19
48
|
def [](key) super(key.to_sym) end
|
49
|
+
|
50
|
+
# Deleted a key and value associated with it
|
51
|
+
# @param [#to_sym] key the key to delete
|
52
|
+
# @return [nil]
|
20
53
|
def delete(key) super(key.to_sym) end
|
54
|
+
|
55
|
+
# Tests if a symbolized key exists
|
56
|
+
# @param [#to_sym] key the key to test
|
57
|
+
# @return [Boolean] whether the key exists
|
21
58
|
def has_key?(key) super(key.to_sym) end
|
22
|
-
|
59
|
+
|
60
|
+
# Updates the object with the contents of another Hash object
|
61
|
+
# This method modifies the original SymbolHash object
|
62
|
+
#
|
63
|
+
# @param [Hash] hash the hash object to copy the values from
|
64
|
+
# @return [SymbolHash] self
|
65
|
+
def update(hash) hash.each {|k,v| self[k] = v }; self end
|
23
66
|
alias_method :merge!, :update
|
24
|
-
|
67
|
+
|
68
|
+
# Merges the contents of another hash into a new SymbolHash object
|
69
|
+
#
|
70
|
+
# @param [Hash] hash the hash of objects to copy
|
71
|
+
# @return [SymbolHash] a new SymbolHash containing the merged data
|
72
|
+
def merge(hash) dup.merge!(hash) end
|
25
73
|
end
|
data/lib/yard/docstring.rb
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
module YARD
|
2
|
+
# A documentation string, or "docstring" for short, encapsulates the
|
3
|
+
# comments and metadata, or "tags", of an object. Meta-data is expressed
|
4
|
+
# in the form +@tag VALUE+, where VALUE can span over multiple lines as
|
5
|
+
# long as they are indented. The following +@example+ tag shows how tags
|
6
|
+
# can be indented:
|
7
|
+
#
|
8
|
+
# # @example My example
|
9
|
+
# # a = "hello world"
|
10
|
+
# # a.reverse
|
11
|
+
# # @version 1.0
|
12
|
+
#
|
13
|
+
# Tags can be nested in a documentation string, though the {Tags::Tag}
|
14
|
+
# itself is responsible for parsing the inner tags.
|
2
15
|
class Docstring < String
|
16
|
+
# @return [Array<Tags::RefTag>] the list of reference tags
|
3
17
|
attr_reader :ref_tags
|
4
|
-
|
18
|
+
|
19
|
+
# @return [CodeObjects::Base] the object that owns the docstring.
|
20
|
+
attr_accessor :object
|
21
|
+
|
22
|
+
# @return [Range] line range in the {#object}'s file where the docstring was parsed from
|
23
|
+
attr_accessor :line_range
|
24
|
+
|
25
|
+
# @return [String] the raw documentation (including raw tag text)
|
26
|
+
attr_accessor :all
|
5
27
|
|
28
|
+
# Matches a tag at the start of a comment line
|
6
29
|
META_MATCH = /^@([a-z_]+)(?:\s+(.*))?$/i
|
7
30
|
|
31
|
+
# Creates a new docstring with the raw contents attached to an optional
|
32
|
+
# object.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Docstring.new("hello world\n@return Object return", someobj)
|
36
|
+
#
|
37
|
+
# @param [String] content the raw comments to be parsed into a docstring
|
38
|
+
# and associated meta-data.
|
39
|
+
# @param [CodeObjects::Base] object an object to associate the docstring
|
40
|
+
# with.
|
8
41
|
def initialize(content = '', object = nil)
|
9
42
|
@tag_factory = Tags::Library.new
|
10
43
|
@object = object
|
@@ -12,6 +45,8 @@ module YARD
|
|
12
45
|
self.all = content
|
13
46
|
end
|
14
47
|
|
48
|
+
# Replaces the docstring with new raw content. Called by {#all=}.
|
49
|
+
# @param [String] content the raw comments to be parsed
|
15
50
|
def replace(content)
|
16
51
|
@tags, @ref_tags = [], []
|
17
52
|
@all = content
|
@@ -19,25 +54,38 @@ module YARD
|
|
19
54
|
end
|
20
55
|
alias all= replace
|
21
56
|
|
57
|
+
# @return [Fixnum] the first line of the {#line_range}.
|
22
58
|
def line
|
23
59
|
line_range.first
|
24
60
|
end
|
25
61
|
|
26
|
-
##
|
27
62
|
# Gets the first line of a docstring to the period or the first paragraph.
|
28
|
-
#
|
29
63
|
# @return [String] The first line or paragraph of the docstring; always ends with a period.
|
30
64
|
def summary
|
31
65
|
return @summary if @summary
|
32
|
-
|
33
|
-
|
34
|
-
|
66
|
+
open_parens = ['{', '(', '[']
|
67
|
+
close_parens = ['}', ')', ']']
|
68
|
+
num_parens = 0
|
69
|
+
idx = length.times do |index|
|
70
|
+
case self[index, 1]
|
71
|
+
when ".", "\r", "\n"
|
72
|
+
next_char = self[index + 1, 1].to_s
|
73
|
+
if num_parens == 0 && next_char =~ /^\s*$/
|
74
|
+
break index - 1
|
75
|
+
end
|
76
|
+
when "{", "(", "["
|
77
|
+
num_parens += 1
|
78
|
+
when "}", ")", "]"
|
79
|
+
num_parens -= 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@summary = self[0..idx]
|
83
|
+
@summary += '.' unless @summary.empty?
|
84
|
+
@summary
|
35
85
|
end
|
36
86
|
|
37
|
-
##
|
38
87
|
# Adds a tag or reftag object to the tag list
|
39
|
-
#
|
40
|
-
# @param [Tags::Tag, Tags::RefTag] *tags list of tag objects to add
|
88
|
+
# @param [Tags::Tag, Tags::RefTag] tags list of tag objects to add
|
41
89
|
def add_tag(*tags)
|
42
90
|
tags.each_with_index do |tag, i|
|
43
91
|
case tag
|
@@ -52,12 +100,11 @@ module YARD
|
|
52
100
|
end
|
53
101
|
end
|
54
102
|
|
55
|
-
##
|
56
103
|
# Convenience method to return the first tag
|
57
104
|
# object in the list of tag objects of that name
|
58
105
|
#
|
59
106
|
# @example
|
60
|
-
# doc =
|
107
|
+
# doc = Docstring.new("@return zero when nil")
|
61
108
|
# doc.tag(:return).text # => "zero when nil"
|
62
109
|
#
|
63
110
|
# @param [#to_s] name the tag name to return data for
|
@@ -66,10 +113,9 @@ module YARD
|
|
66
113
|
tags.find {|tag| tag.tag_name.to_s == name.to_s }
|
67
114
|
end
|
68
115
|
|
69
|
-
##
|
70
116
|
# Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
71
117
|
#
|
72
|
-
# @param name the tag name to return data for, or nil for all tags
|
118
|
+
# @param [#to_s] name the tag name to return data for, or nil for all tags
|
73
119
|
# @return [Array<Tags::Tag>] the list of tags by the specified tag name
|
74
120
|
def tags(name = nil)
|
75
121
|
list = @tags + convert_ref_tags
|
@@ -86,7 +132,6 @@ module YARD
|
|
86
132
|
tags.any? {|tag| tag.tag_name.to_s == name.to_s }
|
87
133
|
end
|
88
134
|
|
89
|
-
##
|
90
135
|
# Returns true if the docstring has no content
|
91
136
|
#
|
92
137
|
# @return [Boolean] whether or not the docstring has content
|
@@ -96,20 +141,25 @@ module YARD
|
|
96
141
|
|
97
142
|
private
|
98
143
|
|
144
|
+
# Maps valid reference tags
|
145
|
+
#
|
146
|
+
# @return [Array<Tags::RefTag>] the list of valid reference tags
|
99
147
|
def convert_ref_tags
|
100
148
|
list = @ref_tags.reject {|t| CodeObjects::Proxy === t.owner }
|
101
149
|
list.map {|t| t.tags }.flatten
|
102
150
|
end
|
103
151
|
|
104
|
-
|
105
|
-
# Creates a {RefTag}
|
152
|
+
# Creates a {Tags::RefTag}
|
106
153
|
def create_ref_tag(tag_name, name, object)
|
107
154
|
@ref_tags << Tags::RefTagList.new(tag_name, object, name)
|
108
155
|
end
|
109
156
|
|
110
|
-
|
111
|
-
# Creates a tag from the TagFactory
|
157
|
+
# Creates a tag from the {Tags::DefaultFactory tag factory}.
|
112
158
|
#
|
159
|
+
# @param [String] tag_name the tag name
|
160
|
+
# @param [String] tag_buf the text attached to the tag with newlines removed.
|
161
|
+
# @param [String] raw_buf the raw buffer of text without removed newlines.
|
162
|
+
# @return [Tags::Tag, Tags::RefTag] a tag
|
113
163
|
def create_tag(tag_name, tag_buf, raw_buf)
|
114
164
|
if tag_buf =~ /\A\s*(?:(\S+)\s+)?\(\s*see\s+(\S+)\s*\)\s*\Z/
|
115
165
|
return create_ref_tag(tag_name, $1, $2)
|
@@ -129,7 +179,6 @@ module YARD
|
|
129
179
|
log.warn "Invalid tag format for @#{tag_name}" + (object ? " in file `#{object.file}` near line #{object.line}" : "")
|
130
180
|
end
|
131
181
|
|
132
|
-
##
|
133
182
|
# Parses out comments split by newlines into a new code object
|
134
183
|
#
|
135
184
|
# @param [String] comments
|
data/lib/yard/globals.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Global methods
|
2
2
|
|
3
|
-
# Shortcut for creating a YARD::CodeObjects::Proxy
|
4
|
-
# via a path
|
3
|
+
# Shortcut for creating a YARD::CodeObjects::Proxy via a path
|
5
4
|
#
|
6
5
|
# @see YARD::CodeObjects::Proxy
|
7
6
|
# @see YARD::Registry#resolve
|
@@ -10,6 +9,10 @@ def P(namespace, name = nil)
|
|
10
9
|
YARD::Registry.resolve(namespace, name, false, true)
|
11
10
|
end
|
12
11
|
|
12
|
+
# The global {YARD::Logger} instance
|
13
|
+
#
|
14
|
+
# @return [YARD::Logger] the global {YARD::Logger} instance
|
15
|
+
# @see YARD::Logger
|
13
16
|
def log
|
14
17
|
YARD::Logger.instance
|
15
18
|
end
|
data/lib/yard/handlers/base.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
module YARD
|
2
2
|
module Handlers
|
3
|
+
# Raised during processing phase when a handler needs to perform
|
4
|
+
# an operation on an object's namespace but the namespace could
|
5
|
+
# not be resolved.
|
3
6
|
class NamespaceMissingError < Parser::UndocumentableError
|
7
|
+
# The object the error occured on
|
8
|
+
# @return [CodeObjects::Base] a code object
|
4
9
|
attr_accessor :object
|
10
|
+
|
5
11
|
def initialize(object) @object = object end
|
6
12
|
end
|
7
13
|
|
@@ -125,6 +131,9 @@ module YARD
|
|
125
131
|
# even if statements. For this reason, the block parsing method must be
|
126
132
|
# invoked explicitly out of efficiency sake.
|
127
133
|
#
|
134
|
+
# @abstract Subclass this class to provide a handler for YARD to use
|
135
|
+
# during the processing phase.
|
136
|
+
#
|
128
137
|
# @see CodeObjects::Base
|
129
138
|
# @see CodeObjects::NamespaceObject
|
130
139
|
# @see handles
|
@@ -132,7 +141,6 @@ module YARD
|
|
132
141
|
# @see #owner
|
133
142
|
# @see #register
|
134
143
|
# @see #parse_block
|
135
|
-
#
|
136
144
|
class Base
|
137
145
|
# For accessing convenience, eg. "MethodObject"
|
138
146
|
# instead of the full qualified namespace
|
@@ -141,10 +149,14 @@ module YARD
|
|
141
149
|
include Parser
|
142
150
|
|
143
151
|
class << self
|
152
|
+
# Clear all registered subclasses. Testing purposes only
|
153
|
+
# @return [nil]
|
144
154
|
def clear_subclasses
|
145
155
|
@@subclasses = []
|
146
156
|
end
|
147
157
|
|
158
|
+
# Returns all registered handler subclasses.
|
159
|
+
# @return [Array<Base>] a list of handlers
|
148
160
|
def subclasses
|
149
161
|
@@subclasses ||= []
|
150
162
|
end
|
@@ -335,8 +347,6 @@ module YARD
|
|
335
347
|
else
|
336
348
|
raise NamespaceMissingError, object
|
337
349
|
end
|
338
|
-
else
|
339
|
-
log.debug "Object #{object} successfully resolved. Adding children."
|
340
350
|
end
|
341
351
|
object
|
342
352
|
end
|
@@ -1,9 +1,52 @@
|
|
1
1
|
module YARD
|
2
2
|
module Handlers
|
3
|
+
# Iterates over all statements in a file and delegates them to the
|
4
|
+
# {Handlers::Base} objects that are registered to handle the statement.
|
5
|
+
#
|
6
|
+
# This class is passed to each handler and keeps overall processing state.
|
7
|
+
# For example, if the {#visibility} is set in a handler, all following
|
8
|
+
# statements will have access to this state. This allows "public",
|
9
|
+
# "protected" and "private" statements to be handled in classes and modules.
|
10
|
+
# In addition, the {#namespace} can be set during parsing to control
|
11
|
+
# where objects are being created from.
|
12
|
+
#
|
13
|
+
# @see Handlers::Base
|
3
14
|
class Processor
|
4
|
-
|
5
|
-
attr_accessor :
|
15
|
+
# @return [String] the filename
|
16
|
+
attr_accessor :file
|
17
|
+
|
18
|
+
# @return [CodeObjects::NamespaceObject] the current namespace
|
19
|
+
attr_accessor :namespace
|
20
|
+
|
21
|
+
# @return [Symbol] the current visibility
|
22
|
+
attr_accessor :visibility
|
23
|
+
|
24
|
+
# @return [Symbol] the current scope
|
25
|
+
attr_accessor :scope
|
26
|
+
|
27
|
+
# @return [CodeObjects::Base, nil] unlike the namespace, the owner
|
28
|
+
# is a non-namespace object that should be stored between statements.
|
29
|
+
# For instance, when parsing a method body, the {CodeObjects::MethodObject}
|
30
|
+
# is set as the owner, in case any extra method information is processed.
|
31
|
+
attr_accessor :owner
|
32
|
+
|
33
|
+
# @return [Boolean] whether or not {Parser::LoadOrderError} is raised
|
34
|
+
attr_accessor :load_order_errors
|
35
|
+
|
36
|
+
# @return [Symbol] the parser type (:ruby, :ruby18 or :c)
|
37
|
+
attr_accessor :parser_type
|
6
38
|
|
39
|
+
# Creates a new Processor for a +file+.
|
40
|
+
#
|
41
|
+
# @param [String] file the name of the file that is being processed.
|
42
|
+
# uses '(stdin)' if file is nil.
|
43
|
+
# @param [Boolean] load_order_error whether or not to raise {Parser::LoadOrderError}
|
44
|
+
# when a file has unresolved references that need to be parsed first.
|
45
|
+
# If these errors are raised, the processor will attempt to load all
|
46
|
+
# other files before continuing to parse the file.
|
47
|
+
# @param [Symbol] parser_type the parser type (:ruby, :ruby18, :c) from
|
48
|
+
# the parser. Used to select the handler (since handlers are specific
|
49
|
+
# to a parser type).
|
7
50
|
def initialize(file = nil, load_order_errors = false, parser_type = Parser::SourceParser.parser_type)
|
8
51
|
@file = file || "(stdin)"
|
9
52
|
@namespace = YARD::Registry.root
|
@@ -16,6 +59,11 @@ module YARD
|
|
16
59
|
load_handlers
|
17
60
|
end
|
18
61
|
|
62
|
+
# Processes a list of statements by finding handlers to process each
|
63
|
+
# one.
|
64
|
+
#
|
65
|
+
# @param [Array] statements a list of statements
|
66
|
+
# @return [nil]
|
19
67
|
def process(statements)
|
20
68
|
statements.each_with_index do |stmt, index|
|
21
69
|
find_handlers(stmt).each do |handler|
|
@@ -41,6 +89,10 @@ module YARD
|
|
41
89
|
end
|
42
90
|
end
|
43
91
|
|
92
|
+
# Searches for all handlers in {Base.subclasses} that match the +statement+
|
93
|
+
#
|
94
|
+
# @param statement the statement object to match.
|
95
|
+
# @return [Array<Base>] a list of handlers to process the statement with.
|
44
96
|
def find_handlers(statement)
|
45
97
|
Base.subclasses.find_all do |handler|
|
46
98
|
handler_base_class > handler &&
|
@@ -51,10 +103,16 @@ module YARD
|
|
51
103
|
|
52
104
|
private
|
53
105
|
|
106
|
+
# Returns the handler base class
|
107
|
+
# @return [Base] the base class
|
54
108
|
def handler_base_class
|
55
109
|
handler_base_namespace.const_get(:Base)
|
56
110
|
end
|
57
111
|
|
112
|
+
# The module holding the handlers to be loaded
|
113
|
+
#
|
114
|
+
# @return [Module] the module containing the handlers depending on
|
115
|
+
# {#parser_type}.
|
58
116
|
def handler_base_namespace
|
59
117
|
case parser_type
|
60
118
|
when :ruby; Ruby
|
@@ -62,6 +120,10 @@ module YARD
|
|
62
120
|
end
|
63
121
|
end
|
64
122
|
|
123
|
+
# Loads handlers from {#handler_base_namespace}. This ensures that
|
124
|
+
# Ruby1.9 handlers are never loaded into 1.8; also lowers the amount
|
125
|
+
# of modules that are loaded
|
126
|
+
# @return [nil]
|
65
127
|
def load_handlers
|
66
128
|
return if @handlers_loaded[parser_type]
|
67
129
|
handler_base_namespace.constants.each {|c| handler_base_namespace.const_get(c) }
|