lib/yard/handlers/ruby/legacy/constant_handler.rb in yard-0.6.1 vs lib/yard/handlers/ruby/legacy/constant_handler.rb in yard-0.6.2

- old
+ new

@@ -1,7 +1,8 @@ # (see Ruby::ConstantHandler) class YARD::Handlers::Ruby::Legacy::ConstantHandler < YARD::Handlers::Ruby::Legacy::Base + include YARD::Handlers::Ruby::StructHandlerMethods HANDLER_MATCH = /\A[A-Z]\w*\s*=[^=]\s*/m handles HANDLER_MATCH process do # Don't document CONSTANTS if they're set in second class objects (methods) because @@ -17,17 +18,14 @@ end private def process_structclass(classname, parameters) - scope = :instance - klass = register ClassObject.new(namespace, classname) - klass.superclass = P(:Struct) - - tokval_list(YARD::Parser::Ruby::Legacy::TokenList.new(parameters), TkSYMBOL).each do |name| - klass.attributes[scope][name] = SymbolHash[:read => nil, :write => nil] - {:read => name, :write => "#{name}="}.each do |type, meth| - klass.attributes[scope][name][type] = register MethodObject.new(klass, meth, scope) - end - end + klass = create_class(classname, P(:Struct)) + create_attributes(klass, extract_parameters(parameters)) + end + + def extract_parameters(parameters) + members = tokval_list(YARD::Parser::Ruby::Legacy::TokenList.new(parameters), TkSYMBOL) + members.map {|m| m.to_s } end end