method
parse_visibility
v1_9_3_392 -
Show latest stable
- Class:
RDoc::Parser::Ruby
parse_visibility(container, single, tk)public
Determines the visibility in container from tk
# File lib/rdoc/parser/ruby.rb, line 1511
def parse_visibility(container, single, tk)
singleton = (single == SINGLE)
vis_type = tk.name
vis = case vis_type
when 'private' then :private
when 'protected' then :protected
when 'public' then :public
when 'private_class_method' then
singleton = true
:private
when 'public_class_method' then
singleton = true
:public
when 'module_function' then
singleton = true
:public
else
raise RDoc::Error, "Invalid visibility: #{tk.name}"
end
skip_tkspace_comment false
case peek_tk
# Ryan Davis suggested the extension to ignore modifiers, because he
# often writes
#
# protected unless $TESTING
#
when TkNL, TkUNLESS_MOD, TkIF_MOD, TkSEMICOLON then
container.ongoing_visibility = vis
else
new_methods = []
case vis_type
when 'module_function' then
args = parse_symbol_arg
container.set_visibility_for args, :private, false
container.methods_matching args do |m|
s_m = m.dup
s_m.record_location @top_level
s_m.singleton = true
new_methods << s_m
end
when 'public_class_method', 'private_class_method' then
args = parse_symbol_arg
container.methods_matching args, true do |m|
if m.parent != container then
m = m.dup
m.record_location @top_level
new_methods << m
end
m.visibility = vis
end
else
args = parse_symbol_arg
container.set_visibility_for args, vis, singleton
end
new_methods.each do |method|
case method
when RDoc::AnyMethod then
container.add_method method
when RDoc::Attr then
container.add_attribute method
end
method.visibility = vis
end
end
end Related methods
- Instance methods
- collect_first_comment
- error
- extract_call_seq
- get_bool
- get_class_or_module
- get_class_specification
- get_constant
- get_constant_with_optional_parens
- get_symbol_or_name
- look_for_directives_in
- make_message
- parse_alias
- parse_attr
- parse_attr_accessor
- parse_call_parameters
- parse_class
- parse_comment
- parse_constant
- parse_include
- parse_meta_attr
- parse_meta_method
- parse_method
- parse_method_or_yield_parameters
- parse_method_parameters
- parse_module
- parse_require
- parse_statements
- parse_symbol_arg
- parse_symbol_in_arg
- parse_top_level_statements
- parse_visibility
- parse_yield
- read_directive
- read_documentation_modifiers
- remove_private_comments
- scan
- skip_for_variable
- skip_method
- skip_optional_do_after_expression
- skip_tkspace_comment
- warn
- Class methods
- new