lib/yard/handlers/ruby/legacy/class_handler.rb in yard-0.9.5 vs lib/yard/handlers/ruby/legacy/class_handler.rb in yard-0.9.6

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true # (see Ruby::ClassHandler) class YARD::Handlers::Ruby::Legacy::ClassHandler < YARD::Handlers::Ruby::Legacy::Base include YARD::Handlers::Ruby::StructHandlerMethods handles TkCLASS namespace_only @@ -44,11 +45,11 @@ end end if classname == "self" parse_block(:namespace => namespace, :scope => :class) - elsif classname[0,1] =~ /[A-Z]/ + 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 @@ -65,11 +66,11 @@ # # @param [String] superstring the string declaring the superclass # @return [Array<String>] a list of member names def extract_parameters(superstring) paramstring = superstring.match(/\A(O?Struct)\.new\((.*?)\)/)[2] - paramstring.split(",").select {|x| x.strip[0,1] == ":"}.map {|x| x.strip[1..-1] } # the 1..-1 chops the leading : + paramstring.split(",").select {|x| x.strip[0, 1] == ":" }.map {|x| x.strip[1..-1] } # the 1..-1 chops the leading : end def create_struct_superclass(superclass, superclass_def) return if superclass == "Struct" the_super = register ClassObject.new(P("Struct"), superclass[8..-1]) do |o| @@ -78,14 +79,15 @@ parse_struct_subclass(the_super, superclass_def) the_super end def struct_superclass_name(superclass) - if match = superclass.match(/\A(Struct)\.new\((.*?)\)/) + match = superclass.match(/\A(Struct)\.new\((.*?)\)/) + if match paramstring = match[2].split(",") first = paramstring.first.strip - if first[0,1] =~ /['"]/ && first[-1,1] =~ /['"]/ && first !~ /\#\{/ + if first[0, 1] =~ /['"]/ && first[-1, 1] =~ /['"]/ && first !~ /\#\{/ return "Struct::#{first[1..-2]}" end end "Struct" end @@ -106,6 +108,6 @@ $1 when "self" namespace.path end end -end \ No newline at end of file +end