yard 0.8.7.6 → 0.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
@@ -1,6 +1,6 @@
|
|
1
1
|
# Handles the Init_Libname() method
|
2
2
|
class YARD::Handlers::C::InitHandler < YARD::Handlers::C::Base
|
3
|
-
MATCH = %r{\A\s*(
|
3
|
+
MATCH = %r{\A\s*(?:\S+\s+)*void\s+(?:[Ii]nit_)?(\w+)\s*}
|
4
4
|
handles MATCH
|
5
5
|
statement_class ToplevelStatement
|
6
6
|
|
@@ -6,9 +6,9 @@ class YARD::Handlers::C::MethodHandler < YARD::Handlers::C::Base
|
|
6
6
|
module_function |
|
7
7
|
private_method
|
8
8
|
)
|
9
|
-
\s*\(\s*([\w\.]+)
|
10
|
-
\s*"([^"]+)"
|
11
|
-
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(\w+\))?(\w+)\)
|
9
|
+
\s*\(\s*([\w\.]+)\s*,
|
10
|
+
\s*"([^"]+)"\s*,
|
11
|
+
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(\w+\))?(\w+)\)?\s*,
|
12
12
|
\s*(-?\w+)\s*\)}xm
|
13
13
|
MATCH2 = %r{rb_define_global_function\s*\(
|
14
14
|
\s*"([^"]+)",
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# Helper methods to assist with processing decorators.
|
2
|
+
module YARD::Handlers::Ruby::DecoratorHandlerMethods
|
3
|
+
|
4
|
+
# @overload process_decorator(*nodes, opts = {}, &block)
|
5
|
+
# Takes care of parsing method definitions passed to decorators
|
6
|
+
# as parameters, as well as parsing chained decorators.
|
7
|
+
#
|
8
|
+
# Use this in a handler's process block.
|
9
|
+
#
|
10
|
+
# @yieldparam method [YARD::CodeObjects::MethodObject] Method being decorated.
|
11
|
+
# @yieldparam node [YARD::Parser::Ruby::AstNode] AST node of the decorated method.
|
12
|
+
# @yieldparam name [Symbol] Name of the decorated method.
|
13
|
+
# @return [Array<Hash>] Array of hashes containing :method, :node, :name.
|
14
|
+
# See yield params.
|
15
|
+
#
|
16
|
+
# @param nodes [YARD::Parser::Ruby::AstNode] AST nodes that refer to decorated
|
17
|
+
# methods, like indexes of statement.parameter. Defaults to all parameters.
|
18
|
+
# Pass nil to specify zero parameters.
|
19
|
+
#
|
20
|
+
# @option opts [:instance, :class] :scope (:instance) Scope to use for each
|
21
|
+
# MethodObject.
|
22
|
+
#
|
23
|
+
# @option opts [true, false] :transfer_docstring Set false to disable
|
24
|
+
# transferring the decorator docstring to method definitions passed to the
|
25
|
+
# decorator as parameters.
|
26
|
+
#
|
27
|
+
# @option opts [true, false] :transfer_source Set false to disable
|
28
|
+
# transferring the decorator source code string to method definitions
|
29
|
+
# passed to the decorator as parameters.
|
30
|
+
#
|
31
|
+
# @example Basic Usage
|
32
|
+
# # Simply pass the method docs through to the method definition.
|
33
|
+
# process do
|
34
|
+
# process_decorator
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# @example Setting a method's visibility to private.
|
38
|
+
# process do
|
39
|
+
# process_decorator :scope => :class do |method|
|
40
|
+
# method.visibility = :private if method.respond_to? :visibility
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
def process_decorator(*nodes, &block)
|
44
|
+
opts = nodes.last.is_a?(Hash) ? nodes.pop : {}
|
45
|
+
|
46
|
+
all_nodes = statement.parameters.select do |p|
|
47
|
+
p.is_a? YARD::Parser::Ruby::AstNode
|
48
|
+
end
|
49
|
+
|
50
|
+
# Parse decorator parameters (decorator chain).
|
51
|
+
all_nodes.each do |param|
|
52
|
+
parse_block param if param.call? or param.def?
|
53
|
+
end
|
54
|
+
|
55
|
+
selected_nodes =
|
56
|
+
if nodes.empty?
|
57
|
+
all_nodes
|
58
|
+
elsif (nodes.count == 1 and nodes.first == nil)
|
59
|
+
[]
|
60
|
+
else
|
61
|
+
nodes
|
62
|
+
end
|
63
|
+
|
64
|
+
decorated_methods = selected_nodes.map { |param|
|
65
|
+
process_decorator_parameter param, opts, &block
|
66
|
+
}.flatten
|
67
|
+
|
68
|
+
# Store method nodes in decorator node.
|
69
|
+
statement.define_singleton_method :decorators do
|
70
|
+
decorated_methods.map { |h| h[:node] }
|
71
|
+
end
|
72
|
+
|
73
|
+
decorated_methods
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def process_decorator_parameter(node, opts={}, &block)
|
79
|
+
scope = opts.fetch :scope, :instance
|
80
|
+
transfer_docstring = opts.fetch :transfer_docstring, true
|
81
|
+
transfer_source = opts.fetch :transfer_source, true
|
82
|
+
|
83
|
+
name = nil
|
84
|
+
|
85
|
+
if node.call?
|
86
|
+
if node.respond_to? :decorators
|
87
|
+
return node.decorators.map do |n|
|
88
|
+
process_decorator_parameter n, opts, &block
|
89
|
+
end
|
90
|
+
end
|
91
|
+
elsif node.def?
|
92
|
+
name = node.jump(:def).method_name.source
|
93
|
+
else
|
94
|
+
name = node.jump(:ident, :string_content, :const).source
|
95
|
+
end
|
96
|
+
|
97
|
+
method = YARD::CodeObjects::Proxy.new(
|
98
|
+
namespace,
|
99
|
+
(scope == :instance ? '#' : '.') + name.to_s,
|
100
|
+
:method
|
101
|
+
)
|
102
|
+
|
103
|
+
# Transfer source to methods passed to the helper as parameters.
|
104
|
+
method.source = statement.source if transfer_source and node.def?
|
105
|
+
|
106
|
+
# Tag decorator on decorated method.
|
107
|
+
if method.respond_to? :add_tag
|
108
|
+
method.add_tag YARD::Tags::Tag.new(
|
109
|
+
:decorator,
|
110
|
+
statement.jump(:command).jump(:ident).source
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Transfer decorator docstring to methods passed to the helper as parameters.
|
115
|
+
if transfer_docstring \
|
116
|
+
and node.def? \
|
117
|
+
and statement.docstring \
|
118
|
+
and method.docstring.empty?
|
119
|
+
tags = method.tags if method.respond_to? :tags
|
120
|
+
tags ||= []
|
121
|
+
|
122
|
+
method.docstring = statement.docstring
|
123
|
+
|
124
|
+
tags.each { |t| method.add_tag t }
|
125
|
+
end
|
126
|
+
|
127
|
+
block.call method, node, name.to_sym if block_given?
|
128
|
+
|
129
|
+
[{:method => method, :node => node, :name => name.to_sym}]
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -15,7 +15,7 @@ class YARD::Handlers::Ruby::Legacy::PrivateClassMethodHandler < YARD::Handlers::
|
|
15
15
|
method = Proxy.new(namespace, name)
|
16
16
|
ensure_loaded!(method)
|
17
17
|
method.visibility = :private
|
18
|
-
rescue NamespaceMissingError
|
18
|
+
rescue YARD::Handlers::NamespaceMissingError
|
19
19
|
raise UndocumentableError, "private visibility set on unrecognized method: #{name}"
|
20
20
|
end
|
21
21
|
end
|
@@ -1,46 +1,13 @@
|
|
1
|
-
# Sets visibility of a class method
|
1
|
+
# Sets visibility of a class method to private.
|
2
2
|
class YARD::Handlers::Ruby::PrivateClassMethodHandler < YARD::Handlers::Ruby::Base
|
3
|
+
include YARD::Handlers::Ruby::DecoratorHandlerMethods
|
4
|
+
|
3
5
|
handles method_call(:private_class_method)
|
4
6
|
namespace_only
|
5
7
|
|
6
8
|
process do
|
7
|
-
|
8
|
-
|
9
|
-
next unless AstNode === param
|
10
|
-
begin
|
11
|
-
privatize_class_method(param)
|
12
|
-
rescue UndocumentableError => err
|
13
|
-
errors << err.message
|
14
|
-
end
|
15
|
-
end
|
16
|
-
if errors.size > 0
|
17
|
-
msg = errors.size == 1 ? ": #{errors[0]}" : "s: #{errors.join(", ")}"
|
18
|
-
raise UndocumentableError, "private class_method#{msg} for #{namespace.path}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def privatize_class_method(node)
|
25
|
-
if node.literal?
|
26
|
-
method = Proxy.new(namespace, node[0][0][0], :method)
|
27
|
-
|
28
|
-
# Proxy will not have a #visibility method when handling inherited class methods
|
29
|
-
# like :new, yet "private_class_method :new" is valid Ruby syntax. Therefore
|
30
|
-
# if Proxy doesn't respond to #visibility, the object should be skipped.
|
31
|
-
#
|
32
|
-
# However, it is important to note that classes can be reopened, and
|
33
|
-
# private_class_method can be called inside these reopened classes.
|
34
|
-
# Therefore when encountering private_class_method, all of the files need
|
35
|
-
# to be parsed before checking if Proxy responds to #visibility. If this
|
36
|
-
# is not done, it is possible that class methods may be incorrectly marked
|
37
|
-
# public/private.
|
38
|
-
parser.parse_remaining_files
|
39
|
-
method.visibility = :private if method.respond_to? :visibility
|
40
|
-
else
|
41
|
-
raise UndocumentableError, "invalid argument to private_class_method: #{node.source}"
|
9
|
+
process_decorator :scope => :class do |method|
|
10
|
+
method.visibility = :private if method.respond_to? :visibility=
|
42
11
|
end
|
43
|
-
rescue NamespaceMissingError
|
44
|
-
raise UndocumentableError, "private visibility set on unrecognized method: #{node[0]}"
|
45
12
|
end
|
46
|
-
end
|
13
|
+
end
|
@@ -1,36 +1,42 @@
|
|
1
1
|
# Sets visibility of a constant (class, module, const)
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module YARD
|
3
|
+
module Handlers
|
4
|
+
module Ruby
|
5
|
+
class PrivateConstantHandler < YARD::Handlers::Ruby::Base
|
6
|
+
handles method_call(:private_constant)
|
7
|
+
namespace_only
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
process do
|
10
|
+
errors = []
|
11
|
+
statement.parameters.each do |param|
|
12
|
+
next unless AstNode === param
|
13
|
+
begin
|
14
|
+
privatize_constant(param)
|
15
|
+
rescue UndocumentableError => err
|
16
|
+
errors << err.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
if errors.size > 0
|
20
|
+
msg = errors.size == 1 ? ": #{errors[0]}" : "s: #{errors.join(", ")}"
|
21
|
+
raise UndocumentableError, "private constant#{msg} for #{namespace.path}"
|
22
|
+
end
|
23
|
+
end
|
21
24
|
|
22
|
-
|
25
|
+
private
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
def privatize_constant(node)
|
28
|
+
if node.literal? || (node.type == :var_ref && node[0].type == :const)
|
29
|
+
node = node.jump(:tstring_content, :const)
|
30
|
+
const = Proxy.new(namespace, node[0])
|
31
|
+
ensure_loaded!(const)
|
32
|
+
const.visibility = :private
|
33
|
+
else
|
34
|
+
raise UndocumentableError, "invalid argument to private_constant: #{node.source}"
|
35
|
+
end
|
36
|
+
rescue NamespaceMissingError
|
37
|
+
raise UndocumentableError, "private visibility set on unrecognized constant: #{node[0]}"
|
38
|
+
end
|
39
|
+
end
|
32
40
|
end
|
33
|
-
rescue NamespaceMissingError
|
34
|
-
raise UndocumentableError, "private visibility set on unrecognized constant: #{node[0]}"
|
35
41
|
end
|
36
|
-
end
|
42
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Sets visibility of a class method to public.
|
2
|
+
class YARD::Handlers::Ruby::PublicClassMethodHandler < YARD::Handlers::Ruby::Base
|
3
|
+
include YARD::Handlers::Ruby::DecoratorHandlerMethods
|
4
|
+
|
5
|
+
handles method_call(:public_class_method)
|
6
|
+
namespace_only
|
7
|
+
|
8
|
+
process do
|
9
|
+
process_decorator :scope => :class do |method|
|
10
|
+
method.visibility = :public if method.respond_to? :visibility
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -133,6 +133,7 @@ module YARD::Handlers::Ruby::StructHandlerMethods
|
|
133
133
|
def create_attributes(klass, members)
|
134
134
|
# For each parameter, add reader and writers
|
135
135
|
members.each do |member|
|
136
|
+
next if klass.attributes[:instance][member]
|
136
137
|
klass.attributes[:instance][member] = SymbolHash[:read => nil, :write => nil]
|
137
138
|
create_writer klass, member if create_member_method?(klass, member, :write)
|
138
139
|
create_reader klass, member if create_member_method?(klass, member, :read)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Handles 'private', 'protected', and 'public' calls.
|
2
2
|
class YARD::Handlers::Ruby::VisibilityHandler < YARD::Handlers::Ruby::Base
|
3
|
+
include YARD::Handlers::Ruby::DecoratorHandlerMethods
|
4
|
+
|
3
5
|
handles method_call(:private)
|
4
6
|
handles method_call(:protected)
|
5
7
|
handles method_call(:public)
|
@@ -11,14 +13,9 @@ class YARD::Handlers::Ruby::VisibilityHandler < YARD::Handlers::Ruby::Base
|
|
11
13
|
when :var_ref, :vcall
|
12
14
|
self.visibility = ident.first.to_sym
|
13
15
|
when :fcall, :command
|
14
|
-
|
15
|
-
|
16
|
-
when :symbol; source = node.first.source
|
17
|
-
when :string_content; source = node.source
|
18
|
-
else next
|
19
|
-
end
|
20
|
-
MethodObject.new(namespace, source, scope) {|o| o.visibility = ident.first }
|
16
|
+
process_decorator do |method|
|
17
|
+
method.visibility = ident.first if method.respond_to? :visibility=
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
24
|
-
end
|
21
|
+
end
|
data/lib/yard/logging.rb
CHANGED
@@ -219,7 +219,7 @@ module YARD
|
|
219
219
|
node.line_range = Range.new(lstart, lineno)
|
220
220
|
if node.respond_to?(:block)
|
221
221
|
sr, lr = node.block.source_range, node.block.line_range
|
222
|
-
node.block.source_range = Range.new(sr.first, @tokens.last[2][1])
|
222
|
+
node.block.source_range = Range.new(sr.first, @tokens.last[2][1]-1)
|
223
223
|
node.block.line_range = Range.new(lr.first, @tokens.last[2][0])
|
224
224
|
end
|
225
225
|
node
|
@@ -634,4 +634,4 @@ module YARD
|
|
634
634
|
end if defined?(::Ripper)
|
635
635
|
end
|
636
636
|
end
|
637
|
-
end
|
637
|
+
end
|
@@ -63,6 +63,10 @@ module YARD
|
|
63
63
|
SHEBANG_LINE = /\A\s*#!\S+/
|
64
64
|
ENCODING_LINE = /\A(?:\s*#*!.*\r?\n)?\s*(?:#+|\/\*+|\/\/+).*coding\s*[:=]{1,2}\s*([a-z\d_\-]+)/i
|
65
65
|
|
66
|
+
# The default glob of files to be parsed.
|
67
|
+
# @since 0.9.0
|
68
|
+
DEFAULT_PATH_GLOB = ["{lib,app}/**/*.rb", "ext/**/*.{c,cc,cxx,cpp}"]
|
69
|
+
|
66
70
|
# Byte order marks for various encodings
|
67
71
|
# @since 0.7.0
|
68
72
|
ENCODING_BYTE_ORDER_MARKS = {
|
@@ -90,7 +94,7 @@ module YARD
|
|
90
94
|
# @param [Fixnum] level the logger level to use during parsing. See
|
91
95
|
# {YARD::Logger}
|
92
96
|
# @return [void]
|
93
|
-
def parse(paths =
|
97
|
+
def parse(paths = DEFAULT_PATH_GLOB, excluded = [], level = log.level)
|
94
98
|
log.debug("Parsing #{paths.inspect} with `#{parser_type}` parser")
|
95
99
|
excluded = excluded.map do |path|
|
96
100
|
case path
|
@@ -99,7 +103,7 @@ module YARD
|
|
99
103
|
end
|
100
104
|
end
|
101
105
|
files = [paths].flatten.
|
102
|
-
map {|p| File.directory?(p) ? "#{p}/**/*.{rb,c}" : p }.
|
106
|
+
map {|p| File.directory?(p) ? "#{p}/**/*.{rb,c,cc,cxx,cpp}" : p }.
|
103
107
|
map {|p| p.include?("*") ? Dir[p].sort_by {|f| f.length } : p }.flatten.
|
104
108
|
reject {|p| !File.file?(p) || excluded.any? {|re| p =~ re } }
|
105
109
|
|
@@ -147,16 +151,12 @@ module YARD
|
|
147
151
|
# @return [Hash{Symbol=>Object}] a list of registered parser types
|
148
152
|
# @private
|
149
153
|
# @since 0.5.6
|
150
|
-
attr_reader :parser_types
|
151
|
-
undef parser_types
|
152
154
|
def parser_types; @@parser_types ||= {} end
|
153
155
|
def parser_types=(value) @@parser_types = value end
|
154
156
|
|
155
157
|
# @return [Hash] a list of registered parser type extensions
|
156
158
|
# @private
|
157
159
|
# @since 0.5.6
|
158
|
-
attr_reader :parser_type_extensions
|
159
|
-
undef parser_type_extensions
|
160
160
|
def parser_type_extensions; @@parser_type_extensions ||= {} end
|
161
161
|
def parser_type_extensions=(value) @@parser_type_extensions = value end
|
162
162
|
|
@@ -66,12 +66,12 @@ module YARD
|
|
66
66
|
# Defines the rake task
|
67
67
|
# @return [void]
|
68
68
|
def define
|
69
|
-
desc "Generate YARD Documentation" unless ::Rake.application.
|
69
|
+
desc "Generate YARD Documentation" unless ::Rake.application.last_description
|
70
70
|
task(name) do
|
71
71
|
before.call if before.is_a?(Proc)
|
72
72
|
yardoc = YARD::CLI::Yardoc.new
|
73
73
|
yardoc.options[:verifier] = verifier if verifier
|
74
|
-
yardoc.run
|
74
|
+
yardoc.run(*(options + files))
|
75
75
|
YARD::CLI::Stats.run(*(stats_options + ['--use-cache'])) unless stats_options.empty?
|
76
76
|
after.call if after.is_a?(Proc)
|
77
77
|
end
|
@@ -26,6 +26,7 @@ module YARD
|
|
26
26
|
# path filename. If this is set to the empty string, no extension is used.
|
27
27
|
def initialize(opts = {})
|
28
28
|
super
|
29
|
+
@name_map = nil
|
29
30
|
@basepath = (options[:basepath] || 'doc').to_s
|
30
31
|
@extension = (options.has_key?(:extension) ? options[:extension] : 'html').to_s
|
31
32
|
end
|
@@ -51,7 +52,7 @@ module YARD
|
|
51
52
|
if object.is_a?(CodeObjects::ExtraFileObject)
|
52
53
|
fspath = ['file.' + object.name + (extension.empty? ? '' : ".#{extension}")]
|
53
54
|
else
|
54
|
-
objname = object != YARD::Registry.root ? object
|
55
|
+
objname = object != YARD::Registry.root ? mapped_name(object) : "top-level-namespace"
|
55
56
|
objname += '_' + object.scope.to_s[0,1] if object.is_a?(CodeObjects::MethodObject)
|
56
57
|
fspath = [objname + (extension.empty? ? '' : ".#{extension}")]
|
57
58
|
if object.namespace && object.namespace.path != ""
|
@@ -72,6 +73,37 @@ module YARD
|
|
72
73
|
|
73
74
|
private
|
74
75
|
|
76
|
+
# Builds a filename mapping from object paths to filesystem path names.
|
77
|
+
# Needed to handle case sensitive YARD objects mapped into a case
|
78
|
+
# insensitive filesystem. Uses with {#mapped_name} to determine the
|
79
|
+
# mapping name for a given object.
|
80
|
+
#
|
81
|
+
# @note In order to use filesystem name mapping, you must initialize
|
82
|
+
# the serializer object after preparing the {YARD::Registry}.
|
83
|
+
def build_filename_map
|
84
|
+
@name_map = {}
|
85
|
+
YARD::Registry.all.each do |object|
|
86
|
+
lpath = nil
|
87
|
+
if object.parent && object.parent.type != :root
|
88
|
+
lpath = object.parent.path + "::" + object.name.to_s.downcase
|
89
|
+
else
|
90
|
+
lpath = object.path.downcase
|
91
|
+
end
|
92
|
+
|
93
|
+
@name_map[lpath] ||= {}
|
94
|
+
size = @name_map[lpath].size
|
95
|
+
name = "#{object.name}#{size > 0 ? "_" * size : ""}"
|
96
|
+
@name_map[lpath][object.name] = name
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# @return [String] the filesystem mapped name of a given object.
|
101
|
+
def mapped_name(object)
|
102
|
+
build_filename_map if !@name_map
|
103
|
+
map = @name_map[object.path.downcase]
|
104
|
+
return map && map[object.name] ? map[object.name] : object.name.to_s
|
105
|
+
end
|
106
|
+
|
75
107
|
# Remove special chars from filenames.
|
76
108
|
# Windows disallows \ / : * ? " < > | but we will just remove any
|
77
109
|
# non alphanumeric (plus period, underscore and dash).
|