method
parse_class
v1_9_3_392 -
Show latest stable
- Class:
RDoc::Parser::Ruby
parse_class(container, single, tk, comment)public
Parses a class in context with comment
# File lib/rdoc/parser/ruby.rb, line 593
def parse_class(container, single, tk, comment)
offset = tk.seek
line_no = tk.line_no
declaration_context = container
container, name_t, given_name = get_class_or_module container
case name_t
when TkCONSTANT
name = name_t.name
superclass = '::Object'
if TkLT === peek_tk then
get_tk
skip_tkspace
superclass = get_class_specification
superclass = '(unknown)' if superclass.empty?
end
cls_type = single == SINGLE ? RDoc::SingleClass : RDoc::NormalClass
cls = declaration_context.add_class cls_type, given_name, superclass
cls.ignore unless container.document_children
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
cls.record_location @top_level
cls.offset = offset
cls.line = line_no
cls.add_comment comment, @top_level
@top_level.add_to_classes_or_modules cls
@stats.add_class cls
parse_statements cls
when TkLSHFT
case name = get_class_specification
when "self", container.name
parse_statements container, SINGLE
else
other = RDoc::TopLevel.find_class_named name
unless other then
other = container.add_module RDoc::NormalModule, name
other.record_location @top_level
other.offset = offset
other.line = line_no
other.add_comment comment, @top_level
end
# notify :nodoc: all if not a constant-named class/module
# (and remove any comment)
unless name =~ /\A(::)?[A-Z]/ then
other.document_self = nil
other.document_children = false
other.clear_comment
end
@top_level.add_to_classes_or_modules other
@stats.add_class other
read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
parse_statements(other, SINGLE)
end
else
warn("Expected class name or '<<'. Got #{name_t.class}: #{name_t.text.inspect}")
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