Skip to content

Commit

Permalink
* lib/rdoc: Import RDoc 2.5.2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drbrain committed Apr 10, 2010
1 parent ce2b574 commit 1325437
Show file tree
Hide file tree
Showing 33 changed files with 395 additions and 162 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Sat Apr 10 15:18:26 2010 Eric Hodel <[email protected]>

* 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 <[email protected]>

* ext/openssl/ossl_ssl.c (Init_ossl_ssl): add SSLContext#ssl_timeout=,
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ with all sufficient information, see the ChangeLog file.

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)
Expand Down
4 changes: 1 addition & 3 deletions doc/re.rdoc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -580,5 +579,4 @@ backtracking needed.

Regexp.new('\A' 'a?' * 29 + 'a' * 29).match('a' * 29)
#=> #<MatchData "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa">
=end
class Regexp; end

2 changes: 1 addition & 1 deletion lib/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def self.const_missing const_name # :nodoc:
##
# 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
Expand Down
32 changes: 24 additions & 8 deletions lib/rdoc/any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class RDoc::AnyMethod < RDoc::CodeObject

MARSHAL_VERSION = 0 # :nodoc:
MARSHAL_VERSION = 1 # :nodoc:

include Comparable

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -87,6 +87,7 @@ def initialize(text, name)
@call_seq = nil
@dont_rename_initialize = false
@is_alias_for = nil
@params = nil
@parent_name = nil
@singleton = nil
@token_stream = nil
Expand All @@ -110,6 +111,19 @@ def add_alias(method)
@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

Expand Down Expand Up @@ -151,6 +165,7 @@ def marshal_dump
@call_seq,
@block_params,
aliases,
@params,
]
end

Expand All @@ -162,7 +177,6 @@ def marshal_dump
# * #parent_name

def marshal_load(array)
@aliases = []
@dont_rename_initialize = nil
@is_alias_for = nil
@token_stream = nil
Expand All @@ -174,6 +188,8 @@ def marshal_load(array)
@comment = array[5]
@call_seq = array[6]
@block_params = array[7]
@aliases = array[8]
@params = array[9]

@parent_name = if @full_name =~ /#/ then
$`
Expand Down Expand Up @@ -201,16 +217,16 @@ def name
# 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!(/\)/, '')
Expand Down
13 changes: 13 additions & 0 deletions lib/rdoc/attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def == other
##
# Returns nil, for duck typing with RDoc::AnyMethod

def arglists
end

##
# Returns nil, for duck typing with RDoc::AnyMethod

def block_params
end

Expand Down Expand Up @@ -132,6 +138,13 @@ def parent_name
@parent_name || super
end

##
# For duck typing with RDoc::AnyMethod, returns nil

def params
nil
end

##
# URL path for this attribute

Expand Down
3 changes: 2 additions & 1 deletion lib/rdoc/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ def marshal_load array # :nodoc:

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
Expand Down
19 changes: 0 additions & 19 deletions lib/rdoc/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
79 changes: 39 additions & 40 deletions lib/rdoc/generator/darkfish.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
#
# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $
#
# == Author/s
# * Michael Granger ([email protected])
#
# == Contributors
# * Mahlon E. Smith ([email protected])
# * Eric Hodel ([email protected])
#
# == 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 ([email protected])
#
# == Contributors
# * Mahlon E. Smith ([email protected])
# * Eric Hodel ([email protected])
#
# == 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 )
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/markup/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def tokenize input
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)]
Expand Down
7 changes: 3 additions & 4 deletions lib/rdoc/markup/preprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ def handle(text)
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
Expand All @@ -57,7 +56,7 @@ def include_file(name, indent)
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
Expand All @@ -67,7 +66,7 @@ def include_file(name, indent)
# 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
Expand Down
8 changes: 5 additions & 3 deletions lib/rdoc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def self.binary?(file)
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

Expand All @@ -102,7 +102,9 @@ def self.can_parse(file_name)
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
Expand Down
Loading

0 comments on commit 1325437

Please sign in to comment.