yard 0.7.5 → 0.8.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 +10 -2
- data/ChangeLog +1263 -38
- data/LEGAL +5 -5
- data/LICENSE +1 -1
- data/README.md +91 -82
- data/Rakefile +6 -6
- data/benchmarks/builtins_vs_eval.rb +1 -1
- data/benchmarks/erb_vs_erubis.rb +4 -4
- data/benchmarks/generation.rb +5 -5
- data/benchmarks/parsing.rb +2 -2
- data/benchmarks/registry_store_types.rb +48 -0
- data/bin/yard +9 -1
- data/bin/yardoc +9 -1
- data/bin/yri +10 -2
- data/docs/CodeObjects.md +10 -10
- data/docs/GettingStarted.md +85 -83
- data/docs/Handlers.md +21 -21
- data/docs/Overview.md +7 -7
- data/docs/Parser.md +30 -30
- data/docs/Tags.md +250 -554
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +58 -80
- data/docs/WhatsNew.md +378 -133
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +7 -0
- data/docs/templates/default/fulldoc/html/setup.rb +6 -0
- data/docs/templates/default/layout/html/setup.rb +8 -0
- data/docs/templates/default/layout/html/tag_list.erb +11 -0
- data/docs/templates/default/yard_tags/html/list.erb +18 -0
- data/docs/templates/default/yard_tags/html/setup.rb +27 -0
- data/docs/templates/plugin.rb +65 -0
- data/lib/yard.rb +1 -10
- data/lib/yard/autoload.rb +75 -27
- data/lib/yard/cli/command.rb +5 -2
- data/lib/yard/cli/command_parser.rb +3 -2
- data/lib/yard/cli/diff.rb +1 -1
- data/lib/yard/cli/i18n.rb +69 -0
- data/lib/yard/cli/list.rb +1 -1
- data/lib/yard/cli/server.rb +30 -7
- data/lib/yard/cli/stats.rb +5 -6
- data/lib/yard/cli/yardoc.rb +95 -45
- data/lib/yard/cli/yri.rb +24 -3
- data/lib/yard/code_objects/base.rb +35 -4
- data/lib/yard/code_objects/extra_file_object.rb +1 -1
- data/lib/yard/code_objects/macro_object.rb +56 -99
- data/lib/yard/code_objects/method_object.rb +44 -6
- data/lib/yard/config.rb +18 -8
- data/lib/yard/core_ext/symbol_hash.rb +1 -1
- data/lib/yard/docstring.rb +45 -85
- data/lib/yard/docstring_parser.rb +269 -0
- data/lib/yard/handlers/base.rb +129 -118
- data/lib/yard/handlers/c/alias_handler.rb +15 -0
- data/lib/yard/handlers/c/attribute_handler.rb +13 -0
- data/lib/yard/handlers/c/base.rb +110 -0
- data/lib/yard/handlers/c/class_handler.rb +26 -0
- data/lib/yard/handlers/c/constant_handler.rb +12 -0
- data/lib/yard/handlers/c/handler_methods.rb +165 -0
- data/lib/yard/handlers/c/init_handler.rb +16 -0
- data/lib/yard/handlers/c/method_handler.rb +35 -0
- data/lib/yard/handlers/c/mixin_handler.rb +13 -0
- data/lib/yard/handlers/c/module_handler.rb +16 -0
- data/lib/yard/handlers/c/override_comment_handler.rb +22 -0
- data/lib/yard/handlers/c/path_handler.rb +10 -0
- data/lib/yard/handlers/c/struct_handler.rb +12 -0
- data/lib/yard/handlers/c/symbol_handler.rb +7 -0
- data/lib/yard/handlers/processor.rb +41 -30
- data/lib/yard/handlers/ruby/alias_handler.rb +0 -2
- data/lib/yard/handlers/ruby/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/base.rb +10 -6
- data/lib/yard/handlers/ruby/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/dsl_handler.rb +14 -0
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +71 -0
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +0 -3
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/legacy/base.rb +28 -6
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +0 -2
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +18 -0
- data/lib/yard/handlers/ruby/method_handler.rb +10 -15
- data/lib/yard/handlers/ruby/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/module_function_handler.rb +26 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -2
- data/lib/yard/i18n/pot_generator.rb +281 -0
- data/lib/yard/i18n/text.rb +72 -0
- data/lib/yard/logging.rb +3 -7
- data/lib/yard/options.rb +216 -0
- data/lib/yard/parser/c/c_parser.rb +225 -0
- data/lib/yard/parser/c/comment_parser.rb +131 -0
- data/lib/yard/parser/c/statement.rb +63 -0
- data/lib/yard/parser/ruby/ast_node.rb +91 -1
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +7 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +13 -22
- data/lib/yard/parser/ruby/ruby_parser.rb +87 -26
- data/lib/yard/parser/source_parser.rb +89 -88
- data/lib/yard/rake/yardoc_task.rb +1 -1
- data/lib/yard/registry.rb +21 -10
- data/lib/yard/registry_store.rb +48 -0
- data/lib/yard/serializers/file_system_serializer.rb +18 -20
- data/lib/yard/serializers/yardoc_serializer.rb +1 -0
- data/lib/yard/server/adapter.rb +2 -2
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/commands/display_object_command.rb +13 -6
- data/lib/yard/server/commands/frames_command.rb +4 -21
- data/lib/yard/server/commands/library_command.rb +57 -11
- data/lib/yard/server/commands/list_command.rb +10 -34
- data/lib/yard/server/commands/search_command.rb +8 -2
- data/lib/yard/server/doc_server_helper.rb +34 -0
- data/lib/yard/server/rack_adapter.rb +5 -1
- data/lib/yard/server/router.rb +4 -10
- data/lib/yard/server/static_caching.rb +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +0 -15
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +3 -3
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +8 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +1 -1
- data/lib/yard/tags/default_factory.rb +31 -4
- data/lib/yard/tags/directives.rb +593 -0
- data/lib/yard/tags/library.rb +437 -35
- data/lib/yard/templates/engine.rb +17 -12
- data/lib/yard/templates/helpers/base_helper.rb +8 -2
- data/lib/yard/templates/helpers/html_helper.rb +57 -14
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +9 -9
- data/lib/yard/templates/helpers/text_helper.rb +2 -2
- data/lib/yard/templates/template.rb +42 -13
- data/lib/yard/templates/template_options.rb +81 -0
- data/spec/cli/command_parser_spec.rb +4 -4
- data/spec/cli/command_spec.rb +3 -3
- data/spec/cli/config_spec.rb +13 -13
- data/spec/cli/diff_spec.rb +13 -10
- data/spec/cli/gems_spec.rb +12 -12
- data/spec/cli/help_spec.rb +2 -2
- data/spec/cli/i18n_spec.rb +111 -0
- data/spec/cli/server_spec.rb +66 -18
- data/spec/cli/stats_spec.rb +15 -15
- data/spec/cli/yardoc_spec.rb +124 -97
- data/spec/cli/yri_spec.rb +14 -12
- data/spec/code_objects/base_spec.rb +104 -46
- data/spec/code_objects/class_object_spec.rb +33 -33
- data/spec/code_objects/code_object_list_spec.rb +5 -5
- data/spec/code_objects/constants_spec.rb +4 -3
- data/spec/code_objects/extra_file_object_spec.rb +19 -19
- data/spec/code_objects/macro_object_spec.rb +31 -37
- data/spec/code_objects/method_object_spec.rb +46 -23
- data/spec/code_objects/module_object_spec.rb +16 -16
- data/spec/code_objects/namespace_object_spec.rb +6 -6
- data/spec/code_objects/proxy_spec.rb +19 -19
- data/spec/config_spec.rb +33 -24
- data/spec/core_ext/array_spec.rb +1 -1
- data/spec/core_ext/file_spec.rb +8 -8
- data/spec/core_ext/hash_spec.rb +1 -1
- data/spec/core_ext/insertion_spec.rb +3 -3
- data/spec/core_ext/module_spec.rb +1 -1
- data/spec/core_ext/string_spec.rb +6 -6
- data/spec/core_ext/symbol_hash_spec.rb +11 -11
- data/spec/docstring_parser_spec.rb +207 -0
- data/spec/docstring_spec.rb +33 -146
- data/spec/handlers/alias_handler_spec.rb +14 -14
- data/spec/handlers/attribute_handler_spec.rb +20 -20
- data/spec/handlers/base_spec.rb +16 -16
- data/spec/handlers/c/alias_handler_spec.rb +33 -0
- data/spec/handlers/c/attribute_handler_spec.rb +40 -0
- data/spec/handlers/c/class_handler_spec.rb +64 -0
- data/spec/handlers/c/constant_handler_spec.rb +68 -0
- data/spec/handlers/c/init_handler_spec.rb +36 -0
- data/spec/handlers/c/method_handler_spec.rb +228 -0
- data/spec/handlers/c/mixin_handler_spec.rb +27 -0
- data/spec/handlers/c/module_handler_spec.rb +38 -0
- data/spec/handlers/c/override_comment_handler_spec.rb +43 -0
- data/spec/handlers/c/path_handler_spec.rb +35 -0
- data/spec/handlers/c/spec_helper.rb +11 -0
- data/spec/handlers/c/struct_handler_spec.rb +15 -0
- data/spec/handlers/class_condition_handler_spec.rb +10 -10
- data/spec/handlers/class_handler_spec.rb +38 -38
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +7 -7
- data/spec/handlers/{macro_handler_spec.rb → dsl_handler_spec.rb} +72 -53
- data/spec/handlers/examples/alias_handler_001.rb.txt +5 -5
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/class_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/dsl_handler_001.rb.txt +110 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +14 -14
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +2 -2
- data/spec/handlers/examples/method_handler_001.rb.txt +16 -16
- data/spec/handlers/examples/mixin_handler_001.rb.txt +8 -4
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -3
- data/spec/handlers/examples/yield_handler_001.rb.txt +13 -14
- data/spec/handlers/exception_handler_spec.rb +9 -9
- data/spec/handlers/extend_handler_spec.rb +2 -2
- data/spec/handlers/legacy_base_spec.rb +34 -34
- data/spec/handlers/method_condition_handler_spec.rb +2 -2
- data/spec/handlers/method_handler_spec.rb +33 -33
- data/spec/handlers/mixin_handler_spec.rb +13 -9
- data/spec/handlers/module_function_handler_spec.rb +82 -0
- data/spec/handlers/module_handler_spec.rb +6 -6
- data/spec/handlers/private_constant_handler_spec.rb +3 -3
- data/spec/handlers/processor_spec.rb +5 -5
- data/spec/handlers/ruby/base_spec.rb +10 -6
- data/spec/handlers/ruby/legacy/base_spec.rb +11 -7
- data/spec/handlers/spec_helper.rb +2 -3
- data/spec/handlers/visibility_handler_spec.rb +6 -6
- data/spec/handlers/yield_handler_spec.rb +8 -8
- data/spec/i18n/pot_generator_spec.rb +244 -0
- data/spec/i18n/text_spec.rb +69 -0
- data/spec/options_spec.rb +160 -0
- data/spec/parser/base_spec.rb +3 -3
- data/spec/parser/c_parser_spec.rb +31 -257
- data/spec/parser/examples/array.c.txt +187 -187
- data/spec/parser/examples/extrafile.c.txt +1 -1
- data/spec/parser/examples/override.c.txt +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +1 -1
- data/spec/parser/ruby/legacy/statement_list_spec.rb +24 -24
- data/spec/parser/ruby/legacy/token_list_spec.rb +7 -7
- data/spec/parser/ruby/ruby_parser_spec.rb +56 -34
- data/spec/parser/source_parser_spec.rb +125 -65
- data/spec/parser/tag_parsing_spec.rb +4 -4
- data/spec/rake/yardoc_task_spec.rb +10 -8
- data/spec/registry_spec.rb +65 -36
- data/spec/registry_store_spec.rb +90 -40
- data/spec/serializers/file_system_serializer_spec.rb +12 -12
- data/spec/serializers/yardoc_serializer_spec.rb +2 -2
- data/spec/server/adapter_spec.rb +3 -3
- data/spec/server/commands/base_spec.rb +8 -8
- data/spec/server/commands/library_command_spec.rb +3 -3
- data/spec/server/commands/static_file_command_spec.rb +7 -7
- data/spec/server/doc_server_helper_spec.rb +1 -1
- data/spec/server/doc_server_serializer_spec.rb +6 -6
- data/spec/server/rack_adapter_spec.rb +3 -3
- data/spec/server/router_spec.rb +19 -19
- data/spec/server/static_caching_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -7
- data/spec/tags/default_factory_spec.rb +24 -16
- data/spec/tags/directives_spec.rb +422 -0
- data/spec/tags/library_spec.rb +15 -4
- data/spec/tags/overload_tag_spec.rb +6 -6
- data/spec/tags/ref_tag_list_spec.rb +8 -8
- data/spec/templates/class_spec.rb +7 -7
- data/spec/templates/constant_spec.rb +7 -7
- data/spec/templates/engine_spec.rb +28 -36
- data/spec/templates/examples/class001.html +108 -108
- data/spec/templates/examples/class002.html +17 -17
- data/spec/templates/examples/constant001.txt +1 -1
- data/spec/templates/examples/method001.html +45 -45
- data/spec/templates/examples/method002.html +25 -25
- data/spec/templates/examples/method003.html +60 -60
- data/spec/templates/examples/method004.html +7 -7
- data/spec/templates/examples/method005.html +28 -28
- data/spec/templates/examples/module001.html +321 -321
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/examples/module002.html +130 -130
- data/spec/templates/examples/module003.html +74 -74
- data/spec/templates/examples/module004.html +388 -0
- data/spec/templates/helpers/base_helper_spec.rb +32 -32
- data/spec/templates/helpers/html_helper_spec.rb +87 -68
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +9 -9
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +16 -16
- data/spec/templates/helpers/markup_helper_spec.rb +31 -28
- data/spec/templates/helpers/method_helper_spec.rb +7 -7
- data/spec/templates/helpers/shared_signature_examples.rb +9 -7
- data/spec/templates/helpers/text_helper_spec.rb +3 -3
- data/spec/templates/method_spec.rb +13 -13
- data/spec/templates/module_spec.rb +70 -24
- data/spec/templates/onefile_spec.rb +32 -15
- data/spec/templates/section_spec.rb +23 -23
- data/spec/templates/spec_helper.rb +31 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +54 -46
- data/spec/verifier_spec.rb +5 -5
- data/templates/default/class/setup.rb +2 -2
- data/templates/default/docstring/html/abstract.erb +1 -1
- data/templates/default/docstring/html/note.erb +1 -1
- data/templates/default/docstring/html/private.erb +1 -1
- data/templates/default/docstring/html/todo.erb +1 -1
- data/templates/default/docstring/setup.rb +2 -2
- data/templates/default/fulldoc/html/css/full_list.css +4 -2
- data/templates/default/fulldoc/html/css/style.css +50 -44
- data/templates/default/fulldoc/html/frames.erb +21 -6
- data/templates/default/fulldoc/html/full_list.erb +5 -3
- data/templates/default/fulldoc/html/{full_list_files.erb → full_list_file.erb} +0 -0
- data/templates/default/fulldoc/html/js/app.js +29 -26
- data/templates/default/fulldoc/html/js/full_list.js +9 -9
- data/templates/default/fulldoc/html/js/jquery.js +4 -16
- data/templates/default/fulldoc/html/setup.rb +42 -38
- data/templates/default/layout/dot/header.erb +1 -1
- data/templates/default/layout/html/breadcrumb.erb +6 -6
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/footer.erb +1 -1
- data/templates/default/layout/html/headers.erb +3 -6
- data/templates/default/layout/html/index.erb +1 -1
- data/templates/default/layout/html/layout.erb +3 -7
- data/templates/default/layout/html/objects.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +5 -0
- data/templates/default/layout/html/search.erb +4 -1
- data/templates/default/layout/html/setup.rb +8 -8
- data/templates/default/method_details/html/method_signature.erb +10 -3
- data/templates/default/method_details/setup.rb +1 -0
- data/templates/default/module/dot/info.erb +1 -1
- data/templates/default/module/dot/setup.rb +2 -2
- data/templates/default/module/html/attribute_details.erb +1 -1
- data/templates/default/module/html/children.erb +1 -1
- data/templates/default/module/html/defines.erb +1 -1
- data/templates/default/module/html/inherited_methods.erb +5 -4
- data/templates/default/module/html/item_summary.erb +15 -5
- data/templates/default/module/html/method_details_list.erb +2 -2
- data/templates/default/module/setup.rb +25 -12
- data/templates/default/module/text/setup.rb +1 -1
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +2 -2
- data/templates/default/tags/html/example.erb +4 -2
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/overload.erb +1 -1
- data/templates/default/tags/html/see.erb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/default/tags/setup.rb +4 -3
- data/templates/guide/fulldoc/html/css/style.css +8 -8
- data/templates/guide/fulldoc/html/js/app.js +6 -6
- data/templates/guide/fulldoc/html/setup.rb +12 -12
- data/templates/guide/layout/html/layout.erb +11 -11
- data/templates/guide/layout/html/setup.rb +9 -9
- data/templates/guide/method/html/header.erb +2 -2
- data/templates/guide/method/html/setup.rb +1 -1
- metadata +68 -18
- data/bin/yard-graph +0 -4
- data/bin/yard-server +0 -4
- data/docs/Glossary.md +0 -12
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +0 -39
- data/lib/yard/handlers/ruby/macro_handler.rb +0 -40
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +0 -131
- data/lib/yard/parser/c_parser.rb +0 -497
- data/lib/yard/server/templates/default/layout/html/headers.erb +0 -16
- data/lib/yard/server/templates/doc_server/frames/html/frames.erb +0 -13
- data/lib/yard/server/templates/doc_server/frames/html/setup.rb +0 -3
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +0 -34
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +0 -20
- data/spec/handlers/examples/macro_handler_001.rb.txt +0 -83
data/benchmarks/erb_vs_erubis.rb
CHANGED
@@ -17,7 +17,7 @@ Benchmark.bmbm do |x|
|
|
17
17
|
def erb_with(str, x) Erubis::Eruby.new(str) end
|
18
18
|
end end end
|
19
19
|
eof
|
20
|
-
|
20
|
+
|
21
21
|
rungen
|
22
22
|
end
|
23
23
|
|
@@ -27,7 +27,7 @@ Benchmark.bmbm do |x|
|
|
27
27
|
def erb_with(str, x) Erubis::FastEruby.new(str) end
|
28
28
|
end end end
|
29
29
|
eof
|
30
|
-
|
30
|
+
|
31
31
|
rungen
|
32
32
|
end
|
33
33
|
|
@@ -37,7 +37,7 @@ Benchmark.bmbm do |x|
|
|
37
37
|
def erb_with(str, x) Erubis::TinyEruby.new(str) end
|
38
38
|
end end end
|
39
39
|
eof
|
40
|
-
|
40
|
+
|
41
41
|
rungen
|
42
42
|
end
|
43
43
|
|
@@ -47,7 +47,7 @@ Benchmark.bmbm do |x|
|
|
47
47
|
def erb_with(str, x) ERB.new(str, nil) end
|
48
48
|
end end end
|
49
49
|
eof
|
50
|
-
|
50
|
+
|
51
51
|
rungen
|
52
52
|
end
|
53
53
|
end
|
data/benchmarks/generation.rb
CHANGED
@@ -2,20 +2,20 @@ require "benchmark"
|
|
2
2
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
|
3
3
|
|
4
4
|
unless YARD::CodeObjects::Proxy.private_instance_methods.include?('to_obj')
|
5
|
-
raise "This benchmark is dependent on YARD::CodeObjects::Proxy#to_obj"
|
5
|
+
raise "This benchmark is dependent on YARD::CodeObjects::Proxy#to_obj"
|
6
6
|
end
|
7
7
|
|
8
8
|
def rungen
|
9
9
|
YARD::Registry.clear
|
10
|
-
YARD::CLI::Yardoc.run('--quiet', '--use-cache')
|
10
|
+
YARD::CLI::Yardoc.run('--quiet', '--use-cache')
|
11
11
|
end
|
12
12
|
|
13
13
|
def redef(lock = false)
|
14
14
|
eval <<-eof
|
15
|
-
class YARD::CodeObjects::Proxy;
|
15
|
+
class YARD::CodeObjects::Proxy;
|
16
16
|
def to_obj
|
17
|
-
@obj #{lock ? '||' : ''}= YARD::Registry.resolve(@namespace, @name)
|
18
|
-
end
|
17
|
+
@obj #{lock ? '||' : ''}= YARD::Registry.resolve(@namespace, @name)
|
18
|
+
end
|
19
19
|
end
|
20
20
|
eof
|
21
21
|
end
|
data/benchmarks/parsing.rb
CHANGED
@@ -15,8 +15,8 @@ PATH_ORDER = [
|
|
15
15
|
]
|
16
16
|
|
17
17
|
Benchmark.bmbm do |x|
|
18
|
-
x.report("parse in order") { YARD::Registry.clear; YARD.parse PATH_ORDER, [], Logger::ERROR }
|
19
|
-
x.report("parse") { YARD::Registry.clear; YARD.parse 'lib/**/*.rb', [], Logger::ERROR }
|
18
|
+
x.report("parse in order") { YARD::Registry.clear; YARD.parse PATH_ORDER, [], Logger::ERROR }
|
19
|
+
x.report("parse") { YARD::Registry.clear; YARD.parse 'lib/**/*.rb', [], Logger::ERROR }
|
20
20
|
end
|
21
21
|
|
22
22
|
=begin
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
|
3
|
+
|
4
|
+
def parse_and_select_objects
|
5
|
+
YARD::Registry.load_yardoc(File.join(File.dirname(__FILE__), '..', '.yardoc'))
|
6
|
+
YARD::Registry.load_all
|
7
|
+
$paths = []
|
8
|
+
4.times { $paths << YARD::Registry.paths[rand(YARD::Registry.paths.size)] }
|
9
|
+
|
10
|
+
$regular_registry = {}
|
11
|
+
$types_registry = {}
|
12
|
+
YARD::Registry.all.each do |object|
|
13
|
+
$regular_registry[object.path] = object
|
14
|
+
($types_registry[object.type] ||= {})[object.path] = object
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_lookup
|
19
|
+
$paths.select {|path| $regular_registry[path] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_lookup_with_types
|
23
|
+
$paths.select {|path| $types_registry.values.find {|list| list[path] } }
|
24
|
+
end
|
25
|
+
|
26
|
+
TIMES = 100_000
|
27
|
+
|
28
|
+
parse_and_select_objects
|
29
|
+
p $paths
|
30
|
+
Benchmark.bmbm do |x|
|
31
|
+
x.report("normal") { TIMES.times { run_lookup } }
|
32
|
+
x.report("types") { TIMES.times { run_lookup_with_types } }
|
33
|
+
end
|
34
|
+
|
35
|
+
__END__
|
36
|
+
# Run on March 22 2012
|
37
|
+
["YARD::Parser::Ruby::Legacy::RubyToken::TkUnknownChar#initialize",
|
38
|
+
"YARD::Parser::C::CParser#enumerator",
|
39
|
+
"YARD::CodeObjects::ClassObject#inherited_meths",
|
40
|
+
"YARD::Parser::C::Statement#source="]
|
41
|
+
Rehearsal ----------------------------------------------
|
42
|
+
normal 0.180000 0.000000 0.180000 ( 0.182640)
|
43
|
+
types 1.150000 0.010000 1.160000 ( 1.160219)
|
44
|
+
------------------------------------- total: 1.340000sec
|
45
|
+
|
46
|
+
user system total real
|
47
|
+
normal 0.170000 0.000000 0.170000 ( 0.165621)
|
48
|
+
types 1.140000 0.000000 1.140000 ( 1.142269)
|
data/bin/yard
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
# We do all this work just to find the proper load path
|
4
|
+
path = __FILE__
|
5
|
+
while File.symlink?(path)
|
6
|
+
path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
|
7
|
+
end
|
8
|
+
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
|
9
|
+
|
10
|
+
require 'yard'
|
3
11
|
|
4
12
|
YARD::CLI::CommandParser.run(*ARGV)
|
data/bin/yardoc
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
# We do all this work just to find the proper load path
|
4
|
+
path = __FILE__
|
5
|
+
while File.symlink?(path)
|
6
|
+
path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
|
7
|
+
end
|
8
|
+
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
|
9
|
+
|
10
|
+
require 'yard'
|
3
11
|
|
4
12
|
YARD::CLI::Yardoc.run(*ARGV)
|
data/bin/yri
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '/../lib/yard'
|
3
2
|
|
4
|
-
|
3
|
+
# We do all this work just to find the proper load path
|
4
|
+
path = __FILE__
|
5
|
+
while File.symlink?(path)
|
6
|
+
path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
|
7
|
+
end
|
8
|
+
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
|
9
|
+
|
10
|
+
require 'yard'
|
11
|
+
|
12
|
+
YARD::CLI::YRI.run(*ARGV)
|
data/docs/CodeObjects.md
CHANGED
@@ -14,9 +14,9 @@ and non-namespace objects. A namespace object refers to any object in Ruby that
|
|
14
14
|
other objects defined inside of it. In the context of Ruby, this specifically means
|
15
15
|
modules and classes (both of which are subclasses of `NamespaceObject`). These objects
|
16
16
|
act like tree structures, maintaining a list of all of their direct children. All non
|
17
|
-
namespace objects are simply subclasses of the Base class. The {YARD::CodeObjects::RootObject RootObject}
|
17
|
+
namespace objects are simply subclasses of the Base class. The {YARD::CodeObjects::RootObject RootObject}
|
18
18
|
is a special kind of `NamespaceObject` which refers to the top level namespace in Ruby.
|
19
|
-
Methods that accept a namespace object as a parameter should also accept the symbol
|
19
|
+
Methods that accept a namespace object as a parameter should also accept the symbol
|
20
20
|
`:root` as a shortcut for the root object.
|
21
21
|
|
22
22
|
The following is an overview of the classes within the `CodeObjects` namespace:
|
@@ -27,7 +27,7 @@ The following is an overview of the classes within the `CodeObjects` namespace:
|
|
27
27
|
|
28
28
|
All CodeObjects are uniquely defined by their implementation of {YARD::CodeObjects::Base#path}.
|
29
29
|
This path is used to locate or store a code object in the {YARD::Registry}. It is therefore
|
30
|
-
essential that any Base subclass return a unique String value for #path so that the
|
30
|
+
essential that any Base subclass return a unique String value for #path so that the
|
31
31
|
object may co-exist with other objects in the Registry.
|
32
32
|
|
33
33
|
In practice, a path is simply the conventional Ruby representation of a class,
|
@@ -46,7 +46,7 @@ CodeObjects classes are coupled with the {YARD::Registry} class which keeps trac
|
|
46
46
|
all instantiated code objects. This is an explicit design choice to allow objects
|
47
47
|
to be fetched, cached, imported and exported from a centralized location. As mentioned
|
48
48
|
above, this coupling is a result of the fact that each object is uniquely identified by
|
49
|
-
its path, which is used to implement lookups. You can read more about the registry
|
49
|
+
its path, which is used to implement lookups. You can read more about the registry
|
50
50
|
in the {YARD::Registry} class.
|
51
51
|
|
52
52
|
## Identity Map
|
@@ -57,7 +57,7 @@ allows developers to create a code object without checking if it already exists
|
|
57
57
|
the {YARD::Registry}. The following example will only create one object:
|
58
58
|
|
59
59
|
id = ClassObject.new(:root, "MyClass").object_id #=> 13352
|
60
|
-
ClassObject.new(:root, "MyClass").object_id #=> 13352
|
60
|
+
ClassObject.new(:root, "MyClass").object_id #=> 13352
|
61
61
|
|
62
62
|
## Proxy Objects
|
63
63
|
|
@@ -69,8 +69,8 @@ attributes of a proxy are accessed, it will immediately be resolved to the objec
|
|
69
69
|
at its declared path. In the case where such an object exists, it will act as
|
70
70
|
a delegate to the object. However, if the object does not exist, a warning will
|
71
71
|
be raised. Whenever arbitrary code objects are used, care should be taken in
|
72
|
-
order to make sure attributes are not accessed on unresolvable proxies. An
|
73
|
-
unresolvable proxy will return a class name of `Proxy` and #type of `:proxy`,
|
72
|
+
order to make sure attributes are not accessed on unresolvable proxies. An
|
73
|
+
unresolvable proxy will return a class name of `Proxy` and #type of `:proxy`,
|
74
74
|
for example:
|
75
75
|
|
76
76
|
P(:InvalidObject).type == :proxy #=> true
|
@@ -85,8 +85,8 @@ it is possible to simply do:
|
|
85
85
|
|
86
86
|
object = MethodObject.new(:root, "my_method")
|
87
87
|
object[:modified_at] = Time.now
|
88
|
-
|
89
|
-
This value can now be retrieved on this object both by the hash `[]` syntax as
|
88
|
+
|
89
|
+
This value can now be retrieved on this object both by the hash `[]` syntax as
|
90
90
|
well as like any other method:
|
91
91
|
|
92
92
|
object.modified_at #=> 2009-06-03 20:08:46 -0400
|
@@ -111,5 +111,5 @@ following is an implementation of the path for a hypothetical `FooObject`:
|
|
111
111
|
end
|
112
112
|
|
113
113
|
Note that if our FooObject is a `NamespaceObject`, meaning if it can have child
|
114
|
-
FooObjects defined inside of it, you may need to verify that the prefix is only
|
114
|
+
FooObjects defined inside of it, you may need to verify that the prefix is only
|
115
115
|
applied once.
|
data/docs/GettingStarted.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Getting Started with YARD
|
4
4
|
|
5
|
-
There are a few ways which YARD can be of use to you or your project. This
|
5
|
+
There are a few ways which YARD can be of use to you or your project. This
|
6
6
|
document will cover the most common ways to use YARD:
|
7
7
|
|
8
8
|
* [Documenting Code with YARD](#docing)
|
@@ -25,12 +25,12 @@ manner, YARD recommends declaring your parameters, return types, etc. with
|
|
25
25
|
the `@tag` syntax, which makes outputting the documentation more consistent
|
26
26
|
and easier to read. Consider the RDoc documentation for a method to_format:
|
27
27
|
|
28
|
-
# Converts the object into textual markup given a specific `format`
|
28
|
+
# Converts the object into textual markup given a specific `format`
|
29
29
|
# (defaults to `:html`)
|
30
30
|
#
|
31
31
|
# == Parameters:
|
32
32
|
# format::
|
33
|
-
# A Symbol declaring the format to convert the object to. This
|
33
|
+
# A Symbol declaring the format to convert the object to. This
|
34
34
|
# can be `:text` or `:html`.
|
35
35
|
#
|
36
36
|
# == Returns:
|
@@ -40,7 +40,7 @@ and easier to read. Consider the RDoc documentation for a method to_format:
|
|
40
40
|
def to_format(format = :html)
|
41
41
|
# format the object
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
While this may seem easy enough to read and understand, it's hard for a machine
|
45
45
|
to properly pull this data back out of our documentation. Also we've tied our
|
46
46
|
markup to our content, and now our documentation becomes hard to maintain if
|
@@ -56,7 +56,7 @@ In YARD, we would simply define our method as:
|
|
56
56
|
def to_format(format = :html)
|
57
57
|
# format the object
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
Using tags we can add semantic metadata to our code without worrying about
|
61
61
|
presentation. YARD will handle presentation for us when we decide to generate
|
62
62
|
documentation later.
|
@@ -64,17 +64,17 @@ documentation later.
|
|
64
64
|
## Which Markup Format?
|
65
65
|
|
66
66
|
YARD does not impose a specific markup. The above example uses standard RDoc
|
67
|
-
markup formatting, but YARD also supports textile and markdown via the
|
67
|
+
markup formatting, but YARD also supports textile and markdown via the
|
68
68
|
command-line switch or `.yardopts` file (see below). This means that you are
|
69
69
|
free to use whatever formatting you like. This guide is actually written
|
70
|
-
using markdown. YARD, however, does add a few important syntaxes that are
|
71
|
-
processed no matter which markup formatting you use, such as tag support
|
70
|
+
using markdown. YARD, however, does add a few important syntaxes that are
|
71
|
+
processed no matter which markup formatting you use, such as tag support
|
72
72
|
and inter-document linking. These syntaxes are discussed below.
|
73
73
|
|
74
74
|
## Adding Tags to Documentation
|
75
75
|
|
76
|
-
The tag syntax that YARD uses is the same @tag-style syntax you may have seen
|
77
|
-
if you've ever coded in Java, Python, PHP, Objective-C or a myriad of other
|
76
|
+
The tag syntax that YARD uses is the same @tag-style syntax you may have seen
|
77
|
+
if you've ever coded in Java, Python, PHP, Objective-C or a myriad of other
|
78
78
|
languages. The following tag adds an author tag to your class:
|
79
79
|
|
80
80
|
# @author Loren Segal
|
@@ -89,11 +89,11 @@ lines following a tag as part of the tag data. For example:
|
|
89
89
|
# The new method accepts the same parameters.
|
90
90
|
def mymethod
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
### List of Tags
|
94
94
|
|
95
|
-
A list of tags can be found in {file:docs/Tags.md#taglist}
|
96
|
-
|
95
|
+
A list of tags can be found in {file:docs/Tags.md#taglist}
|
96
|
+
|
97
97
|
### Reference Tags
|
98
98
|
|
99
99
|
To reduce the amount of duplication in writing documentation for repetitive
|
@@ -112,7 +112,7 @@ from that docstring/tag into your current object. Consider the example:
|
|
112
112
|
# (see #get)
|
113
113
|
def post(request) "hello" end
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
The above `#post` method takes the docstring and all tags (`param` and `return`)
|
117
117
|
of the `#get` method. When you generate HTML documentation, you will see this
|
118
118
|
duplication automatically, so you don't have to manually type it out. We can
|
@@ -122,14 +122,14 @@ whatever we write will be appended to the docstring:
|
|
122
122
|
# (see #get)
|
123
123
|
# @note This method may modify our application state!
|
124
124
|
def post(request) self.state += 1; "hello" end
|
125
|
-
|
125
|
+
|
126
126
|
Here we added another tag, but we could have also added plain text. The
|
127
127
|
text must be appended *after* the `(see ...)` statement, preferably on
|
128
128
|
a separate line.
|
129
129
|
|
130
|
-
Note that we don't have to "refer" the whole docstring. We can also link
|
131
|
-
individual tags instead. Since "get" and "post" actually have different
|
132
|
-
descriptions, a more accurate example would be to only refer our parameter
|
130
|
+
Note that we don't have to "refer" the whole docstring. We can also link
|
131
|
+
individual tags instead. Since "get" and "post" actually have different
|
132
|
+
descriptions, a more accurate example would be to only refer our parameter
|
133
133
|
and return tags:
|
134
134
|
|
135
135
|
class MyWebServer
|
@@ -137,14 +137,14 @@ and return tags:
|
|
137
137
|
# @param [Request] request the request object
|
138
138
|
# @return [String] the resulting webpage
|
139
139
|
def get(request) "hello" end
|
140
|
-
|
140
|
+
|
141
141
|
# Handles a POST request
|
142
142
|
# @note This method may modify our application state!
|
143
143
|
# @param (see #get)
|
144
144
|
# @return (see #get)
|
145
145
|
def post(request) self.state += 1; "hello" end
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
The above copies all of the param and return tags from `#get`. Note that you
|
149
149
|
cannot copy individual tags of a specific type with this syntax.
|
150
150
|
|
@@ -157,32 +157,33 @@ with or without a types field.
|
|
157
157
|
# @return [String, nil] the contents of our object or nil
|
158
158
|
# if the object has not been filled with data.
|
159
159
|
def validate; end
|
160
|
-
|
160
|
+
|
161
161
|
# We don't care about the "type" here:
|
162
162
|
# @return the object
|
163
163
|
def to_obj; end
|
164
|
-
|
164
|
+
|
165
165
|
The list of types is in the form `[type1, type2, ...]` and is mostly free-form,
|
166
166
|
so we can also specify duck-types or constant values. For example:
|
167
167
|
|
168
168
|
# @param [#to_s] argname any object that responds to `#to_s`
|
169
169
|
# @param [true, false] argname only true or false
|
170
|
-
|
171
|
-
Note the
|
172
|
-
|
170
|
+
|
171
|
+
Note the latter example can be replaced by the meta-type "Boolean".
|
172
|
+
Another meta-type is "void", which stands for "no meaningful value"
|
173
|
+
and is used for return values. These meta-types are by convention
|
173
174
|
only, but are recommended.
|
174
|
-
|
175
|
+
|
175
176
|
List types can be specified in the form `CollectionClass<ElementType, ...>`.
|
176
177
|
For instance, consider the following Array that holds a set of Strings and
|
177
178
|
Symbols:
|
178
|
-
|
179
|
+
|
179
180
|
# @param [Array<String, Symbol>] list the list of strings and symbols.
|
180
|
-
|
181
|
+
|
181
182
|
We mentioned that these type fields are "mostly" free-form. In truth, they
|
182
183
|
are defined "by convention". To view samples of common type specifications
|
183
|
-
and recommended conventions for writing type specifications, see
|
184
|
-
[http://yardoc.org/types.html](http://yardoc.org/types.html). Note that these
|
185
|
-
conventions may change every now and then, although we are working on a more
|
184
|
+
and recommended conventions for writing type specifications, see
|
185
|
+
[http://yardoc.org/types.html](http://yardoc.org/types.html). Note that these
|
186
|
+
conventions may change every now and then, although we are working on a more
|
186
187
|
"formal" type specification proposal.
|
187
188
|
|
188
189
|
## Documenting DSL Methods
|
@@ -197,53 +198,53 @@ a typed attribute for a database model. The code might look like:
|
|
197
198
|
|
198
199
|
class Post
|
199
200
|
include DataMapper::Resource
|
200
|
-
|
201
|
+
|
201
202
|
property :title, String
|
202
203
|
end
|
203
|
-
|
204
|
+
|
204
205
|
As of version 0.7.0, YARD will automatically pick up on these basic methods if
|
205
206
|
you document them with a docstring. Therefore, simply adding some comments to
|
206
207
|
the code will cause it to generate documentation:
|
207
208
|
|
208
209
|
class Post
|
209
210
|
include DataMapper::Resource
|
210
|
-
|
211
|
+
|
211
212
|
# @return [String] the title property of the post
|
212
213
|
property :title, String
|
213
214
|
end
|
214
215
|
|
215
216
|
Note that YARD uses the first argument in the method call to determine the
|
216
217
|
method name. In some cases, this would not be the method name, and you would
|
217
|
-
need to declare it manually. You can do so with the
|
218
|
+
need to declare it manually. You can do so with the `@!method` directive:
|
218
219
|
|
219
|
-
#
|
220
|
+
# @!method foo
|
220
221
|
create_a_foo_method
|
221
|
-
|
222
|
-
The @method tag can also accept a full method signature with parameters:
|
223
222
|
|
224
|
-
|
223
|
+
The @!method directive can also accept a full method signature with parameters:
|
224
|
+
|
225
|
+
# @!method foo(name, opts = {})
|
225
226
|
create_a_foo_method
|
226
227
|
|
227
228
|
You can also set visibility and scope, or modify the method signature with
|
228
229
|
extra tags. The following adds documentation for a private class method:
|
229
230
|
|
230
|
-
#
|
231
|
+
# @!method foo(opts = {})
|
231
232
|
# The foo method!
|
232
|
-
#
|
233
|
-
#
|
233
|
+
# @!scope class
|
234
|
+
# @!visibility private
|
234
235
|
create_a_private_foo_class_method
|
235
|
-
|
236
|
-
Finally, you can tag a method as an attribute by replacing the @method
|
237
|
-
tag with @attribute. The @attribute tag allows for the flags [r], [w], or
|
238
|
-
[rw] to declare a readonly, writeonly, or readwrite attribute, respectively.
|
239
236
|
|
240
|
-
|
237
|
+
Finally, you can tag a method as an attribute by replacing the @!method
|
238
|
+
tag with @!attribute. The @!attribute directive allows for the flags [r], [w],
|
239
|
+
or [rw] to declare a readonly, writeonly, or readwrite attribute, respectively.
|
240
|
+
|
241
|
+
# @!attribute [w]
|
241
242
|
# The writeonly foo attribute!
|
242
243
|
a_writeonly_attribute :foo
|
243
|
-
|
244
|
+
|
244
245
|
(Note that if the name can be automatically detected, you do not need to
|
245
|
-
specify it in the
|
246
|
-
|
246
|
+
specify it in the @!method or @!attribute directives)
|
247
|
+
|
247
248
|
However, you will notice a few drawbacks with this basic support:
|
248
249
|
|
249
250
|
1. There is a fair bit of duplication in such documentation. Specifically, we
|
@@ -252,7 +253,7 @@ However, you will notice a few drawbacks with this basic support:
|
|
252
253
|
If we do not write a comment, it is ignored.
|
253
254
|
|
254
255
|
### Macros
|
255
|
-
|
256
|
+
|
256
257
|
Fortunately YARD 0.7.0 also adds macros, a powerful way to add support for
|
257
258
|
these DSL methods on the fly without writing extra plugins. Macros allow
|
258
259
|
you to interpolate arguments from the method call inside the docstring,
|
@@ -261,8 +262,8 @@ using a macro, it might look like:
|
|
261
262
|
|
262
263
|
class Post
|
263
264
|
include DataMapper::Resource
|
264
|
-
|
265
|
-
#
|
265
|
+
|
266
|
+
# @!macro dm.property
|
266
267
|
# @return [$2] the $1 $0 of the post
|
267
268
|
property :title, String
|
268
269
|
end
|
@@ -275,7 +276,7 @@ section. There is also some extra benefit to using this macro, in that we
|
|
275
276
|
can re-apply it to any other property in our class by simply calling on
|
276
277
|
the macro. The following:
|
277
278
|
|
278
|
-
#
|
279
|
+
# @!macro dm.property
|
279
280
|
property :view_count, Integer
|
280
281
|
|
281
282
|
Would be equivalent to:
|
@@ -292,7 +293,7 @@ by using this snippet:
|
|
292
293
|
class Post
|
293
294
|
include DataMapper::Resource
|
294
295
|
|
295
|
-
#
|
296
|
+
# @!macro [attach] dm.property
|
296
297
|
# @return [$2] the $1 $0 of the post
|
297
298
|
property :title, String
|
298
299
|
property :view_count, Integer
|
@@ -315,7 +316,7 @@ To link another "object" (class, method, module, etc.), use the format:
|
|
315
316
|
{ObjectName#method OPTIONAL_TITLE}
|
316
317
|
{Class::CONSTANT My constant's title}
|
317
318
|
{#method_inside_current_namespace}
|
318
|
-
|
319
|
+
|
319
320
|
Without an explicit title, YARD will use the relative path to the object as
|
320
321
|
the link name. Note that you can also use relative paths inside the object
|
321
322
|
path to refer to an object inside the same namespace as your current docstring.
|
@@ -345,7 +346,7 @@ via the command-line. Consider the following examples:
|
|
345
346
|
|
346
347
|
{file:docs/GettingStarted.md Getting Started}
|
347
348
|
{file:mypage.html Name#anchor}
|
348
|
-
|
349
|
+
|
349
350
|
As shown, you can also add an optional `#anchor` if the page is an HTML link.
|
350
351
|
|
351
352
|
### Embedding Docstrings `{include:...}`
|
@@ -358,17 +359,17 @@ embed a docstring (minus tags) at a specific point in the text.
|
|
358
359
|
# This class is cool
|
359
360
|
# @abstract
|
360
361
|
class Foo; end
|
361
|
-
|
362
|
+
|
362
363
|
# This is another class. {include:Foo} too!
|
363
364
|
class Bar; end
|
364
|
-
|
365
|
-
The docstring for Bar becomes:
|
365
|
+
|
366
|
+
The docstring for Bar becomes:
|
366
367
|
|
367
368
|
"This is another class. This class is cool too!"
|
368
369
|
|
369
370
|
### Embedding Files `{include:file:...}`
|
370
371
|
|
371
|
-
You can embed the contents of files using `{include:file:path/to/file}`,
|
372
|
+
You can embed the contents of files using `{include:file:path/to/file}`,
|
372
373
|
similar to the `{include:OBJECT}` tag above. If the file uses a specific markup
|
373
374
|
type, it will be applied and embedded as marked up text. The following
|
374
375
|
shows how the tag can be used inside of comments:
|
@@ -376,7 +377,7 @@ shows how the tag can be used inside of comments:
|
|
376
377
|
# Here is an example of a highlighted Ruby file:
|
377
378
|
#
|
378
379
|
# {include:file:examples/test.rb}
|
379
|
-
|
380
|
+
|
380
381
|
### Rendering Objects `{render:...}`
|
381
382
|
|
382
383
|
Entire objects can also be rendered in place in documentation. This can be
|
@@ -384,17 +385,18 @@ used for guide-style documentation which does not document the entire source
|
|
384
385
|
tree, but instead selectively renders important classes or methods. Consider
|
385
386
|
the following documentation inside of a README file:
|
386
387
|
|
388
|
+
!!!plain
|
387
389
|
= igLatinPay!
|
388
|
-
|
390
|
+
|
389
391
|
This library adds pig latin methods to the string class, allowing you
|
390
392
|
to transform sentences into pig latin.
|
391
|
-
|
393
|
+
|
392
394
|
{render:String#pig_latin}
|
393
|
-
|
395
|
+
|
394
396
|
You can also un-pig-latin-ify a word or sentence:
|
395
|
-
|
397
|
+
|
396
398
|
{render:String#de_pig_latin}
|
397
|
-
|
399
|
+
|
398
400
|
The above would render the methods in place inside the README document,
|
399
401
|
allowing you to summarize a small library in a single file.
|
400
402
|
|
@@ -405,8 +407,8 @@ allowing you to summarize a small library in a single file.
|
|
405
407
|
### `yard` Executable
|
406
408
|
|
407
409
|
YARD ships with a single executable aptly named `yard`. In addition to
|
408
|
-
generating standard documentation for your project, you would use this tool
|
409
|
-
if you wanted to:
|
410
|
+
generating standard documentation for your project, you would use this tool
|
411
|
+
if you wanted to:
|
410
412
|
|
411
413
|
* Document all installed gems
|
412
414
|
* Run a local documentation server
|
@@ -415,7 +417,7 @@ if you wanted to:
|
|
415
417
|
* Diff your documentation
|
416
418
|
* Analyze documentation statistics.
|
417
419
|
|
418
|
-
The following commands are available in YARD 0.6.x (see `yard help` for a
|
420
|
+
The following commands are available in YARD 0.6.x (see `yard help` for a
|
419
421
|
full list):
|
420
422
|
|
421
423
|
Usage: yard <command> [options]
|
@@ -444,11 +446,11 @@ you run `yardoc` from) and contains all of arguments you would otherwise pass
|
|
444
446
|
to the command-line tool. For instance, if you often type:
|
445
447
|
|
446
448
|
yardoc --no-private --protected app/**/*.rb - README LEGAL COPYING
|
447
|
-
|
449
|
+
|
448
450
|
You can place the following into your `.yardopts`:
|
449
451
|
|
450
452
|
--no-private --protected app/**/*.rb - README LEGAL COPYING
|
451
|
-
|
453
|
+
|
452
454
|
This way, you only need to type:
|
453
455
|
|
454
456
|
yardoc
|
@@ -456,7 +458,7 @@ This way, you only need to type:
|
|
456
458
|
Any extra switches passed to the command-line now will be appended to your
|
457
459
|
`.yardopts` options.
|
458
460
|
|
459
|
-
Note that options for `yardoc` are discussed in the {file:README.md README},
|
461
|
+
Note that options for `yardoc` are discussed in the {file:README.md README},
|
460
462
|
and a full overview of the `.yardopts` file can be found in {YARD::CLI::Yardoc}.
|
461
463
|
|
462
464
|
### Documenting Extra Files
|
@@ -469,13 +471,13 @@ which is automatically detected by YARD if found in the root of your project
|
|
469
471
|
line (or in the `.yardopts` file) by listing them after the '-' separator:
|
470
472
|
|
471
473
|
yardoc lib/**/*.rb ext/**/*.c - LICENSE.txt
|
472
|
-
|
474
|
+
|
473
475
|
Note that the README will automatically be picked up, so you do not need to
|
474
476
|
specify it. If you don't want to modify the default file globs, you can ignore
|
475
477
|
the first set of arguments:
|
476
478
|
|
477
479
|
yardoc - LICENSE.txt
|
478
|
-
|
480
|
+
|
479
481
|
Below you can read about how to customize the look of these extra files, both
|
480
482
|
with markup and pretty titles.
|
481
483
|
|
@@ -483,23 +485,23 @@ with markup and pretty titles.
|
|
483
485
|
|
484
486
|
You can add YARD-style `@tag` metadata to the top of any extra file if prefixed
|
485
487
|
by a `#` hash comment. YARD allows for arbitrary meta-data, but pays special
|
486
|
-
attention to the tags `@markup`, `@encoding`, and `@title`. Note that there
|
487
|
-
cannot be any whitespace before the tags. Here is an example of some tag data
|
488
|
+
attention to the tags `@markup`, `@encoding`, and `@title`. Note that there
|
489
|
+
cannot be any whitespace before the tags. Here is an example of some tag data
|
488
490
|
in a README:
|
489
491
|
|
490
492
|
# @markup markdown
|
491
493
|
# @title The Best Library in the World!
|
492
494
|
# @author The Author Name
|
493
|
-
|
495
|
+
|
494
496
|
This is the best library you will ever meet. Lipsum ...
|
495
497
|
|
496
498
|
The `@markup` tag allows you to specify a markup format to use for the file,
|
497
|
-
including "markdown", "textile", "rdoc", "ruby", "text", "html", or "none"
|
499
|
+
including "markdown", "textile", "rdoc", "ruby", "text", "html", or "none"
|
498
500
|
(no markup). This can be used when the markup cannot be auto-detected using
|
499
501
|
the extension of the filename, if the file has no extension, or if you want
|
500
502
|
to override the auto-detection.
|
501
503
|
|
502
|
-
By using `@encoding` you can specify a non-standard encoding. Note that
|
504
|
+
By using `@encoding` you can specify a non-standard encoding. Note that
|
503
505
|
`yardoc --charset` sets the global encoding (for all comments / files),
|
504
506
|
so if you are using unicode across all your files, you can specify it there.
|
505
507
|
Using the `@encoding` tag might be used to override the default global
|
@@ -535,7 +537,7 @@ A sample configuration file might look like:
|
|
535
537
|
:autoload_plugins:
|
536
538
|
- my_autoload_plugin
|
537
539
|
:safe_mode: false
|
538
|
-
|
540
|
+
|
539
541
|
You can also view and edit these configuration options from the commandline
|
540
542
|
using the `yard config` command. To list your configuration, use `yard config --list`.
|
541
543
|
To view a key, use `yard config ITEM`, and to set it, use `yard config ITEM VALUE`.
|
@@ -544,7 +546,7 @@ To view a key, use `yard config ITEM`, and to set it, use `yard config ITEM VALU
|
|
544
546
|
|
545
547
|
## Extending YARD
|
546
548
|
|
547
|
-
There are many ways to extend YARD to support non-standard Ruby syntax (DSLs),
|
549
|
+
There are many ways to extend YARD to support non-standard Ruby syntax (DSLs),
|
548
550
|
add new meta-data tags or programmatically access the intermediate metadata
|
549
551
|
and documentation from code. An overview of YARD's full architecture can be
|
550
552
|
found in the {file:docs/Overview.md} document.
|
@@ -570,7 +572,7 @@ document covers the basics of how YARD's templating system works.
|
|
570
572
|
## Plugin Support
|
571
573
|
|
572
574
|
As of 0.4, YARD will automatically load any gem named with the prefix of
|
573
|
-
`yard-` or `yard_`. You can use this to load a custom plugin that
|
575
|
+
`yard-` or `yard_`. You can use this to load a custom plugin that
|
574
576
|
[extend](#extending) YARD's functionality. A good example of this
|
575
577
|
is the [yard-rspec][yard-rspec] plugin, which adds [RSpec][rspec] specifications
|
576
578
|
to your documentation (`yardoc` and `yri`). You can try it out by installing
|