Class: YARD::Handlers::Ruby::Legacy::ClassHandler
- Inherits:
- Base show all
- Includes:
- StructHandlerMethods
- Defined in:
- lib/yard/handlers/ruby/legacy/class_handler.rb
Overview
Handles class declarations
Constant Summary
Constants included from CodeObjects
BUILTIN_ALL, BUILTIN_CLASSES, BUILTIN_EXCEPTIONS, BUILTIN_EXCEPTIONS_HASH, BUILTIN_MODULES, CONSTANTMATCH, CSEP, CSEPQ, ISEP, ISEPQ, METHODMATCH, METHODNAMEMATCH, NAMESPACEMATCH, NSEP, NSEPQ
Constants included from Parser::Ruby::Legacy::RubyToken
EXPR_ARG, EXPR_BEG, EXPR_CLASS, EXPR_DOT, EXPR_END, EXPR_FNAME, EXPR_MID, NEWLINE_TOKEN, TkReading2Token, TkSymbol2Token
Instance Method Summary (collapse)
-
- (Object) process
Main processing callback.
Methods included from StructHandlerMethods
#add_reader_tags, #add_writer_tags, #create_attributes, #create_class, #create_member_method?, #create_reader, #create_writer, #member_tag_for_member, #return_type_from_tag
Methods inherited from Base
Methods inherited from Base
clear_subclasses, #ensure_loaded!, handlers, handles, handles?, #initialize, namespace_only, namespace_only?, #parse_block, process, #push_state, #register, subclasses
Constructor Details
This class inherits a constructor from YARD::Handlers::Base
Instance Method Details
- (Object) process
Main processing callback
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/yard/handlers/ruby/legacy/class_handler.rb', line 6 process do if statement.tokens.to_s =~ /^class\s+(#{NAMESPACEMATCH})\s*(?:<\s*(.+)|\Z)/m classname = $1 superclass_def = $2 superclass = parse_superclass($2) if superclass == "Struct" is_a_struct = true superclass = struct_superclass_name(superclass_def) create_struct_superclass(superclass, superclass_def) end undocsuper = $2 && superclass.nil? klass = register ClassObject.new(namespace, classname) do |o| o.superclass = superclass if superclass o.superclass.type = :class if o.superclass.is_a?(Proxy) end parse_struct_subclass(klass, superclass_def) if is_a_struct parse_block(:namespace => klass) if undocsuper raise YARD::Parser::UndocumentableError, 'superclass (class was added without superclass)' end elsif statement.tokens.to_s =~ /^class\s*<<\s*([\w\:]+)/ classname = $1 proxy = Proxy.new(namespace, classname) # Allow constants to reference class names if ConstantObject === proxy if proxy.value =~ /\A#{NAMESPACEMATCH}\Z/ proxy = Proxy.new(namespace, proxy.value) else raise YARD::Parser::UndocumentableError, "constant class reference '#{classname}'" end end if classname == "self" parse_block(:namespace => namespace, :scope => :class) elsif classname[0,1] =~ /[A-Z]/ register ClassObject.new(namespace, classname) if Proxy === proxy parse_block(:namespace => proxy, :scope => :class) else raise YARD::Parser::UndocumentableError, "class '#{classname}'" end else raise YARD::Parser::UndocumentableError, "class: #{statement.tokens}" end end |