[前][次][番号順一覧][スレッド一覧]

ruby-changes:15390

From: drbrain <ko1@a...>
Date: Sat, 10 Apr 2010 15:36:38 +0900 (JST)
Subject: [ruby-changes:15390] Ruby:r27283 (trunk): * lib/rdoc: Import RDoc 2.5.2

drbrain	2010-04-10 15:36:13 +0900 (Sat, 10 Apr 2010)

  New Revision: 27283

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27283

  Log:
    * lib/rdoc: Import RDoc 2.5.2
    * lib/rdoc/parser/ruby.rb (RDoc::Parser::Ruby): Don't parse rdoc
      files, reverts r24976 in favor of include directive support in C
      parser.

  Added files:
    trunk/test/rdoc/README
    trunk/test/rdoc/test_rdoc_markup_pre_process.rb
  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/doc/re.rdoc
    trunk/lib/rdoc/any_method.rb
    trunk/lib/rdoc/attr.rb
    trunk/lib/rdoc/class_module.rb
    trunk/lib/rdoc/code_object.rb
    trunk/lib/rdoc/generator/darkfish.rb
    trunk/lib/rdoc/markup/parser.rb
    trunk/lib/rdoc/markup/preprocess.rb
    trunk/lib/rdoc/parser/c.rb
    trunk/lib/rdoc/parser/ruby.rb
    trunk/lib/rdoc/parser/simple.rb
    trunk/lib/rdoc/parser.rb
    trunk/lib/rdoc/rdoc.rb
    trunk/lib/rdoc/ri/driver.rb
    trunk/lib/rdoc/ri/paths.rb
    trunk/lib/rdoc/ruby_lex.rb
    trunk/lib/rdoc/task.rb
    trunk/lib/rdoc.rb
    trunk/re.c
    trunk/test/rdoc/test_rdoc_any_method.rb
    trunk/test/rdoc/test_rdoc_attr.rb
    trunk/test/rdoc/test_rdoc_markup_parser.rb
    trunk/test/rdoc/test_rdoc_parser.rb
    trunk/test/rdoc/test_rdoc_parser_c.rb
    trunk/test/rdoc/test_rdoc_parser_ruby.rb
    trunk/test/rdoc/test_rdoc_parser_simple.rb
    trunk/test/rdoc/test_rdoc_rdoc.rb
    trunk/test/rdoc/test_rdoc_ri_driver.rb
    trunk/test/rdoc/xref_data.rb

Index: doc/re.rdoc
===================================================================
--- doc/re.rdoc	(revision 27282)
+++ doc/re.rdoc	(revision 27283)
@@ -1,5 +1,4 @@
 # -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-=begin rdoc
 
 Regular expressions (<i>regexp</i>s) are patterns which describe the
 contents of a string. They're used for testing whether a string contains a
@@ -580,5 +579,4 @@
 
     Regexp.new('\A' 'a?' * 29 + 'a' * 29).match('a' * 29)
         #=> #<MatchData "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa">
-=end
-class Regexp; end
+
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27282)
+++ ChangeLog	(revision 27283)
@@ -1,3 +1,10 @@
+Sat Apr 10 15:18:26 2010  Eric Hodel  <drbrain@s...>
+
+	* lib/rdoc: Import RDoc 2.5.2
+	* lib/rdoc/parser/ruby.rb (RDoc::Parser::Ruby): Don't parse rdoc
+	  files, reverts r24976 in favor of include directive support in C
+	  parser.
+
 Sat Apr 10 13:14:22 2010  Yusuke Endoh  <mame@t...>
 
 	* ext/openssl/ossl_ssl.c (Init_ossl_ssl): add SSLContext#ssl_timeout=,
Index: re.c
===================================================================
--- re.c	(revision 27282)
+++ re.c	(revision 27283)
@@ -3456,9 +3456,7 @@
  *  <code>%r{...}</code> literals, and by the <code>Regexp::new</code>
  *  constructor.
  *
- *  A comprehensive reference for regexp syntax and usage is available as
- *  +Doc::Regexp+.
- *
+ *  :include: doc/re.rdoc
  */
 
 void
Index: lib/rdoc.rb
===================================================================
--- lib/rdoc.rb	(revision 27282)
+++ lib/rdoc.rb	(revision 27283)
@@ -383,7 +383,7 @@
   ##
   # RDoc version you are using
 
-  VERSION = '2.5'
+  VERSION = '2.5.2'
 
   ##
   # Name of the dotfile that contains the description of files to be processed
Index: lib/rdoc/generator/darkfish.rb
===================================================================
--- lib/rdoc/generator/darkfish.rb	(revision 27282)
+++ lib/rdoc/generator/darkfish.rb	(revision 27283)
@@ -1,7 +1,6 @@
 # -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
 # vim: noet ts=2 sts=8 sw=2
 
-require 'pp'
 require 'pathname'
 require 'fileutils'
 require 'erb'
