yard 0.2.1 → 0.2.2
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/{LICENSE.txt → LICENSE} +1 -1
- data/README +211 -0
- data/Rakefile +31 -0
- data/benchmarks/builtins_vs_eval.rb +23 -0
- data/benchmarks/erb_vs_erubis.rb +53 -0
- data/benchmarks/generation.rb +37 -0
- data/benchmarks/parsing.rb +33 -0
- data/bin/view_generator +17 -0
- data/bin/yard-graph +4 -0
- data/bin/yardoc +1 -93
- data/bin/yri +12 -3
- data/lib/yard.rb +10 -5
- data/lib/yard/autoload.rb +116 -0
- data/lib/yard/cli/yard_graph.rb +86 -0
- data/lib/yard/cli/yardoc.rb +131 -0
- data/lib/yard/code_objects/base.rb +321 -0
- data/lib/yard/code_objects/class_object.rb +89 -0
- data/lib/yard/code_objects/class_variable_object.rb +4 -0
- data/lib/yard/code_objects/constant_object.rb +4 -0
- data/lib/yard/code_objects/method_object.rb +51 -0
- data/lib/yard/code_objects/module_object.rb +4 -0
- data/lib/yard/code_objects/namespace_object.rb +88 -0
- data/lib/yard/code_objects/proxy.rb +183 -0
- data/lib/yard/code_objects/root_object.rb +8 -0
- data/lib/yard/core_ext/file.rb +26 -0
- data/lib/yard/core_ext/logger.rb +5 -0
- data/lib/yard/core_ext/module.rb +9 -0
- data/lib/yard/core_ext/string.rb +13 -0
- data/lib/yard/core_ext/symbol_hash.rb +24 -0
- data/lib/yard/generators/attributes_generator.rb +22 -0
- data/lib/yard/generators/base.rb +285 -0
- data/lib/yard/generators/class_generator.rb +25 -0
- data/lib/yard/generators/constants_generator.rb +73 -0
- data/lib/yard/generators/constructor_generator.rb +25 -0
- data/lib/yard/generators/deprecated_generator.rb +15 -0
- data/lib/yard/generators/docstring_generator.rb +15 -0
- data/lib/yard/generators/full_doc_generator.rb +59 -0
- data/lib/yard/generators/helpers/base_helper.rb +52 -0
- data/lib/yard/generators/helpers/filter_helper.rb +21 -0
- data/lib/yard/generators/helpers/html_helper.rb +137 -0
- data/lib/yard/generators/helpers/method_helper.rb +27 -0
- data/lib/yard/generators/helpers/uml_helper.rb +16 -0
- data/lib/yard/generators/inheritance_generator.rb +16 -0
- data/lib/yard/generators/method_details_generator.rb +18 -0
- data/lib/yard/generators/method_generator.rb +31 -0
- data/lib/yard/generators/method_listing_generator.rb +105 -0
- data/lib/yard/generators/method_missing_generator.rb +25 -0
- data/lib/yard/generators/method_signature_generator.rb +19 -0
- data/lib/yard/generators/method_summary_generator.rb +21 -0
- data/lib/yard/generators/mixins_generator.rb +15 -0
- data/lib/yard/generators/module_generator.rb +22 -0
- data/lib/yard/generators/quick_doc_generator.rb +31 -0
- data/lib/yard/generators/source_generator.rb +26 -0
- data/lib/yard/generators/tags_generator.rb +50 -0
- data/lib/yard/generators/uml_generator.rb +92 -0
- data/lib/yard/generators/visibility_group_generator.rb +26 -0
- data/lib/yard/handlers/alias_handler.rb +32 -0
- data/lib/yard/handlers/attribute_handler.rb +54 -0
- data/lib/yard/handlers/base.rb +509 -0
- data/lib/yard/handlers/class_handler.rb +44 -0
- data/lib/yard/handlers/class_variable_handler.rb +13 -0
- data/lib/yard/handlers/constant_handler.rb +13 -0
- data/lib/yard/handlers/exception_handler.rb +12 -0
- data/lib/yard/handlers/method_handler.rb +27 -0
- data/lib/yard/handlers/mixin_handler.rb +16 -0
- data/lib/yard/handlers/module_handler.rb +9 -0
- data/lib/yard/handlers/visibility_handler.rb +14 -0
- data/lib/yard/handlers/yield_handler.rb +26 -0
- data/lib/yard/logging.rb +27 -0
- data/lib/yard/parser/ruby_lex.rb +1344 -0
- data/lib/yard/parser/source_parser.rb +109 -0
- data/lib/yard/parser/statement.rb +36 -0
- data/lib/yard/parser/statement_list.rb +167 -0
- data/lib/yard/parser/token_list.rb +58 -0
- data/lib/yard/rake/yardoc_task.rb +30 -0
- data/lib/yard/registry.rb +136 -0
- data/lib/yard/serializers/base.rb +16 -0
- data/lib/yard/serializers/file_system_serializer.rb +48 -0
- data/lib/yard/serializers/process_serializer.rb +14 -0
- data/lib/yard/serializers/stdout_serializer.rb +21 -0
- data/lib/yard/tags/default_factory.rb +98 -0
- data/lib/yard/tags/library.rb +109 -0
- data/lib/yard/tags/merbdoc_factory.rb +47 -0
- data/lib/yard/tags/tag.rb +35 -0
- data/spec/code_objects/base_spec.rb +219 -0
- data/spec/code_objects/class_object_spec.rb +176 -0
- data/spec/code_objects/code_object_list_spec.rb +33 -0
- data/spec/code_objects/constants_spec.rb +79 -0
- data/spec/code_objects/method_object_spec.rb +30 -0
- data/spec/code_objects/module_object_spec.rb +73 -0
- data/spec/code_objects/namespace_object_spec.rb +129 -0
- data/spec/code_objects/proxy_spec.rb +80 -0
- data/spec/code_objects/spec_helper.rb +3 -0
- data/spec/core_ext/file_spec.rb +20 -0
- data/spec/core_ext/string_spec.rb +4 -0
- data/spec/core_ext/symbol_hash_spec.rb +80 -0
- data/spec/generators/base_spec.rb +64 -0
- data/spec/generators/helpers/base_helper_spec.rb +15 -0
- data/spec/generators/helpers/html_helper_spec.rb +56 -0
- data/spec/generators/quick_doc_generator_spec.rb +13 -0
- data/spec/handlers/alias_handler_spec.rb +50 -0
- data/spec/handlers/attribute_handler_spec.rb +78 -0
- data/spec/handlers/base_spec.rb +165 -0
- data/spec/handlers/class_handler_spec.rb +68 -0
- data/spec/handlers/class_variable_handler_spec.rb +9 -0
- data/spec/handlers/constant_handler_spec.rb +13 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +24 -0
- data/spec/handlers/examples/attribute_handler_001.rb.txt +19 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +39 -0
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +42 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +35 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +12 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +16 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +20 -0
- data/spec/handlers/examples/yield_handler_001.rb.txt +55 -0
- data/spec/handlers/exception_handler_spec.rb +35 -0
- data/spec/handlers/method_handler_spec.rb +35 -0
- data/spec/handlers/mixin_handler_spec.rb +30 -0
- data/spec/handlers/module_handler_spec.rb +25 -0
- data/spec/handlers/spec_helper.rb +21 -0
- data/spec/handlers/visibility_handler_spec.rb +24 -0
- data/spec/handlers/yield_handler_spec.rb +51 -0
- data/spec/parser/examples/example1.rb.txt +8 -0
- data/spec/parser/examples/tag_handler_001.rb.txt +8 -0
- data/spec/parser/source_parser_spec.rb +43 -0
- data/spec/parser/tag_parsing_spec.rb +18 -0
- data/spec/parser/token_list_spec.rb +35 -0
- data/spec/registry_spec.rb +70 -0
- data/spec/serializers/file_system_serializer_spec.rb +91 -0
- data/spec/serializers/spec_helper.rb +2 -0
- data/spec/spec_helper.rb +77 -0
- data/templates/default/attributes/html/header.erb +35 -0
- data/templates/default/attributes/text/header.erb +10 -0
- data/templates/default/class/html/header.erb +4 -0
- data/templates/default/constants/html/constants.erb +9 -0
- data/templates/default/constants/html/header.erb +3 -0
- data/templates/default/constants/html/included.erb +9 -0
- data/templates/default/constants/html/inherited.erb +9 -0
- data/templates/default/constructor/html/header.erb +10 -0
- data/templates/default/deprecated/html/main.erb +4 -0
- data/templates/default/deprecated/text/main.erb +3 -0
- data/templates/default/docstring/html/main.erb +3 -0
- data/templates/default/docstring/text/main.erb +3 -0
- data/templates/default/fulldoc/html/all_methods.erb +25 -0
- data/templates/default/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/default/fulldoc/html/app.js +18 -0
- data/templates/default/fulldoc/html/header.erb +15 -0
- data/templates/default/fulldoc/html/html_head.erb +3 -0
- data/templates/default/fulldoc/html/index.erb +18 -0
- data/templates/default/fulldoc/html/jquery.js +11 -0
- data/templates/default/fulldoc/html/readme.erb +15 -0
- data/templates/default/fulldoc/html/style.css +65 -0
- data/templates/default/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/default/inheritance/html/header.erb +8 -0
- data/templates/default/inheritance/text/header.erb +3 -0
- data/templates/default/method/html/aliases.erb +6 -0
- data/templates/default/method/html/header.erb +3 -0
- data/templates/default/method/html/title.erb +3 -0
- data/templates/default/methoddetails/html/header.erb +8 -0
- data/templates/default/methoddetails/html/method_header.erb +3 -0
- data/templates/default/methodmissing/html/header.erb +12 -0
- data/templates/default/methodsignature/html/main.erb +8 -0
- data/templates/default/methodsignature/text/main.erb +5 -0
- data/templates/default/methodsummary/html/header.erb +5 -0
- data/templates/default/methodsummary/html/included.erb +9 -0
- data/templates/default/methodsummary/html/inherited.erb +9 -0
- data/templates/default/methodsummary/html/summary.erb +25 -0
- data/templates/default/methodsummary/text/header.erb +5 -0
- 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 +3 -0
- data/templates/default/mixins/html/header.erb +4 -0
- data/templates/default/module/html/header.erb +4 -0
- data/templates/default/quickdoc/html/header.erb +15 -0
- data/templates/default/quickdoc/text/header.erb +12 -0
- data/templates/default/source/html/main.erb +15 -0
- data/templates/default/source/text/main.erb +4 -0
- data/templates/default/tags/html/header.erb +4 -0
- data/templates/default/tags/html/see.erb +13 -0
- data/templates/default/tags/html/tags.erb +20 -0
- data/templates/default/tags/text/header.erb +3 -0
- data/templates/default/tags/text/see.erb +5 -0
- data/templates/default/tags/text/tags.erb +7 -0
- data/templates/default/uml/dot/child.erb +1 -0
- data/templates/default/uml/dot/dependencies.erb +10 -0
- data/templates/default/uml/dot/header.erb +6 -0
- data/templates/default/uml/dot/info.erb +14 -0
- data/templates/default/uml/dot/subgraph.erb +6 -0
- data/templates/default/uml/dot/superclasses.erb +9 -0
- data/templates/default/uml/dot/unknown.erb +3 -0
- data/templates/default/uml/dot/unknown_child.erb +1 -0
- data/templates/default/visibilitygroup/html/header.erb +6 -0
- data/templates/javadoc/attributes/html/header.erb +16 -0
- data/templates/javadoc/class/html/header.erb +4 -0
- data/templates/javadoc/constants/html/constants.erb +9 -0
- data/templates/javadoc/constants/html/header.erb +3 -0
- data/templates/javadoc/constants/html/included.erb +12 -0
- data/templates/javadoc/constants/html/inherited.erb +12 -0
- data/templates/javadoc/constructor/html/header.erb +10 -0
- data/templates/javadoc/deprecated/html/main.erb +0 -0
- data/templates/javadoc/docstring/html/main.erb +6 -0
- data/templates/javadoc/fulldoc/html/all_methods.erb +25 -0
- data/templates/javadoc/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/javadoc/fulldoc/html/app.js +18 -0
- data/templates/javadoc/fulldoc/html/header.erb +15 -0
- data/templates/javadoc/fulldoc/html/html_head.erb +3 -0
- data/templates/javadoc/fulldoc/html/index.erb +18 -0
- data/templates/javadoc/fulldoc/html/jquery.js +11 -0
- data/templates/javadoc/fulldoc/html/readme.erb +15 -0
- data/templates/javadoc/fulldoc/html/style.css +22 -0
- data/templates/javadoc/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/javadoc/inheritance/html/header.erb +6 -0
- data/templates/javadoc/method/html/aliases.erb +6 -0
- data/templates/javadoc/method/html/header.erb +4 -0
- data/templates/javadoc/method/html/title.erb +4 -0
- data/templates/javadoc/methoddetails/html/header.erb +8 -0
- data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
- data/templates/javadoc/methodmissing/html/header.erb +12 -0
- data/templates/javadoc/methodsignature/html/main.erb +8 -0
- data/templates/javadoc/methodsummary/html/header.erb +5 -0
- data/templates/javadoc/methodsummary/html/included.erb +12 -0
- data/templates/javadoc/methodsummary/html/inherited.erb +12 -0
- data/templates/javadoc/methodsummary/html/summary.erb +25 -0
- data/templates/javadoc/mixins/html/header.erb +5 -0
- data/templates/javadoc/module/html/header.erb +4 -0
- data/templates/javadoc/source/html/main.erb +15 -0
- data/templates/javadoc/tags/html/header.erb +5 -0
- data/templates/javadoc/tags/html/see.erb +8 -0
- data/templates/javadoc/tags/html/tags.erb +19 -0
- data/templates/javadoc/visibilitygroup/html/header.erb +5 -0
- metadata +352 -50
- data/README.pdf +0 -0
- data/lib/code_object.rb +0 -337
- data/lib/extra.rb +0 -8
- data/lib/formatter.rb +0 -90
- data/lib/handlers/all_handlers.rb +0 -2
- data/lib/handlers/attribute_handler.rb +0 -51
- data/lib/handlers/class_handler.rb +0 -30
- data/lib/handlers/class_variable_handler.rb +0 -9
- data/lib/handlers/code_object_handler.rb +0 -104
- data/lib/handlers/constant_handler.rb +0 -11
- data/lib/handlers/exception_handler.rb +0 -20
- data/lib/handlers/method_handler.rb +0 -28
- data/lib/handlers/mixin_handler.rb +0 -15
- data/lib/handlers/module_handler.rb +0 -9
- data/lib/handlers/visibility_handler.rb +0 -7
- data/lib/handlers/yield_handler.rb +0 -33
- data/lib/logger.rb +0 -19
- data/lib/namespace.rb +0 -98
- data/lib/quick_doc.rb +0 -104
- data/lib/ruby_lex.rb +0 -1321
- data/lib/source_parser.rb +0 -253
- data/lib/tag_library.rb +0 -175
- data/lib/tag_type.rb +0 -155
- data/templates/default/html/_fulldoc.erb +0 -64
- data/templates/default/html/class.erb +0 -226
- data/templates/default/html/method.erb +0 -20
- data/templates/default/html/module.erb +0 -126
- data/test/fixtures/docstring.txt +0 -23
- data/test/fixtures/docstring2.txt +0 -4
- data/test/test_code_object.rb +0 -66
- data/test/test_namespace.rb +0 -10
@@ -0,0 +1,105 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class MethodListingGenerator < Base
|
4
|
+
include Helpers::MethodHelper
|
5
|
+
|
6
|
+
attr_reader :scope, :visibility
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
super
|
10
|
+
@scope = options[:scope]
|
11
|
+
@visibility = options[:visibility]
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def has_methods?(object)
|
17
|
+
method_list.size > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_inherited_methods?(object)
|
21
|
+
return false unless object.is_a?(CodeObjects::ClassObject)
|
22
|
+
meths = object.inherited_meths(:scope => scope, :visibility => visibility)
|
23
|
+
remove_ignored_meths!(meths)
|
24
|
+
meths.size > 0
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_included_methods?(object)
|
28
|
+
meths = object.included_meths(:scope => scope, :visibility => visibility)
|
29
|
+
remove_ignored_meths!(meths, false)
|
30
|
+
meths.size > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_list
|
34
|
+
meths = current_object.meths(meths_opts)
|
35
|
+
remove_ignored_meths!(meths)
|
36
|
+
meths.sort_by {|m| m.name.to_s.downcase }
|
37
|
+
end
|
38
|
+
|
39
|
+
# @yield [superclass, meths]
|
40
|
+
# Yields a the list of methods pertaining to a superclass
|
41
|
+
# in the inheritance order.
|
42
|
+
#
|
43
|
+
# @yieldparam [CodeObjects::ClassObject] superclass
|
44
|
+
# The superclass the methods belong to
|
45
|
+
#
|
46
|
+
# @yieldparam [Array<CodeObjects::ConstantObject>] meths
|
47
|
+
# The list of methods inherited from the superclass
|
48
|
+
#
|
49
|
+
def inherited_meths_by_class
|
50
|
+
all_meths = current_object.inherited_meths(:scope => scope, :visibility => visibility)
|
51
|
+
current_object.inheritance_tree[1..-1].each do |superclass|
|
52
|
+
next if superclass.is_a?(CodeObjects::Proxy)
|
53
|
+
meths = superclass.meths(meths_opts).select {|c| all_meths.include?(c) }
|
54
|
+
remove_ignored_meths!(meths)
|
55
|
+
next if meths.empty?
|
56
|
+
yield(superclass, meths)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# @yield [mixin, meths]
|
61
|
+
# Yields a the list of methods pertaining to a module
|
62
|
+
# in the module order.
|
63
|
+
#
|
64
|
+
# @yieldparam [CodeObjects::ModuleObject] mixin
|
65
|
+
# The module the methods belong to
|
66
|
+
#
|
67
|
+
# @yieldparam [Array<CodeObjects::ConstantObject>] meths
|
68
|
+
# The list of methods included from the module
|
69
|
+
#
|
70
|
+
def included_meths_by_module
|
71
|
+
all_meths = current_object.included_meths(:scope => scope, :visibility => visibility)
|
72
|
+
current_object.mixins.each do |mixin|
|
73
|
+
next if mixin.is_a?(CodeObjects::Proxy)
|
74
|
+
meths = mixin.meths(meths_opts).select {|c| all_meths.include?(c) }
|
75
|
+
remove_ignored_meths!(meths)
|
76
|
+
next if meths.empty?
|
77
|
+
yield(mixin, meths)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def ignored_meths
|
82
|
+
{
|
83
|
+
:instance => [:initialize, :method_missing],
|
84
|
+
:class => [:new]
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def remove_ignored_meths!(list, explicit_attr = true)
|
89
|
+
list.reject! do |o|
|
90
|
+
ignored_meths[o.scope].include?(o.name) ||
|
91
|
+
o.is_alias? || (explicit_attr ? (o.is_attribute? && !o.is_explicit?) : o.is_attribute?)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def meths_opts
|
98
|
+
{
|
99
|
+
:included => false, :inherited => false,
|
100
|
+
:scope => scope, :visibility => visibility
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class MethodMissingGenerator < Base
|
4
|
+
before_generate :has_method_missing?
|
5
|
+
|
6
|
+
def sections_for(object)
|
7
|
+
[:header, [G(MethodGenerator)]]
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def has_method_missing?
|
13
|
+
method_missing_method ? true : false
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing_method
|
17
|
+
current_object.meths.find {|o| o.name == :method_missing && o.scope == :instance }
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing_method_inherited?
|
21
|
+
method_missing_method.namespace != current_object
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class MethodSignatureGenerator < Base
|
4
|
+
include Helpers::MethodHelper
|
5
|
+
|
6
|
+
before_generate :has_signature?
|
7
|
+
|
8
|
+
def sections_for(object)
|
9
|
+
[:main]
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def has_signature?(object)
|
15
|
+
object.signature ? true : false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class MethodSummaryGenerator < MethodListingGenerator
|
4
|
+
before_generate :is_namespace?
|
5
|
+
before_section :summary, :has_methods?
|
6
|
+
before_section :inherited, :has_inherited_methods?
|
7
|
+
before_section :included, :has_included_methods?
|
8
|
+
|
9
|
+
def sections_for(object)
|
10
|
+
[
|
11
|
+
:header,
|
12
|
+
[
|
13
|
+
:summary,
|
14
|
+
:inherited,
|
15
|
+
:included
|
16
|
+
]
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class ModuleGenerator < Base
|
4
|
+
before_generate :is_module?
|
5
|
+
|
6
|
+
def sections_for(object)
|
7
|
+
[
|
8
|
+
:header,
|
9
|
+
[
|
10
|
+
G(MixinsGenerator),
|
11
|
+
G(DocstringGenerator),
|
12
|
+
G(AttributesGenerator),
|
13
|
+
G(ConstantsGenerator),
|
14
|
+
G(VisibilityGroupGenerator, :visibility => :public),
|
15
|
+
G(VisibilityGroupGenerator, :visibility => :protected),
|
16
|
+
G(VisibilityGroupGenerator, :visibility => :private)
|
17
|
+
]
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class QuickDocGenerator < Base
|
4
|
+
def sections_for(object)
|
5
|
+
case object
|
6
|
+
when CodeObjects::MethodObject
|
7
|
+
[
|
8
|
+
:header,
|
9
|
+
[
|
10
|
+
G(DeprecatedGenerator),
|
11
|
+
G(DocstringGenerator),
|
12
|
+
G(MethodSignatureGenerator),
|
13
|
+
G(TagsGenerator),
|
14
|
+
G(SourceGenerator)
|
15
|
+
]
|
16
|
+
]
|
17
|
+
when CodeObjects::NamespaceObject
|
18
|
+
[
|
19
|
+
:header,
|
20
|
+
[
|
21
|
+
G(DeprecatedGenerator),
|
22
|
+
G(DocstringGenerator),
|
23
|
+
G(AttributesGenerator),
|
24
|
+
G(MethodSummaryGenerator, :scope => [:class, :instance], :visibility => :public)
|
25
|
+
]
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class SourceGenerator < Base
|
4
|
+
def sections_for(object)
|
5
|
+
[:main] if object.source
|
6
|
+
end
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def format_lines(object)
|
11
|
+
i = -1
|
12
|
+
object.source.split(/\n/).map { object.line + (i += 1) }.join("\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
def format_code(object, show_lines = false)
|
16
|
+
i = -1
|
17
|
+
lines = object.source.split(/\n/)
|
18
|
+
longestline = (object.line + lines.size).to_s.length
|
19
|
+
lines.map do |line|
|
20
|
+
lineno = object.line + (i += 1)
|
21
|
+
(" " * (longestline - lineno.to_s.length)) + lineno.to_s + " " + line
|
22
|
+
end.join("\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class TagsGenerator < Base
|
4
|
+
before_section :header, :has_tags?
|
5
|
+
|
6
|
+
def sections_for(object)
|
7
|
+
[:header, [:param, :yieldparam, :return, :raise, :author, :version, :since, :see]]
|
8
|
+
end
|
9
|
+
|
10
|
+
def param(object)
|
11
|
+
render_tags :param
|
12
|
+
end
|
13
|
+
|
14
|
+
def yieldparam(object)
|
15
|
+
render_tags :yieldparam
|
16
|
+
end
|
17
|
+
|
18
|
+
def return(object)
|
19
|
+
render_tags :return
|
20
|
+
end
|
21
|
+
|
22
|
+
def raise(object)
|
23
|
+
render_tags :raise, :no_names => true
|
24
|
+
end
|
25
|
+
|
26
|
+
def author(object)
|
27
|
+
render_tags :author, :no_types => true, :no_names => true
|
28
|
+
end
|
29
|
+
|
30
|
+
def version(object)
|
31
|
+
render_tags :version, :no_types => true, :no_names => true
|
32
|
+
end
|
33
|
+
|
34
|
+
def since(object)
|
35
|
+
render_tags :since, :no_types => true, :no_names => true
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def has_tags?(object)
|
41
|
+
object.tags.size > 0
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_tags(name, opts = {})
|
45
|
+
opts = { :name => name }.update(opts)
|
46
|
+
render(current_object, 'tags', opts)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class UMLGenerator < Base
|
4
|
+
include Helpers::UMLHelper
|
5
|
+
|
6
|
+
before_generate :init
|
7
|
+
before_section :dependencies, :show_dependencies?
|
8
|
+
|
9
|
+
def sections_for(object)
|
10
|
+
[
|
11
|
+
:header,
|
12
|
+
[
|
13
|
+
:unknown, [:unresolved, [:unknown_child]],
|
14
|
+
:subgraph, [:info],
|
15
|
+
:superclasses,
|
16
|
+
:dependencies
|
17
|
+
]
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def header(object, &block)
|
22
|
+
tidy render(object, :header, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def subgraph(object, &block)
|
26
|
+
name = namespaces(object).empty? ? :child : :subgraph
|
27
|
+
render(object, name, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def unresolved(object, &block)
|
31
|
+
@objects.select {|o| o.is_a?(CodeObjects::Proxy) }.map {|o| yield(o) }.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def show_full_info?; options.has_key? :full end
|
37
|
+
def show_dependencies?; options.has_key? :dependencies end
|
38
|
+
|
39
|
+
def init(object)
|
40
|
+
@objects = {}
|
41
|
+
process_objects(object)
|
42
|
+
@objects = @objects.values
|
43
|
+
end
|
44
|
+
|
45
|
+
def namespaces(object)
|
46
|
+
object.children.select {|o| o.is_a?(CodeObjects::NamespaceObject) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def unresolved_objects
|
50
|
+
@direction_paths.values.flatten.select {|o| o.is_a?(CodeObjects::Proxy) }.uniq
|
51
|
+
end
|
52
|
+
|
53
|
+
def format_path(object)
|
54
|
+
object.path.gsub('::', '_')
|
55
|
+
end
|
56
|
+
|
57
|
+
def h(text)
|
58
|
+
text.to_s.gsub(/(\W)/, '\\\\\1')
|
59
|
+
end
|
60
|
+
|
61
|
+
def process_objects(object)
|
62
|
+
@objects[object.path] = object
|
63
|
+
@objects[object.superclass.path] = object.superclass if object.is_a?(CodeObjects::ClassObject)
|
64
|
+
object.mixins.each {|o| @objects[o.path] = o }
|
65
|
+
|
66
|
+
namespaces(object).each {|o| process_objects(o) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def method_list(object)
|
70
|
+
vissort = lambda {|vis| vis == :public ? 'a' : (vis == :protected ? 'b' : 'c') }
|
71
|
+
|
72
|
+
object.meths(:inherited => false, :included => false, :visibility => options[:visibility]).reject do |o|
|
73
|
+
o.is_attribute?
|
74
|
+
end.sort_by {|o| "#{o.scope}#{vissort.call(o.visibility)}#{o.name}" }
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def tidy(data)
|
80
|
+
indent = 0
|
81
|
+
data.split(/\n/).map do |line|
|
82
|
+
line.gsub!(/^\s*/, '')
|
83
|
+
next if line.empty?
|
84
|
+
indent -= 1 if line =~ /^\s*\}\s*$/
|
85
|
+
line = (' ' * (indent * 2)) + line
|
86
|
+
indent += 1 if line =~ /\{\s*$/
|
87
|
+
line
|
88
|
+
end.compact.join("\n") + "\n"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module YARD
|
2
|
+
module Generators
|
3
|
+
class VisibilityGroupGenerator < Base
|
4
|
+
attr_reader :visibility
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super
|
8
|
+
@visibility = options[:visibility]
|
9
|
+
end
|
10
|
+
|
11
|
+
before_generate :is_namespace?
|
12
|
+
|
13
|
+
def sections_for(object)
|
14
|
+
[
|
15
|
+
:header,
|
16
|
+
[
|
17
|
+
G(MethodSummaryGenerator, :visibility => visibility, :scope => :class),
|
18
|
+
G(MethodSummaryGenerator, :visibility => visibility, :scope => :instance),
|
19
|
+
G(MethodDetailsGenerator, :visibility => visibility, :scope => :class),
|
20
|
+
G(MethodDetailsGenerator, :visibility => visibility, :scope => :instance)
|
21
|
+
]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|