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
File without changes
|
@@ -4,14 +4,14 @@ Handlers Architecture
|
|
4
4
|
Handlers allow the processing of parsed source code. Handling is done after
|
5
5
|
parsing to abstract away the implementation details of lexical and semantic
|
6
6
|
analysis on source and to only deal with the logic regarding recognizing
|
7
|
-
source statements as {file:
|
7
|
+
source statements as {file:CodeObjects.md code objects}.
|
8
8
|
|
9
9
|
![Handlers Architecture Class Diagram](images/handlers-class-diagram.png)
|
10
10
|
|
11
11
|
The Pipeline
|
12
12
|
------------
|
13
13
|
|
14
|
-
After the {file:
|
14
|
+
After the {file:Parser.md parser component} finishes analyzing the
|
15
15
|
source, it is handed off for post-processing to the {YARD::Handlers::Processor}
|
16
16
|
class, which is responsible for traversing the set of statements given by
|
17
17
|
the parser and delegating them to matching handlers. Handlers match when the
|
@@ -51,7 +51,7 @@ class method. A very simple handler that handles a module definition would be:
|
|
51
51
|
end
|
52
52
|
|
53
53
|
For details on what nodes are, and what node types are, see the
|
54
|
-
{file:
|
54
|
+
{file:Parser.md parser architecture document}.
|
55
55
|
|
56
56
|
In this case the node type being handled is the `:module` type. More than one
|
57
57
|
node type or `handles` declarations may describe a single handler, for instance,
|
@@ -89,7 +89,7 @@ Creating a new Code Object
|
|
89
89
|
--------------------------
|
90
90
|
|
91
91
|
Usually (but not always) handling is performed to create new code objects to add
|
92
|
-
to the registry (for information about code objects, see {file:
|
92
|
+
to the registry (for information about code objects, see {file:CodeObjects.md this document}).
|
93
93
|
Code objects should simply be created and added to the existing `namespace`. This
|
94
94
|
will be enough to add them to the registry. There is also a convenience
|
95
95
|
{YARD::Handlers::Base#register register} method which quickly sets standard attributed
|
@@ -132,7 +132,7 @@ Because the legacy handler uses the legacy parser and therefore a different kind
|
|
132
132
|
of AST, there are subtle differences in the handler API. Most importantly, the
|
133
133
|
`handles` method usually deals with either lexical tokens or source code as a string
|
134
134
|
or RegExp object. The statement object, similarly, is made up of lexical tokens instead
|
135
|
-
of semantically parsed nodes (this is described in the {file:
|
135
|
+
of semantically parsed nodes (this is described in the {file:Parser.md parser document}).
|
136
136
|
|
137
137
|
The module example above can be rewritten as a legacy handler as follows:
|
138
138
|
|
@@ -8,7 +8,7 @@ that tools like RDoc do not do. These components are:
|
|
8
8
|
|
9
9
|
* [Code Parsing & Processing Component](#parsing)
|
10
10
|
* [Data Storage Component](#storage)
|
11
|
-
* [Post Processing &
|
11
|
+
* [Post Processing & Templating System](#templates)
|
12
12
|
|
13
13
|
This separation is a major goal of the project, and means that YARD is not *just*
|
14
14
|
a tool to generate HTML output. The expectation is that any subset of YARD's
|
@@ -30,10 +30,10 @@ This component is made up of four sub-components, each of which have separate
|
|
30
30
|
tasks during the data gathering process (*note: the tag architecture is not*
|
31
31
|
*shown in the class diagram*). These sub-components are:
|
32
32
|
|
33
|
-
* {file:
|
34
|
-
* {file:
|
35
|
-
* {file:
|
36
|
-
* {file:
|
33
|
+
* {file:Parser.md Parser Architecture}
|
34
|
+
* {file:Handlers.md Handler Architecture}
|
35
|
+
* {file:CodeObjects.md Code Object Architecture}
|
36
|
+
* {file:Tags.md Tag Architecture}
|
37
37
|
|
38
38
|
The parser component reads source files and converts it into a set of statements
|
39
39
|
which the handlers then process, creating code objects which in turn create tags
|
@@ -50,15 +50,11 @@ is the centralized repository for all data being parsed, stored and accessed. Th
|
|
50
50
|
are future plans to improve this storage mechanism to be backend agnostic and allow
|
51
51
|
for more robust storage.
|
52
52
|
|
53
|
-
<a name="
|
54
|
-
Post Processing &
|
55
|
-
|
53
|
+
<a name="templates"></a>
|
54
|
+
Post Processing & Templating System
|
55
|
+
-----------------------------------
|
56
56
|
|
57
57
|
This component handles processing of objects from the registry through a templating
|
58
58
|
engine that allows output to a variety of formats. Practically speaking, this is
|
59
59
|
where templates can be implemented to change the design, output or structure of
|
60
|
-
the data.
|
61
|
-
this component, so documentation might be sparse for now.
|
62
|
-
|
63
|
-
The current design is documented in the {file:GENERATORS.markdown Generators Architecture}
|
64
|
-
document.
|
60
|
+
the data. See {file:Templates.md Templates Architecture} for a complete overview.
|
@@ -3,7 +3,7 @@ Parser Architecture
|
|
3
3
|
|
4
4
|
The parser component of YARD is the first component in the data processing pipeline
|
5
5
|
that runs before any handling is done on the source. The parser is meant to translate
|
6
|
-
the source into a set of statements that can be understood by the {file:
|
6
|
+
the source into a set of statements that can be understood by the {file:Handlers.md Handlers}
|
7
7
|
that run immediately afterwards.
|
8
8
|
|
9
9
|
The important classes are described in the class diagram of the entire parser
|
@@ -19,7 +19,7 @@ class.
|
|
19
19
|
Accessing Tag Information
|
20
20
|
-------------------------
|
21
21
|
|
22
|
-
Tag metadata is added when a {YARD::Docstring} is added to a {file:
|
22
|
+
Tag metadata is added when a {YARD::Docstring} is added to a {file:CodeObjects.md code object}
|
23
23
|
using the {YARD::CodeObjects::Base#docstring=} attribute. In addition to adding
|
24
24
|
conventional comments, tags are parsed and associated with the object. The easiest
|
25
25
|
way to access tags on an object is to use the {YARD::CodeObjects::Base#tag} and `#tags`
|
data/docs/Templates.md
ADDED
@@ -0,0 +1,286 @@
|
|
1
|
+
Templates Architecture
|
2
|
+
======================
|
3
|
+
|
4
|
+
Templates are the main component in the output rendering process of YARD,
|
5
|
+
which is invoked when conventional HTML/text output needs to be rendered
|
6
|
+
for a set of code objects.
|
7
|
+
|
8
|
+
Design Goals
|
9
|
+
------------
|
10
|
+
|
11
|
+
The general design attempts to be as abstracted from actual content and templates
|
12
|
+
as possible. Unlike RDoc which uses one file to describe the entire template,
|
13
|
+
YARD splits up the rendering of code objects into small components, allowing
|
14
|
+
template modification for smaller subsets of a full template without having to
|
15
|
+
duplicate the entire template itself. This is necessary because of YARD's support
|
16
|
+
for plugins. YARD is designed for extensibility by external plugins, and because
|
17
|
+
of this, no one plugin can be responsible for the entire template because no
|
18
|
+
one plugin knows about the other plugins being used. For instance, if an RSpec
|
19
|
+
plugin was added to support and document specifications in class templates,
|
20
|
+
this information would need to be transparently added to the template to work
|
21
|
+
in conjunction with any other plugin that performed similar template modifications.
|
22
|
+
The design goals can be summarized as follows:
|
23
|
+
|
24
|
+
1. Output should be able to be rendered for any arbitrary format with little
|
25
|
+
modification to YARD's source code. The addition of extra templates should
|
26
|
+
be sufficient.
|
27
|
+
2. The output rendered for an object should independently rendered data
|
28
|
+
from arbitrary sources. These independent components are called "sections".
|
29
|
+
3. Sections should be able to be inserted into any object without affecting
|
30
|
+
any existing sections in the document. This allows for easy modification
|
31
|
+
of templates by plugins.
|
32
|
+
|
33
|
+
Templates
|
34
|
+
---------
|
35
|
+
|
36
|
+
Template modules are the objects used to orchestrate the design goals listed
|
37
|
+
above. Specifically, they organize the sections and render the template contents
|
38
|
+
depending on the format.
|
39
|
+
|
40
|
+
Engine
|
41
|
+
------
|
42
|
+
|
43
|
+
The Engine class orchestrates the creation and rendering of Template modules and
|
44
|
+
handles serialization or specific rendering scenarios (like HTML). To create
|
45
|
+
a template, use the {YARD::Templates::Engine.template template} method. The two most
|
46
|
+
common methods used to initiate output are the {YARD::Templates::Engine.render render}
|
47
|
+
and {YARD::Templates::Engine.generate generate} methods which generate and
|
48
|
+
optionally serialize output to a file. The latter, `#generate`, is used
|
49
|
+
specially to generate HTML documentation and copy over assets that may be
|
50
|
+
needed. For instance, an object may be rendered with:
|
51
|
+
|
52
|
+
YARD::Templates::Engine.render(:object => myobject)
|
53
|
+
|
54
|
+
A set of objects may be rendered into HTML documentation by using:
|
55
|
+
|
56
|
+
# all_objects is an array of module and class objects
|
57
|
+
# options includes a :serializer key to copy output to the file system
|
58
|
+
YARD::Templates::Engine.generate(all_objects, options)
|
59
|
+
|
60
|
+
Note that these methods should not be called directly. The {YARD::CodeObjects::Base}
|
61
|
+
class has a {YARD::CodeObjects::Base#format #format} helper method to render an
|
62
|
+
object. For instance, the above render example is equivalent to the simple
|
63
|
+
call `myobject.format`. The `generate` method is a special kind of render
|
64
|
+
and is called from the {YARD::CLI::Yardoc} command line utility.
|
65
|
+
|
66
|
+
Template Options
|
67
|
+
----------------
|
68
|
+
|
69
|
+
A template keeps state when it is rendering output. This state is kept in
|
70
|
+
an options hash which is initially passed to it during instantiation. Some
|
71
|
+
default options set the template style (`:template`), the output format (`:format`),
|
72
|
+
and the serializer to use (`:serializer`). This options hash is modifiable
|
73
|
+
from all methods seen above. For example, initializing a template to output as
|
74
|
+
HTML instead of text can be done as follows:
|
75
|
+
|
76
|
+
myobject.format(:format => :html)
|
77
|
+
|
78
|
+
Serializer
|
79
|
+
----------
|
80
|
+
|
81
|
+
This class abstracts the logic involved in deciding how to serialize data to
|
82
|
+
the expected endpoint. For instance, there is both a {YARD::Serializers::StdoutSerializer StdoutSerializer}
|
83
|
+
and {YARD::Serializers::FileSystemSerializer FileSystemSerializer} class for
|
84
|
+
outputting to console or to a file respectively. When endpoints with locations
|
85
|
+
are used (like files or URLs), the serializer implements the {YARD::Serializers::Base#serialized_path #serialized_path}
|
86
|
+
method. This allows the translation from a code object to its path at the endpoint,
|
87
|
+
which enables inter-document linking.
|
88
|
+
|
89
|
+
Rendered objects are automatically serialized using the object if present,
|
90
|
+
otherwise the rendered object is returned as a string to its parent. Nested
|
91
|
+
Templates automatically set the serializer to nil so that they return
|
92
|
+
as a String to their parent.
|
93
|
+
|
94
|
+
Creating a Template
|
95
|
+
-------------------
|
96
|
+
|
97
|
+
Templates are represented by a directory inside the {YARD::Templates::Engine.template_paths}
|
98
|
+
on disk. A standard template directory looks like the following tree:
|
99
|
+
|
100
|
+
(Assuming templates/ is a template path)
|
101
|
+
templates
|
102
|
+
`-- default
|
103
|
+
|-- class
|
104
|
+
| |-- dot
|
105
|
+
| | |-- setup.rb
|
106
|
+
| | `-- superklass.erb
|
107
|
+
| |-- html
|
108
|
+
| | |-- constructor_details.erb
|
109
|
+
| | |-- setup.rb
|
110
|
+
| | `-- subclasses.erb
|
111
|
+
| |-- setup.rb
|
112
|
+
| `-- text
|
113
|
+
| |-- setup.rb
|
114
|
+
| `-- subclasses.erb
|
115
|
+
|-- docstring
|
116
|
+
| |-- html
|
117
|
+
| | |-- abstract.erb
|
118
|
+
| | |-- deprecated.erb
|
119
|
+
| | |-- index.erb
|
120
|
+
| | `-- text.erb
|
121
|
+
| |-- setup.rb
|
122
|
+
| `-- text
|
123
|
+
| |-- abstract.erb
|
124
|
+
| |-- deprecated.erb
|
125
|
+
| |-- index.erb
|
126
|
+
| `-- text.erb
|
127
|
+
|
128
|
+
The path `default` refers to the template style (:template key in options hash)
|
129
|
+
and the directories at the next level (such as `class`) refer to template
|
130
|
+
`:type` (options hash key) for a template. The next directory refers to the
|
131
|
+
output format being used defined by the `:format` template option.
|
132
|
+
|
133
|
+
As we saw in the above example, the format option can be set to `:html`, which
|
134
|
+
would use the `html/` directory instead of `text/`. Finally, the individual .erb
|
135
|
+
files are the sections that make up the template.
|
136
|
+
|
137
|
+
Note that the subdirectory `html/` is also its own "template" that inherits
|
138
|
+
from the parent directory. We will see more on this later.
|
139
|
+
|
140
|
+
setup.rb
|
141
|
+
--------
|
142
|
+
|
143
|
+
Every template should have at least one `setup.rb` file that defines the
|
144
|
+
{YARD::Templates::Template#init #init} method to set the
|
145
|
+
{YARD::Templates::Template#sections #sections} used by the template. If
|
146
|
+
a setup.rb is not defined in the template itself, there should be a template
|
147
|
+
that is inherited (via parent directory or explcitly) that sets the sections
|
148
|
+
on a newly created template.
|
149
|
+
|
150
|
+
A standard setup.rb file looks like:
|
151
|
+
|
152
|
+
def init
|
153
|
+
sections :section1, :section2, :section3
|
154
|
+
end
|
155
|
+
|
156
|
+
Sections
|
157
|
+
--------
|
158
|
+
|
159
|
+
Sections are smaller components that correlate to template
|
160
|
+
fragments. Practically speaking, a section can either be a template fragment
|
161
|
+
(a conventional .erb file or other supported templating language), a method
|
162
|
+
(which returns a String) or another {YARD::Templates::Template} (which in turn has its own
|
163
|
+
list of sections).
|
164
|
+
|
165
|
+
Nested Sections
|
166
|
+
---------------
|
167
|
+
|
168
|
+
Sections often require the ability to encapsulate a set of sub-sections in markup
|
169
|
+
(HTML, for instance). Rather than use heavier Template subclass objects, a more
|
170
|
+
lightweight solution is to nest a set of sub-sections as a list that follows
|
171
|
+
a section, for example:
|
172
|
+
|
173
|
+
def init
|
174
|
+
sections :header, [:section_a, :section_b]
|
175
|
+
end
|
176
|
+
|
177
|
+
The above example nests `section_a` and `section_b` within the `header` section.
|
178
|
+
Practically speaking, these sections can be placed in the result by `yield`ing
|
179
|
+
to them. A sample header.erb template might contain:
|
180
|
+
|
181
|
+
<h2>Header</h2>
|
182
|
+
<div id="contents">
|
183
|
+
<%= yieldall %>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
This template code would place the output of `section_a` and `section_b` within
|
187
|
+
the above div element. Using `yieldall`, we can also change the object that is being
|
188
|
+
rendered. For example, we may want to yield the first method of the class.
|
189
|
+
We can do this like so:
|
190
|
+
|
191
|
+
<h2>First method</h2>
|
192
|
+
<%= yieldall :object => object.meths.first %>
|
193
|
+
|
194
|
+
This would run the nested sections for the method object instead of the class.
|
195
|
+
|
196
|
+
Note that `yieldall` yields to all subsections, whereas `yield` will yield
|
197
|
+
to each individually (in order) until there are no more left to yield to.
|
198
|
+
In the vast majority of cases, you'd want to use `yieldall`, since `yield`
|
199
|
+
makes it hard for users to override your template.
|
200
|
+
|
201
|
+
Inheriting Templates
|
202
|
+
--------------------
|
203
|
+
|
204
|
+
Parent directory templates are automatically inherited (or mixed in, to be
|
205
|
+
more accurate) by the current template. This means that the 'default/class/html'
|
206
|
+
template automatically inherits from 'default/class'. This also means that anything
|
207
|
+
defined in 'default/class/setup.rb' can be overridden by 'default/class/html/setup.rb'.
|
208
|
+
|
209
|
+
Since the Template module is a module, and not a class, they can be mixed in
|
210
|
+
explicitly (via include/extend) from other templates, which allows templates
|
211
|
+
to share erb files or helper logic. The 'default/class' template explicitly
|
212
|
+
mixes in the 'default/module' template, since it uses much of the same sections.
|
213
|
+
This is done with the helper {YARD::Templates::Template::ClassMethods#T T} method, which
|
214
|
+
is simply a shorthand for {YARD::Templates::Engine.template Engine.template}.
|
215
|
+
It can then override (using standard inheritance) the sections from the module
|
216
|
+
template and insert sections pertaining to classes. This is one of the design
|
217
|
+
goals described above.
|
218
|
+
|
219
|
+
For instance, the first line in `default/class/html/setup.rb` is:
|
220
|
+
|
221
|
+
include T('default/module/html')
|
222
|
+
|
223
|
+
This includes the 'default/module/html', which means it also includes 'default/module'
|
224
|
+
by extension. This allows class to make use of any of module's erb files.
|
225
|
+
|
226
|
+
Inserting Sections
|
227
|
+
------------------
|
228
|
+
|
229
|
+
The ability to insert sections was mentioned above. The class template, for
|
230
|
+
instance, will modify the #init method to insert class specific sections:
|
231
|
+
|
232
|
+
def init
|
233
|
+
super
|
234
|
+
sections.place(:subclasses).before(:children)
|
235
|
+
sections.delete(:children)
|
236
|
+
sections.place([:constructor_details, [T('method_details')]]).before(:methodmissing)
|
237
|
+
end
|
238
|
+
|
239
|
+
Observe how sections has been modified after the super method was called (the
|
240
|
+
super method would have been defined in `default/module/setup.rb`). The
|
241
|
+
custom method {Array#place} is added by YARD to allow sections to be inserted
|
242
|
+
before or after another section by it's given name rather than index. This
|
243
|
+
allows the overriding of templates in a way that does not depend on where
|
244
|
+
the section is located (since it may have been overriden by another module).
|
245
|
+
|
246
|
+
Overriding Templates by Registering a Template Path
|
247
|
+
---------------------------------------------------
|
248
|
+
|
249
|
+
Inheriting templates explicitly is useful when creating a customized template
|
250
|
+
that wants to take advantage of code re-use. However, most users who want
|
251
|
+
to customize YARD templates will want to override existing behaviour without
|
252
|
+
creating a template from scratch.
|
253
|
+
|
254
|
+
YARD solves this problem by allowing other template paths to be registered.
|
255
|
+
Because template modules are represented by a relative path such as 'default/class',
|
256
|
+
they can be found within any of the registered template paths. A new template
|
257
|
+
path is registered as:
|
258
|
+
|
259
|
+
YARD::Templates::Engine.register_template_path '/path/to/mytemplates'
|
260
|
+
|
261
|
+
At this point, any time the 'default/class' template is loaded, the template
|
262
|
+
will first be looked for inside the newly registered template path. If found,
|
263
|
+
it will be used as the template module, with the modules from the other
|
264
|
+
template paths implicitly mixed in.
|
265
|
+
|
266
|
+
Therefore, by using the same directory structure as a builtin YARD template,
|
267
|
+
a user can customize or override individual templates as if the old ones were
|
268
|
+
inherited. A real world example would further modify the 'default/class' template
|
269
|
+
seen above by creating such a path in our '/path/to/mytemplates' custom template
|
270
|
+
path:
|
271
|
+
|
272
|
+
/path/to/mytemplates/:
|
273
|
+
|-- class
|
274
|
+
| |-- html
|
275
|
+
| | |-- customsection.erb
|
276
|
+
| |-- setup.rb
|
277
|
+
|
278
|
+
The `setup.rb` file would look like:
|
279
|
+
|
280
|
+
def init
|
281
|
+
super
|
282
|
+
sections.push :customsection
|
283
|
+
end
|
284
|
+
|
285
|
+
Now, when a class object is formatted as HTML, our customsection.erb will be
|
286
|
+
appended to the rendered data.
|
@@ -1,5 +1,85 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
What's New in 0.4.x?
|
2
|
+
====================
|
3
|
+
|
4
|
+
1. **New templating engine and templates**
|
5
|
+
2. **yardoc `--query` argument**
|
6
|
+
3. **Greatly expanded API documentation**
|
7
|
+
4. **New plugin support**
|
8
|
+
5. **New tags (@abstract, @private)**
|
9
|
+
6. **Default rake task is now `rake yard`**
|
10
|
+
|
11
|
+
New templating engine and templates
|
12
|
+
-----------------------------------
|
13
|
+
|
14
|
+
The templates were redesigned, most notably removing the ugly frameset, adding
|
15
|
+
search to the class/method lists, simplifying the layout and making things
|
16
|
+
generally prettier. You should also notice that more tags are now visible in
|
17
|
+
the templates such as @todo, the new @abstract and @note tags and some others
|
18
|
+
that existed but were previously omitted from the generated documentation.
|
19
|
+
|
20
|
+
There is also a new templating engine (based on the tadpole templating library)
|
21
|
+
to allow for much more user customization. You can read about it in
|
22
|
+
{file:Templates.md}.
|
23
|
+
|
24
|
+
yardoc `--query` argument
|
25
|
+
-------------------------
|
26
|
+
|
27
|
+
The yardoc command-line tool now supports queries to select which classes,
|
28
|
+
modules or methods to include in documentation based on their data or meta-data.
|
29
|
+
For instance, you can now generate documentation for your "public" API only by
|
30
|
+
adding "@api public" to each of your public API methods/classes and using
|
31
|
+
the following argument:
|
32
|
+
|
33
|
+
--query '@api.text == "public"'
|
34
|
+
|
35
|
+
More information on queries is in the {file:README.md}.
|
36
|
+
|
37
|
+
Greatly expanded API documentation
|
38
|
+
----------------------------------
|
39
|
+
|
40
|
+
Last release focused on many how-to and architecture documents to explain
|
41
|
+
the design of YARD, but many of the actual API classes/methods were still
|
42
|
+
left undocumented. This release marks a focus on getting YARD's own documentation
|
43
|
+
up to par so that it can serve as an official reference on the recommended
|
44
|
+
conventions to use when documenting code.
|
45
|
+
|
46
|
+
New plugin support
|
47
|
+
------------------
|
48
|
+
|
49
|
+
YARD now supports loading of plugins via RubyGems. Any gem named `yard-*` or
|
50
|
+
`yard_*` will now be loaded when YARD starts up. Note that the '-' separator
|
51
|
+
is the recommended naming scheme.
|
52
|
+
|
53
|
+
To ignore plugins, add the gem names to `~/.yard/ignored_plugins` on separate
|
54
|
+
lines (or separated by whitespace).
|
55
|
+
|
56
|
+
New tags (@abstract, @private)
|
57
|
+
------------------------------
|
58
|
+
|
59
|
+
Two new tags were added to the list of builtin meta-tags in YARD. `@abstract`
|
60
|
+
marks a class/module/method as abstract while `@private` marks an object
|
61
|
+
as "private". The latter tag is unsed in situations where an object is public
|
62
|
+
due to Ruby's own visibility limitations (constants, classes and modules
|
63
|
+
can never be private) but not actually part of your public API. You should
|
64
|
+
use this tag sparingly, as it is not meant to be an equivalent to RDoc's
|
65
|
+
`:nodoc:` tag. Remember, YARD recommends documenting private objects too.
|
66
|
+
This tag exists so that you can create a query (`--query !@private`) to
|
67
|
+
ignore all of these private objects in your documentation. You can also
|
68
|
+
use the new `--no-private` switch, which is a shortcut to the afformentioned
|
69
|
+
query. You can read more about the new tags in the {file:GettingStarted.md}
|
70
|
+
guide.
|
71
|
+
|
72
|
+
Default rake task is now `rake yard`
|
73
|
+
------------------------------------
|
74
|
+
|
75
|
+
Not a big change, but anyone using the default "rake yardoc" task should
|
76
|
+
update their scripts:
|
77
|
+
|
78
|
+
[http://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0](http://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0)
|
79
|
+
|
80
|
+
|
81
|
+
What's New in 0.2.3.x?
|
82
|
+
======================
|
3
83
|
|
4
84
|
1. **Full Ruby 1.9 support**
|
5
85
|
2. **New parser code and handler API for 1.9**
|