@@ -11,46 +10,46 @@
 $DARKFISH_DRYRUN = false # TODO make me non-global
 
 #
-#  Darkfish RDoc HTML Generator
-#  
-#  $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $
+# Darkfish RDoc HTML Generator
 #
-#  == Author/s
-#  * Michael Granger (ged@F...)
-#  
-#  == Contributors
-#  * Mahlon E. Smith (mahlon@m...)
-#  * Eric Hodel (drbrain@s...)
-#  
-#  == License
-#  
-#  Copyright (c) 2007, 2008, Michael Granger. All rights reserved.
-#  
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions are met:
-#  
-#  * Redistributions of source code must retain the above copyright notice,
-#    this list of conditions and the following disclaimer.
-#  
-#  * Redistributions in binary form must reproduce the above copyright notice,
-#    this list of conditions and the following disclaimer in the documentation
-#    and/or other materials provided with the distribution.
-#  
-#  * Neither the name of the author/s, nor the names of the project's
-#    contributors may be used to endorse or promote products derived from this
-#    software without specific prior written permission.
-#  
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#  
+# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $
+#
+# == Author/s
+# * Michael Granger (ged@F...)
+#
+# == Contributors
+# * Mahlon E. Smith (mahlon@m...)
+# * Eric Hodel (drbrain@s...)
+#
+# == License
+#
+# Copyright (c) 2007, 2008, Michael Granger. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+#   this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+#   this list of conditions and the following disclaimer in the documentation
+#   and/or other materials provided with the distribution.
+#
+# * Neither the name of the author/s, nor the names of the project's
+#   contributors may be used to endorse or promote products derived from this
+#   software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
 class RDoc::Generator::Darkfish
 
 	RDoc::RDoc.add_generator( self )
Index: lib/rdoc/rdoc.rb
===================================================================
--- lib/rdoc/rdoc.rb	(revision 27282)
+++ lib/rdoc/rdoc.rb	(revision 27283)
@@ -135,17 +135,17 @@
   def setup_output_dir(op_dir, force)
     flag_file = output_flag_file op_dir
 
-    last = @last_created
+    last = {}
 
     if File.exist? op_dir then
       unless File.directory? op_dir then
         error "'#{op_dir}' exists, and is not a directory"
       end
       begin
-        open(flag_file) do |f|
+        open flag_file do |io|
           unless force
-            Time.parse(f.gets)
-            f.each do |line|
+            Time.parse f.gets
+            io.each do |line|
               file, time = line.split(/\t/, 2)
               time = Time.parse(time) rescue next
               last[file] = time
@@ -225,19 +225,20 @@
       stat = File.stat rel_file_name rescue next
 
       case type = stat.ftype
