From 1325437297539bf433904b64db63a3186e62177e Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 10 Apr 2010 06:36:13 +0000 Subject: * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/any_method.rb | 32 ++++++++++++----- lib/rdoc/attr.rb | 13 +++++++ lib/rdoc/class_module.rb | 3 +- lib/rdoc/code_object.rb | 19 ---------- lib/rdoc/generator/darkfish.rb | 79 +++++++++++++++++++++--------------------- lib/rdoc/markup/parser.rb | 2 +- lib/rdoc/markup/preprocess.rb | 7 ++-- lib/rdoc/parser.rb | 8 +++-- lib/rdoc/parser/c.rb | 64 +++++++++++++++++++++++++++------- lib/rdoc/parser/ruby.rb | 27 ++++++--------- lib/rdoc/parser/simple.rb | 9 ++++- lib/rdoc/rdoc.rb | 19 +++++----- lib/rdoc/ri/driver.rb | 20 ++++------- lib/rdoc/ri/paths.rb | 3 +- lib/rdoc/ruby_lex.rb | 12 +++++-- lib/rdoc/task.rb | 14 +++++--- 16 files changed, 193 insertions(+), 138 deletions(-) (limited to 'lib/rdoc') diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb index 5d291e82c8..f3f83363cd 100644 --- a/lib/rdoc/any_method.rb +++ b/lib/rdoc/any_method.rb @@ -6,7 +6,7 @@ require 'rdoc/tokenstream' class RDoc::AnyMethod < RDoc::CodeObject - MARSHAL_VERSION = 0 # :nodoc: + MARSHAL_VERSION = 1 # :nodoc: include Comparable @@ -58,7 +58,7 @@ class RDoc::AnyMethod < RDoc::CodeObject ## # Parameters for this method - attr_overridable :params, :param, :parameters, :parameter + attr_accessor :params ## # Different ways to call this method @@ -87,6 +87,7 @@ class RDoc::AnyMethod < RDoc::CodeObject @call_seq = nil @dont_rename_initialize = false @is_alias_for = nil + @params = nil @parent_name = nil @singleton = nil @token_stream = nil @@ -110,6 +111,19 @@ class RDoc::AnyMethod < RDoc::CodeObject @aliases << method 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 @@ -151,6 +165,7 @@ class RDoc::AnyMethod < RDoc::CodeObject @call_seq, @block_params, aliases, + @params, ] end @@ -162,7 +177,6 @@ class RDoc::AnyMethod < RDoc::CodeObject # * #parent_name def marshal_load(array) - @aliases = [] @dont_rename_initialize = nil @is_alias_for = nil @token_stream = nil @@ -174,6 +188,8 @@ class RDoc::AnyMethod < RDoc::CodeObject @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 @@ class RDoc::AnyMethod < RDoc::CodeObject # 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!(/\)/, '') diff --git a/lib/rdoc/attr.rb b/lib/rdoc/attr.rb index 43ded8e610..9b8c4562c2 100644 --- a/lib/rdoc/attr.rb +++ b/lib/rdoc/attr.rb @@ -56,6 +56,12 @@ class RDoc::Attr < RDoc::CodeObject ## # Returns nil, for duck typing with RDoc::AnyMethod + def arglists + end + + ## + # Returns nil, for duck typing with RDoc::AnyMethod + def block_params end @@ -132,6 +138,13 @@ class RDoc::Attr < RDoc::CodeObject @parent_name || super end + ## + # For duck typing with RDoc::AnyMethod, returns nil + + def params + nil + end + ## # URL path for this attribute diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index 321aaee57d..16b85d7918 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -146,10 +146,11 @@ class RDoc::ClassModule < RDoc::Context 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 diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 2fcc92e8b5..5574194d00 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -53,25 +53,6 @@ class RDoc::CodeObject 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 diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 51339ebce3..497be0eb8b 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -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 @@ require 'rdoc/generator/markup' $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 +# +# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $ +# +# == Author/s +# * Michael Granger (ged@FaerieMUD.org) +# +# == Contributors +# * Mahlon E. Smith (mahlon@martini.nu) +# * Eric Hodel (drbrain@segment7.net) +# +# == 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. # -# == Author/s -# * Michael Granger (ged@FaerieMUD.org) -# -# == Contributors -# * Mahlon E. Smith (mahlon@martini.nu) -# * Eric Hodel (drbrain@segment7.net) -# -# == 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 ) diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb index c0d6519fd5..166d8f89f7 100644 --- a/lib/rdoc/markup/parser.rb +++ b/lib/rdoc/markup/parser.rb @@ -463,7 +463,7 @@ class RDoc::Markup::Parser 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)] diff --git a/lib/rdoc/markup/preprocess.rb b/lib/rdoc/markup/preprocess.rb index a175d179cf..7aac9df74a 100644 --- a/lib/rdoc/markup/preprocess.rb +++ b/lib/rdoc/markup/preprocess.rb @@ -41,14 +41,13 @@ class RDoc::Markup::PreProcess 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 @@ class RDoc::Markup::PreProcess 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 @@ class RDoc::Markup::PreProcess # 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 diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index a5c7de663f..01e24e5d4b 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -73,10 +73,10 @@ class RDoc::Parser 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 @@ class RDoc::Parser 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 diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index 0f728ed9f2..27236a3ff5 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -227,8 +227,8 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ class RDoc::Parser::C < RDoc::Parser 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 @@ -639,6 +649,34 @@ class RDoc::Parser::C < RDoc::Parser end 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 @@ class RDoc::Parser::C < RDoc::Parser end def remove_private_comments(comment) - comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '') - comment.sub!(/\/?\*--\n.*/m, '') + comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '') + comment.sub!(/\/?\*--\n.*/m, '') end ## diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 7550508b81..b1684a6900 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -146,7 +146,7 @@ $TOKEN_DEBUG ||= nil 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 @@ class RDoc::Parser::Ruby < RDoc::Parser def error(msg) msg = make_message msg $stderr.puts msg - exit(false) + exit false end ## @@ -377,10 +377,9 @@ class RDoc::Parser::Ruby < RDoc::Parser # 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 @@ class RDoc::Parser::Ruby < RDoc::Parser '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 @@ class RDoc::Parser::Ruby < RDoc::Parser @options.title = param '' else - warn "Unrecognized directive '#{directive}'" + warn "Unrecognized directive :#{directive}:" false end end @@ -1405,16 +1404,12 @@ class RDoc::Parser::Ruby < RDoc::Parser 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 ## diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb index 9072667f89..37125ff299 100644 --- a/lib/rdoc/parser/simple.rb +++ b/lib/rdoc/parser/simple.rb @@ -24,7 +24,10 @@ class RDoc::Parser::Simple < RDoc::Parser # 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 @@ class RDoc::Parser::Simple < RDoc::Parser comment.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '') end + def remove_coding_comment text + text.sub(/\A# .*coding[=:].*$/, '') + end + end diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 493dada4f0..736c77eb23 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -135,17 +135,17 @@ class RDoc::RDoc 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 @@ class RDoc::RDoc 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 @@ The internal error was: @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 diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index d3620d4817..9083f6c67a 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -657,21 +657,13 @@ Options may also be set in the 'RI' environment variable. 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 @@ Options may also be set in the 'RI' environment variable. end methods.each do |item| - yield(*item) + yield(*item) # :yields: store, klass, ancestor, types, method end self diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb index 8ea260891b..df12045203 100644 --- a/lib/rdoc/ri/paths.rb +++ b/lib/rdoc/ri/paths.rb @@ -13,8 +13,7 @@ module RDoc::RI::Paths 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 diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index 59de6cc762..ab5f32ba42 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -359,6 +359,8 @@ class RDoc::RubyLex "(" => ")" } + PERCENT_PAREN_REV = PERCENT_PAREN.invert + Ltype2Token = { "\'" => TkSTRING, "\"" => TkSTRING, @@ -1120,7 +1122,12 @@ class RDoc::RubyLex 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 @@ -1136,6 +1143,7 @@ class RDoc::RubyLex subtype = true if ch == "{" then str << ch << skip_inner_expression + next else ungetc end @@ -1179,7 +1187,7 @@ class RDoc::RubyLex def skip_inner_expression res = "" nest = 0 - while (ch = getc) + while ch = getc res << ch if ch == '}' break if nest.zero? diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb index 6417a66969..005c516eed 100644 --- a/lib/rdoc/task.rb +++ b/lib/rdoc/task.rb @@ -160,24 +160,28 @@ class RDoc::Task < Rake::TaskLib # 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 -- cgit v1.2.3