-      when "file"
-        next if last_created = @last_created[rel_file_name] and stat.mtime <= last_created
+      when "file" then
+        next if last_created = @last_created[rel_file_name] and
+                stat.mtime <= last_created
 
         if force_doc or RDoc::Parser.can_parse(rel_file_name) then
           file_list << rel_file_name.sub(/^\.\//, '')
           @last_created[rel_file_name] = stat.mtime
         end
-      when "directory"
+      when "directory" then
         next if rel_file_name == "CVS" || rel_file_name == ".svn"
 
         dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
 
-        if File.file?(dot_doc) then
+        if File.file? dot_doc then
           file_list << parse_dot_doc_file(rel_file_name, dot_doc)
         else
           file_list << list_files_in_directory(rel_file_name)
@@ -355,7 +356,7 @@
 
     @exclude = @options.exclude
 
-    setup_output_dir @options.op_dir, @options.force_update
+    @last_created = setup_output_dir @options.op_dir, @options.force_update
 
     start_time = Time.now
 
Index: lib/rdoc/parser.rb
===================================================================
--- lib/rdoc/parser.rb	(revision 27282)
+++ lib/rdoc/parser.rb	(revision 27283)
@@ -73,10 +73,10 @@
       true
     elsif file =~ /erb\.rb$/ then
       false
-    elsif s.scan(/<%|%>/).length >= 4 then
+    elsif s.scan(/<%|%>/).length >= 4 || s.index("\x00") then
       true
     else
-      s.count("^ -~\t\r\n").fdiv(s.size) > 0.3 || s.index("\x00")
+      s.count("^ -~\t\r\n").fdiv(s.size) > 0.3
     end
   end
 
@@ -102,7 +102,9 @@
     return if parser == RDoc::Parser::Simple and zip? file_name
 
     # The default parser must not parse binary files
-    return if parser == RDoc::Parser::Simple and file_name !~ /\.(txt|rdoc)$/
+    ext_name = File.extname file_name
+    return parser if ext_name.empty?
+    return if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/
 
     parser
   end
Index: lib/rdoc/markup/preprocess.rb
===================================================================
--- lib/rdoc/markup/preprocess.rb	(revision 27282)
+++ lib/rdoc/markup/preprocess.rb	(revision 27283)
@@ -41,14 +41,13 @@
     end
   end
 
-  private
-
   ##
   # Include a file, indenting it correctly.
 
   def include_file(name, indent)
     if full_name = find_include_file(name) then
       content = File.read full_name
+      content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
 
       # strip leading '#'s, but only if all lines start with them
       if content =~ /^[^#]/ then
@@ -57,7 +56,7 @@
         content.gsub(/^#?/, indent)
       end
     else
-      $stderr.puts "Couldn't find file to include '#{name}' from #{@input_file_name}"
+      warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
       ''
     end
   end
@@ -67,7 +66,7 @@
   # and then in each of the directories specified in the RDOC_INCLUDE path
 
   def find_include_file(name)
-    to_search = [ File.dirname(@input_file_name) ].concat @include_path
+    to_search = [File.dirname(@input_file_name)].concat @include_path
     to_search.each do |dir|
       full_name = File.join(dir, name)
       stat = File.stat(full_name) rescue next
Index: lib/rdoc/markup/parser.rb
===================================================================
--- lib/rdoc/markup/parser.rb	(revision 27282)
+++ lib/rdoc/markup/parser.rb	(revision 27283)
@@ -463,7 +463,7 @@
                    token
                  when s.scan(/ +/) then
                    [:INDENT, s.matched_size, *token_pos(pos)]
-                 when s.scan(/(=+)\s+/) then
+                 when s.scan(/(=+)\s*/) then
                    level = s[1].length
                    level = 6 if level > 6
                    @tokens << [:HEADER, level, *token_pos(pos)]
Index: lib/rdoc/code_object.rb
===================================================================
--- lib/rdoc/code_object.rb	(revision 27282)
+++ lib/rdoc/code_object.rb	(revision 27283)
@@ -54,25 +54,6 @@
   attr_accessor :viewer
 
   ##
-  # There's a wee trick we pull. Comment blocks can have directives that
-  # override the stuff we extract during the parse. So, we have a special
-  # class method, attr_overridable, that lets code objects list those
-  # directives. When a comment is assigned, we then extract out any matching
-  # directives and update our object
-
-  def self.attr_overridable(name, *aliases)
-    @overridables ||= {}
-
-    attr_accessor name
-
-    aliases.unshift name
-
-    aliases.each do |directive_name|
-      @overridables[directive_name.to_s] = name
-    end
-  end
-
-  ##
   # Creates a new CodeObject that will document itself and its children
 
   def initialize
Index: lib/rdoc/ri/paths.rb
===================================================================
--- lib/rdoc/ri/paths.rb	(revision 27282)
+++ lib/rdoc/ri/paths.rb	(revision 27283)
@@ -13,8 +13,7 @@
   base    = File.join RbConfig::CONFIG['ridir'], version
   SYSDIR  = File.join base, "system"
   SITEDIR = File.join base, "site"
-  HOMEDIR = (File.expand_path("~/.rdoc") rescue nil)
-
+  HOMEDIR = (File.expand_path('~/.rdoc') rescue nil)
   #:startdoc:
 
   @gemdirs = nil
Index: lib/rdoc/ri/driver.rb
===================================================================
--- lib/rdoc/ri/driver.rb	(revision 27282)
+++ lib/rdoc/ri/driver.rb	(revision 27283)
@@ -657,21 +657,13 @@
         end
         out << RDoc::Markup::Rule.new(1)
 
-        if method.call_seq then
-          call_seq = method.call_seq.chomp.split "\n"
-          call_seq = call_seq.map { |line| ['  ', line, "\n"] }
-          out << RDoc::Markup::Verbatim.new(*call_seq.flatten)
+        if method.arglists then
+          arglists = method.arglists.chomp.split "\n"
+          arglists = arglists.map { |line| ['  ', line, "\n"] }
+          out << RDoc::Markup::Verbatim.new(*arglists.flatten)
+          out << RDoc::Markup::Rule.new(1)
         end
 
-        if method.block_params then
-          out << RDoc::Markup::BlankLine.new if method.call_seq
-          params = "yields: #{method.block_params}"
-          out << RDoc::Markup::Verbatim.new('  ', params, "\n")
-        end
-
-        out << RDoc::Markup::Rule.new(1) if
-          method.call_seq or method.block_params
-
         out << RDoc::Markup::BlankLine.new
         out << method.comment
         out << RDoc::Markup::BlankLine.new
@@ -793,7 +785,7 @@
     end
 
     methods.each do |item|
-      yield(*item)
+      yield(*item) # :yields: store, klass, ancestor, types, method
     end
 
     self
Index: lib/rdoc/class_module.rb
===================================================================
--- lib/rdoc/class_module.rb	(revision 27282)
+++ lib/rdoc/class_module.rb	(revision 27283)
@@ -146,10 +146,11 @@
 
   def merge class_module
     comment = class_module.comment
+
     if comment then
       document = parse @comment
 
-      comment.parts.concat(document.parts)
+      comment.parts.concat document.parts
 
       @comment = comment
     end
Index: lib/rdoc/any_method.rb
===================================================================
--- lib/rdoc/any_method.rb	(revision 27282)
+++ lib/rdoc/any_method.rb	(revision 27283)
@@ -6,7 +6,7 @@
 
 class RDoc::AnyMethod < RDoc::CodeObject
 
-  MARSHAL_VERSION = 0 # :nodoc:
+  MARSHAL_VERSION = 1 # :nodoc:
 
   include Comparable
 
@@ -58,7 +58,7 @@
   ##
   # Parameters for this method
 
-  attr_overridable :params, :param, :parameters, :parameter
+  attr_accessor :params
 
   ##
   # Different ways to call this method
@@ -87,6 +87,7 @@
     @call_seq               = nil
     @dont_rename_initialize = false
     @is_alias_for           = nil
+    @params                 = nil
     @parent_name            = nil
     @singleton              = nil
     @token_stream           = nil
@@ -111,6 +112,19 @@
   end
 
   ##
+  # The call_seq or the param_seq with method name, if there is no call_seq.
+  #
+  # Use this for displaying a method's argument lists.
+
+  def arglists
+    if @call_seq then
+      @call_seq
+    elsif @params then
+      "#{name}#{param_seq}"
+    end
+  end
+
+  ##
   # HTML id-friendly method name
 
   def html_name
@@ -151,6 +165,7 @@
       @call_seq,
       @block_params,
       aliases,
+      @params,
     ]
   end
 
@@ -162,7 +177,6 @@
   # * #parent_name
 
   def marshal_load(array)
-    @aliases                = []
     @dont_rename_initialize = nil
     @is_alias_for           = nil
     @token_stream           = nil
@@ -174,6 +188,8 @@
     @comment      = array[5]
     @call_seq     = array[6]
     @block_params = array[7]
+    @aliases      = array[8]
+    @params       = array[9]
 
     @parent_name = if @full_name =~ /#/ then
                      $`
@@ -201,16 +217,16 @@
   # Pretty parameter list for this method
 
   def param_seq
-    params = params.gsub(/\s*\#.*/, '')
+    params = @params.gsub(/\s*\#.*/, '')
     params = params.tr("\n", " ").squeeze(" ")
-    params = "(#{params})" unless p[0] == ?(
+    params = "(#{params})" unless params[0] == ?(
 
-    if block = block_params then # yes, =
+    if @block_params then
       # If this method has explicit block parameters, remove any explicit
       # &block
-      params.sub!(/,?\s*&\w+/)
+      params.sub!(/,?\s*&\w+/, '')
 
-      block.gsub!(/\s*\#.*/, '')
+      block = @block_params.gsub(/\s*\#.*/, '')
       block = block.tr("\n", " ").squeeze(" ")
       if block[0] == ?(
         block.sub!(/^\(/, '').sub!(/\)/, '')
Index: lib/rdoc/ruby_lex.rb
===================================================================
--- lib/rdoc/ruby_lex.rb	(revision 27282)
+++ lib/rdoc/ruby_lex.rb	(revision 27283)
@@ -359,6 +359,8 @@
     "(" => ")"
   }
 
+  PERCENT_PAREN_REV = PERCENT_PAREN.invert
+
   Ltype2Token = {
     "\'" => TkSTRING,
     "\"" => TkSTRING,
@@ -1120,8 +1122,13 @@
   def identify_string(ltype, quoted = ltype)
     @ltype = ltype
     @quoted = quoted
-    str = @ltype.dup
 
+    str = if ltype == quoted then
+            ltype.dup
+          else
+            "%#{PERCENT_PAREN_REV[quoted]}"
+          end
+
     subtype = nil
     begin
       nest = 0
@@ -1136,6 +1143,7 @@
           subtype = true
           if ch == "{" then
             str << ch << skip_inner_expression
+            next
           else
             ungetc
           end
@@ -1179,7 +1187,7 @@
   def skip_inner_expression
     res = ""
     nest = 0
-    while (ch = getc)
+    while ch = getc
       res << ch
       if ch == '}'
         break if nest.zero?
Index: lib/rdoc/parser/ruby.rb
===================================================================
--- lib/rdoc/parser/ruby.rb	(revision 27282)
+++ lib/rdoc/parser/ruby.rb	(revision 27283)
@@ -146,7 +146,7 @@
 
 class RDoc::Parser::Ruby < RDoc::Parser
 
-  parse_files_matching(/\.(?:rbw?|rdoc)\z/)
+  parse_files_matching(/\.rbw?$/)
 
   include RDoc::RubyToken
   include RDoc::TokenStream
@@ -212,7 +212,7 @@
   def error(msg)
     msg = make_message msg
     $stderr.puts msg
-    exit(false)
+    exit false
   end
 
   ##
@@ -377,10 +377,9 @@
   # This routine modifies it's parameter
 
   def look_for_directives_in(context, comment)
-    preprocess = RDoc::Markup::PreProcess.new(@file_name,
-                                              @options.rdoc_include)
+    preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
 
-    preprocess.handle(comment) do |directive, param|
+    preprocess.handle comment do |directive, param|
       case directive
       when 'enddoc' then
         throw :enddoc
@@ -391,7 +390,7 @@
            'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then
         false # handled elsewhere
       when 'section' then
-        context.set_current_section(param, comment)
+        context.set_current_section param, comment
         comment.replace ''
         break
       when 'startdoc' then
@@ -405,7 +404,7 @@
         @options.title = param
         ''
       else
-        warn "Unrecognized directive '#{directive}'"
+        warn "Unrecognized directive :#{directive}:"
         false
       end
     end
@@ -1405,16 +1404,12 @@
     end
   end
 
-  def parse_yield_parameters
-    parse_method_or_yield_parameters
-  end
-
   def parse_yield(context, single, tk, method)
-    if method.block_params.nil?
-      get_tkread
-      @scanner.instance_eval{@continue = false}
-      method.block_params = parse_yield_parameters
-    end
+    return if method.block_params
+
+    get_tkread
+    @scanner.instance_eval { @continue = false }
+    method.block_params = parse_method_or_yield_parameters
   end
 
   ##
Index: lib/rdoc/parser/c.rb
===================================================================
--- lib/rdoc/parser/c.rb	(revision 27282)
+++ lib/rdoc/parser/c.rb	(revision 27283)
@@ -227,8 +227,8 @@
       next if var_name == "argf"   # it'd be nice to handle this one
 
       var_name = "rb_cObject" if var_name == "rb_mKernel"
-      handle_method(type, var_name, meth_name,
-                    meth_body, param_count, source_file)
+      handle_method(type, var_name, meth_name, meth_body, param_count,
+                    source_file)
     end
 
     @content.scan(%r{rb_define_attr\(
@@ -304,7 +304,7 @@
 
       find_modifiers comment, meth_obj if comment
 
-#        meth_obj.params = params
+      #meth_obj.params = params
       meth_obj.start_collecting_tokens
       tk = RDoc::RubyToken::Token.new nil, 1, 1
       tk.set_text body_text
@@ -397,7 +397,13 @@
       comment = $1
     end
 
-    class_mod.comment = strip_stars comment if comment
+    return unless comment
+
+    comment = strip_stars comment
+
+    comment = look_for_directives_in class_mod, comment
+
+    class_mod.comment = comment
   end
 
   ##
@@ -479,7 +485,7 @@
       end
 
       unless enclosure then
-        warn("Enclosing class/module '#{in_module}' for #{type} #{class_name} not known")
+        warn "Enclosing class/module '#{in_module}' for #{type} #{class_name} not known"
         return
       end
     else
@@ -601,9 +607,9 @@
       meth_obj = RDoc::AnyMethod.new '', meth_name
       meth_obj.singleton = %w[singleton_method module_function].include? type
 
-      p_count = (Integer(param_count) rescue -1)
+      p_count = Integer(param_count) rescue -1
 
-      if p_count < 0
+      if p_count < 0 then
         meth_obj.params = "(...)"
       elsif p_count == 0
         meth_obj.params = "()"
@@ -611,10 +617,14 @@
         meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")"
       end
 
-      if source_file and File.exist?(file_name = File.join(@file_dir, source_file)) then
-        body = (@@known_bodies[source_file] ||= File.read(file_name))
-      elsif source_file then
-        warn "unknown source file #{source_file}"
+      if source_file then
+        file_name = File.join @file_dir, source_file
+
+        if File.exist? file_name then
+          body = (@@known_bodies[file_name] ||= File.read(file_name))
+        else
+          warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
+        end
       else
         body = @content
       end
@@ -640,6 +650,34 @@
   end
 
   ##
+  # Look for directives in a normal comment block:
+  #
+  #   /*
+  #    * :title: My Awesome Project
+  #    */
+  #
+  # This routine modifies it's parameter
+
+  def look_for_directives_in(context, comment)
+    preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
+
+    preprocess.handle comment do |directive, param|
+      case directive
+      when 'main' then
+        @options.main_page = param
+        ''
+      when 'title' then
+        @options.title = param
+        ''
+      else
+        warn "Unrecognized directive :#{directive}:"
+        false
+      end
+    end
+
+    comment
+  end
+  ##
   # Removes lines that are commented out that might otherwise get picked up
   # when scanning for classes and methods
 
@@ -648,8 +686,8 @@
   end
 
   def remove_private_comments(comment)
-     comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
-     comment.sub!(/\/?\*--\n.*/m, '')
+    comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
+    comment.sub!(/\/?\*--\n.*/m, '')
   end
 
   ##
Index: lib/rdoc/parser/simple.rb
===================================================================
--- lib/rdoc/parser/simple.rb	(revision 27282)
+++ lib/rdoc/parser/simple.rb	(revision 27283)
@@ -24,7 +24,10 @@
   # Extract the file contents and attach them to the TopLevel as a comment
 
   def scan
-    @top_level.comment = remove_private_comments(@content)
+    comment = remove_coding_comment @content
+    comment = remove_private_comments comment
+
+    @top_level.comment = comment
     @top_level.parser = self.class
     @top_level
   end
@@ -33,5 +36,9 @@
     comment.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '')
   end
 
+  def remove_coding_comment text
+    text.sub(/\A# .*coding[=:].*$/, '')
+  end
+
 end
 
Index: lib/rdoc/task.rb
===================================================================
--- lib/rdoc/task.rb	(revision 27282)
+++ lib/rdoc/task.rb	(revision 27283)
@@ -160,24 +160,28 @@
   # Create the tasks defined by this task lib.
 
   def define
-    desc "Build the RDoc HTML files"
+    desc "Build RDoc HTML files"
     task rdoc_task_name
 
-    desc "Force rebuild RDoc HTML files"
+    desc "Rebuild RDoc HTML files"
     task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
 
     desc "Remove RDoc HTML files"
     task clobber_task_name do
-      rm_r rdoc_dir rescue nil
+      rm_r @rdoc_dir rescue nil
     end
 
     task :clobber => [clobber_task_name]
 
     directory @rdoc_dir
 
+    rdoc_target_deps = [
+      @rdoc_files,
+      Rake.application.rakefile
+    ].flatten.compact
+
     task rdoc_task_name => [rdoc_target]
-    file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
-      rm_r @rdoc_dir rescue nil
+    file rdoc_target => rdoc_target_deps do
       @before_running_rdoc.call if @before_running_rdoc
       args = option_list + @rdoc_files
 
Index: lib/rdoc/attr.rb
===================================================================
--- lib/rdoc/attr.rb	(revision 27282)
+++ lib/rdoc/attr.rb	(revision 27283)
@@ -56,6 +56,12 @@
   ##
   # Returns nil, for duck typing with RDoc::AnyMethod
 
+  def arglists
+  end
+
+  ##
+  # Returns nil, for duck typing with RDoc::AnyMethod
+
   def block_params
   end
 
@@ -133,6 +139,13 @@
   end
 
   ##
+  # For duck typing with RDoc::AnyMethod, returns nil
+
+  def params
+    nil
+  end
+
+  ##
   # URL path for this attribute
 
   def path
Index: NEWS
===================================================================
--- NEWS	(revision 27282)
+++ NEWS	(revision 27283)
@@ -199,6 +199,10 @@
 
     http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
 
+* RDoc
+
+  * Updated to RDoc 2.5.2
+
 * logger
 
   * imported upstream version (logger/1.2.7)
Index: test/rdoc/test_rdoc_attr.rb
===================================================================
--- test/rdoc/test_rdoc_attr.rb	(revision 27282)
+++ test/rdoc/test_rdoc_attr.rb	(revision 27283)
@@ -8,6 +8,10 @@
     @a = RDoc::Attr.new nil, 'attr', 'RW', ''
   end
 
+  def test_arglists
+    assert_nil @a.arglists
+  end
+
   def test_block_params
     assert_nil @a.block_params
   end
@@ -20,6 +24,10 @@
     assert_equal '(unknown)#attr', @a.full_name
   end
 
+  def test_params
+    assert_nil @a.params
+  end
+
   def test_singleton
     refute @a.singleton
   end
Index: test/rdoc/test_rdoc_rdoc.rb
===================================================================
--- test/rdoc/test_rdoc_rdoc.rb	(revision 27282)
+++ test/rdoc/test_rdoc_rdoc.rb	(revision 27283)
@@ -15,8 +15,8 @@
   end
 
   def test_gather_files
-    file = File.expand_path("../../../lib/rdoc.rb", __FILE__)
-    assert_equal([file], @rdoc.gather_files([file, file]))
+    file = File.expand_path __FILE__
+    assert_equal [file], @rdoc.gather_files([file, file])
   end
 
   def test_read_file_contents
Index: test/rdoc/test_rdoc_parser.rb
===================================================================
--- test/rdoc/test_rdoc_parser.rb	(revision 27282)
+++ test/rdoc/test_rdoc_parser.rb	(revision 27283)
@@ -55,7 +55,10 @@
     assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
 
     jtest_rdoc_file_name = File.expand_path '../test.ja.rdoc', __FILE__
-    assert_equal @RP::Ruby, @RP.can_parse(jtest_rdoc_file_name)
+    assert_equal @RP::Simple, @RP.can_parse(jtest_rdoc_file_name)
+
+    readme_file_name = File.expand_path '../README', __FILE__
+    assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
   end
 
   ##
Index: test/rdoc/test_rdoc_markup_pre_process.rb
===================================================================
--- test/rdoc/test_rdoc_markup_pre_process.rb	(revision 0)
+++ test/rdoc/test_rdoc_markup_pre_process.rb	(revision 27283)
@@ -0,0 +1,42 @@
+require 'tempfile'
+require 'rubygems'
+require 'minitest/autorun'
+require 'rdoc/markup/preprocess'
+
+class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
+
+  def setup
+    @tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
+    @name = File.basename @tempfile.path
+    @dir  = File.dirname @tempfile.path
+
+    @pp = RDoc::Markup::PreProcess.new __FILE__, [@dir]
+  end
+
+  def teardown
+    @tempfile.close
+  end
+
+  def test_include_file
+    @tempfile.write <<-INCLUDE
+# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+    INCLUDE
+
+    @tempfile.flush
+    @tempfile.rewind
+
+    content = @pp.include_file @name, ''
+
+    expected = <<-EXPECTED
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+    EXPECTED
+
+    assert_equal expected, content
+  end
+
+end
+

Property changes on: test/rdoc/test_rdoc_markup_pre_process.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: test/rdoc/test_rdoc_markup_parser.rb
===================================================================
--- test/rdoc/test_rdoc_markup_parser.rb	(revision 27282)
+++ test/rdoc/test_rdoc_markup_parser.rb	(revision 27283)
@@ -1004,6 +1004,24 @@
     assert_equal expected, @RMP.tokenize(str)
   end
 
+  def test_tokenize_heading_no_space
+    str = <<-STR
+=Heading
+==Heading 2
+    STR
+
+    expected = [
+      [:HEADER,  1,            0, 0],
+      [:TEXT,    'Heading',    1, 0],
+      [:NEWLINE, "\n",         8, 0],
+      [:HEADER,  2,            0, 1],
+      [:TEXT,    'Heading 2',  2, 1],
+      [:NEWLINE, "\n",        11, 1],
+    ]
+
+    assert_equal expected, @RMP.tokenize(str)
+  end
+
   def test_tokenize_label
     str = <<-STR
 [cat] l1
Index: test/rdoc/README
===================================================================
--- test/rdoc/README	(revision 0)
+++ test/rdoc/README	(revision 27283)
@@ -0,0 +1 @@
+you don't have to

Property changes on: test/rdoc/README
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: test/rdoc/test_rdoc_ri_driver.rb
===================================================================
--- test/rdoc/test_rdoc_ri_driver.rb	(revision 27282)
+++ test/rdoc/test_rdoc_ri_driver.rb	(revision 27283)
@@ -366,7 +366,6 @@
     assert_match %r%Foo::Bar#blah%, out
     assert_match %r%blah.5%,        out
     assert_match %r%blah.6%,        out
-    assert_match %r%yields: stuff%, out
   end
 
   def test_display_method_attribute
@@ -425,6 +424,16 @@
     assert_equal expected, out
   end
 
+  def test_display_method_params
+    util_store
+
+    out, err = capture_io do
+      @driver.display_method 'Foo::Bar#bother'
+    end
+
+    assert_match %r%things.*stuff%, out
+  end
+
   def test_expand_class
     util_store
 
@@ -511,7 +520,7 @@
     util_store
 
     out, err = capture_io do
-      @driver.list_known_classes
+      @driver.list_known_classes 
     end
 
     assert_equal "Ambiguous\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out
@@ -675,7 +684,7 @@
   def test_setup_pager
     @driver.use_stdout = false
 
-    pager = with_dummy_pager {@driver.setup_pager}
+    pager = with_dummy_pager do @driver.setup_pager end
 
     skip "couldn't find a standard pager" unless pager
 
@@ -776,9 +785,10 @@
 
     @blah = RDoc::AnyMethod.new nil, 'blah'
     @blah.call_seq = "blah(5) => 5\nblah(6) => 6\n"
-    @blah.block_params = "stuff"
 
     @bother = RDoc::AnyMethod.new nil, 'bother'
+    @bother.params = "(things)"
+    @bother.block_params = "stuff"
 
     @new  = RDoc::AnyMethod.new nil, 'new'
     @new.singleton = true
Index: test/rdoc/test_rdoc_any_method.rb
===================================================================
--- test/rdoc/test_rdoc_any_method.rb	(revision 27282)
+++ test/rdoc/test_rdoc_any_method.rb	(revision 27283)
@@ -2,25 +2,42 @@
 
 class RDocAnyMethodTest < XrefTestCase
 
+  def test_arglists
+    m = RDoc::AnyMethod.new nil, 'method'
+
+    assert_nil m.arglists
+
+    m.params = "(a, b)"
+    m.block_params = "c, d"
+
+    assert_equal "method(a, b) { |c, d| ... }", m.arglists
+
+    call_seq = <<-SEQ
+method(a) { |c| ... }
+method(a, b) { |c, d| ... }
+    SEQ
+
+    m.call_seq = call_seq.dup
+
+    assert_equal call_seq, m.arglists
+  end
+
   def test_full_name
     assert_equal 'C1::m', @c1.method_list.first.full_name
   end
 
-  def test_parent_name
-    assert_equal 'C1', @c1.method_list.first.parent_name
-    assert_equal 'C1', @c1.method_list.last.parent_name
-  end
-
   def test_marshal_load
     instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
 
-    assert_equal 'C1#m', instance_method.full_name
-    assert_equal 'C1',   instance_method.parent_name
+    assert_equal 'C1#m',  instance_method.full_name
+    assert_equal 'C1',    instance_method.parent_name
+    assert_equal '(foo)', instance_method.params
 
     class_method = Marshal.load Marshal.dump(@c1.method_list.first)
 
     assert_equal 'C1::m', class_method.full_name
     assert_equal 'C1',    class_method.parent_name
+    assert_equal '()',    class_method.params
   end
 
   def test_name
@@ -29,5 +46,30 @@
     assert_nil m.name
   end
 
+  def test_param_seq
+    m = RDoc::AnyMethod.new nil, 'method'
+    m.parent = @c1
+    m.params = 'a'
+
+    assert_equal '(a)', m.param_seq
+
+    m.params = '(a)'
+
+    assert_equal '(a)', m.param_seq
+
+    m.params = "(a,\n  b)"
+
+    assert_equal '(a, b)', m.param_seq
+
+    m.block_params = "c,\n  d"
+
+    assert_equal '(a, b) { |c, d| ... }', m.param_seq
+  end
+
+  def test_parent_name
+    assert_equal 'C1', @c1.method_list.first.parent_name
+    assert_equal 'C1', @c1.method_list.last.parent_name
+  end
+
 end
 
Index: test/rdoc/xref_data.rb
===================================================================
--- test/rdoc/xref_data.rb	(revision 27282)
+++ test/rdoc/xref_data.rb	(revision 27283)
@@ -11,7 +11,7 @@
   def self.m
   end
 
-  def m
+  def m foo
   end
 end
 
Index: test/rdoc/test_rdoc_parser_ruby.rb
===================================================================
--- test/rdoc/test_rdoc_parser_ruby.rb	(revision 27282)
+++ test/rdoc/test_rdoc_parser_ruby.rb	(revision 27283)
@@ -1246,14 +1246,22 @@
 
   # If you're writing code like this you're doing it wrong
 
-  def x_test_sanity_interpolation_crazy
+  def test_sanity_interpolation_crazy
     last_tk = nil
     util_parser '"#{"#{"a")}" if b}"'
 
-    assert_equal RDoc::RubyToken::TkDSTRING, tk.class
+    assert_equal '"#{"#{"a")}" if b}"', @parser.get_tk.text
     assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
   end
 
+  def test_sanity_interpolation_curly
+    last_tk = nil
+    util_parser '%{ #{} }'
+
+    assert_equal '%{ #{} }', @parser.get_tk.text
+    assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
+  end
+
   def test_sanity_interpolation_format
     util_parser '"#{stftime("%m-%d")}"'
 
Index: test/rdoc/test_rdoc_parser_c.rb
===================================================================
--- test/rdoc/test_rdoc_parser_c.rb	(revision 27282)
+++ test/rdoc/test_rdoc_parser_c.rb	(revision 27283)
@@ -201,6 +201,26 @@
     assert constants.empty?, constants.inspect
   end
 
+  def test_find_class_comment_include
+    @options.rdoc_include << File.dirname(__FILE__)
+
+    content = <<-EOF
+/*
+ * a comment for class Foo
+ *
+ * :include: test.txt
+ */
+void
+Init_Foo(void) {
+  VALUE foo = rb_define_class("Foo", rb_cObject);
+}
+    EOF
+
+    klass = util_get_class content, 'foo'
+
+    assert_equal "a comment for class Foo\n\ntest file", klass.comment
+  end
+
   def test_find_class_comment_init
     content = <<-EOF
 /*
Index: test/rdoc/test_rdoc_parser_simple.rb
===================================================================
--- test/rdoc/test_rdoc_parser_simple.rb	(revision 27282)
+++ test/rdoc/test_rdoc_parser_simple.rb	(revision 27283)
@@ -22,6 +22,25 @@
     @tempfile.close
   end
 
+  def test_remove_coding_comment
+    parser = util_parser <<-TEXT
+# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+    TEXT
+
+    parser.scan
+
+    expected = <<-TEXT.strip
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+    TEXT
+
+    assert_equal expected, @top_level.comment
+  end
+
   def test_remove_private_comments
     parser = util_parser ''
     text = "foo\n\n--\nbar\n++\n\nbaz\n"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]