1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc: Update to RDoc 4.2.0.

* test/rdoc:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2014-12-07 01:22:37 +00:00
parent 7d2d6d0a2f
commit 4260aa1dc3
28 changed files with 622 additions and 177 deletions

View file

@ -1,3 +1,8 @@
Sun Dec 7 10:20:55 2014 Eric Hodel <drbrain@segment7.net>
* lib/rdoc: Update to RDoc 4.2.0.
* test/rdoc: ditto.
Sun Dec 7 09:52:30 2014 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems 2.4.5.

View file

@ -64,7 +64,7 @@ module RDoc
##
# RDoc version you are using
VERSION = '4.2.0.alpha'
VERSION = '4.2.0'
##
# Method visibilities

View file

@ -62,14 +62,14 @@ class RDoc::Generator::Darkfish
BUILTIN_STYLE_ITEMS = # :nodoc:
%w[
fonts.css
css/fonts.css
fonts/Lato-Light.ttf
fonts/Lato-LightItalic.ttf
fonts/Lato-Regular.ttf
fonts/Lato-RegularItalic.ttf
fonts/SourceCodePro-Bold.ttf
fonts/SourceCodePro-Regular.ttf
rdoc.css
css/rdoc.css
]
##
@ -246,6 +246,7 @@ class RDoc::Generator::Darkfish
generate_file_files
generate_table_of_contents
@json_index.generate
@json_index.generate_gzipped
copy_static

View file

@ -1,4 +1,5 @@
require 'json'
require 'zlib'
##
# The JsonIndex generator is designed to complement an HTML generator and
@ -152,6 +153,49 @@ class RDoc::Generator::JsonIndex
end
end
##
# Compress the search_index.js file using gzip
def generate_gzipped
debug_msg "Compressing generated JSON index"
out_dir = @base_dir + @options.op_dir
search_index_file = out_dir + SEARCH_INDEX_FILE
outfile = out_dir + "#{search_index_file}.gz"
debug_msg "Reading the JSON index file from %s" % search_index_file
search_index = search_index_file.read
debug_msg "Writing gzipped search index to %s" % outfile
Zlib::GzipWriter.open(outfile) do |gz|
gz.mtime = File.mtime(search_index_file)
gz.orig_name = search_index_file.to_s
gz.write search_index
gz.close
end
# GZip the rest of the js files
Dir.chdir @template_dir do
Dir['**/*.js'].each do |source|
dest = out_dir + source
outfile = out_dir + "#{dest}.gz"
debug_msg "Reading the original js file from %s" % dest
data = dest.read
debug_msg "Writing gzipped file to %s" % outfile
Zlib::GzipWriter.open(outfile) do |gz|
gz.mtime = File.mtime(dest)
gz.orig_name = dest.to_s
gz.write data
gz.close
end
end
end
end
##
# Adds classes and modules to the index

View file

@ -9,8 +9,8 @@
<script src="<%= asset_rel_prefix %>/js/jquery.js"></script>
<script src="<%= asset_rel_prefix %>/js/darkfish.js"></script>
<link href="<%= asset_rel_prefix %>/fonts.css" rel="stylesheet">
<link href="<%= asset_rel_prefix %>/rdoc.css" rel="stylesheet">
<link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
<link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
<% if @options.template_stylesheets.flatten.any? then %>
<% @options.template_stylesheets.flatten.each do |stylesheet| %>
<link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">

View file

@ -59,6 +59,7 @@ module RDoc
"rb_eZeroDivError" => "ZeroDivError",
"rb_mComparable" => "Comparable",
"rb_mDL" => "DL",
"rb_mEnumerable" => "Enumerable",
"rb_mErrno" => "Errno",
"rb_mFConst" => "File::Constants",

View file

@ -2822,6 +2822,172 @@ class RDoc::Markdown
return _tmp
end
# HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">"
def _HtmlOpenAnchor
_save = self.pos
while true # sequence
_tmp = match_string("<")
unless _tmp
self.pos = _save
break
end
_tmp = apply(:_Spnl)
unless _tmp
self.pos = _save
break
end
_save1 = self.pos
while true # choice
_tmp = match_string("a")
break if _tmp
self.pos = _save1
_tmp = match_string("A")
break if _tmp
self.pos = _save1
break
end # end choice
unless _tmp
self.pos = _save
break
end
_tmp = apply(:_Spnl)
unless _tmp
self.pos = _save
break
end
while true
_tmp = apply(:_HtmlAttribute)
break unless _tmp
end
_tmp = true
unless _tmp
self.pos = _save
break
end
_tmp = match_string(">")
unless _tmp
self.pos = _save
end
break
end # end sequence
set_failed_rule :_HtmlOpenAnchor unless _tmp
return _tmp
end
# HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">"
def _HtmlCloseAnchor
_save = self.pos
while true # sequence
_tmp = match_string("<")
unless _tmp
self.pos = _save
break
end
_tmp = apply(:_Spnl)
unless _tmp
self.pos = _save
break
end
_tmp = match_string("/")
unless _tmp
self.pos = _save
break
end
_save1 = self.pos
while true # choice
_tmp = match_string("a")
break if _tmp
self.pos = _save1
_tmp = match_string("A")
break if _tmp
self.pos = _save1
break
end # end choice
unless _tmp
self.pos = _save
break
end
_tmp = apply(:_Spnl)
unless _tmp
self.pos = _save
break
end
_tmp = match_string(">")
unless _tmp
self.pos = _save
end
break
end # end sequence
set_failed_rule :_HtmlCloseAnchor unless _tmp
return _tmp
end
# HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor
def _HtmlAnchor
_save = self.pos
while true # sequence
_tmp = apply(:_HtmlOpenAnchor)
unless _tmp
self.pos = _save
break
end
while true
_save2 = self.pos
while true # choice
_tmp = apply(:_HtmlAnchor)
break if _tmp
self.pos = _save2
_save3 = self.pos
while true # sequence
_save4 = self.pos
_tmp = apply(:_HtmlCloseAnchor)
_tmp = _tmp ? nil : true
self.pos = _save4
unless _tmp
self.pos = _save3
break
end
_tmp = get_byte
unless _tmp
self.pos = _save3
end
break
end # end sequence
break if _tmp
self.pos = _save2
break
end # end choice
break unless _tmp
end
_tmp = true
unless _tmp
self.pos = _save
break
end
_tmp = apply(:_HtmlCloseAnchor)
unless _tmp
self.pos = _save
end
break
end # end sequence
set_failed_rule :_HtmlAnchor unless _tmp
return _tmp
end
# HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* ">"
def _HtmlBlockOpenAddress
@ -8289,11 +8455,14 @@ class RDoc::Markdown
return _tmp
end
# HtmlBlockInTags = (HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)
# HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)
def _HtmlBlockInTags
_save = self.pos
while true # choice
_tmp = apply(:_HtmlAnchor)
break if _tmp
self.pos = _save
_tmp = apply(:_HtmlBlockAddress)
break if _tmp
self.pos = _save
@ -15120,7 +15289,7 @@ class RDoc::Markdown
self.pos = _save
break
end
@result = begin;
@result = begin;
ref = [:inline, @note_order.length]
@footnotes[ref] = paragraph a
@ -15748,6 +15917,9 @@ class RDoc::Markdown
Rules[:_Enumerator] = rule_info("Enumerator", "@NonindentSpace [0-9]+ \".\" @Spacechar+")
Rules[:_OrderedList] = rule_info("OrderedList", "&Enumerator (ListTight | ListLoose):a { RDoc::Markup::List.new(:NUMBER, *a) }")
Rules[:_ListBlockLine] = rule_info("ListBlockLine", "!@BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule OptionallyIndentedLine")
Rules[:_HtmlOpenAnchor] = rule_info("HtmlOpenAnchor", "\"<\" Spnl (\"a\" | \"A\") Spnl HtmlAttribute* \">\"")
Rules[:_HtmlCloseAnchor] = rule_info("HtmlCloseAnchor", "\"<\" Spnl \"/\" (\"a\" | \"A\") Spnl \">\"")
Rules[:_HtmlAnchor] = rule_info("HtmlAnchor", "HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor")
Rules[:_HtmlBlockOpenAddress] = rule_info("HtmlBlockOpenAddress", "\"<\" Spnl (\"address\" | \"ADDRESS\") Spnl HtmlAttribute* \">\"")
Rules[:_HtmlBlockCloseAddress] = rule_info("HtmlBlockCloseAddress", "\"<\" Spnl \"/\" (\"address\" | \"ADDRESS\") Spnl \">\"")
Rules[:_HtmlBlockAddress] = rule_info("HtmlBlockAddress", "HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress")
@ -15847,7 +16019,7 @@ class RDoc::Markdown
Rules[:_HtmlBlockOpenScript] = rule_info("HtmlBlockOpenScript", "\"<\" Spnl (\"script\" | \"SCRIPT\") Spnl HtmlAttribute* \">\"")
Rules[:_HtmlBlockCloseScript] = rule_info("HtmlBlockCloseScript", "\"<\" Spnl \"/\" (\"script\" | \"SCRIPT\") Spnl \">\"")
Rules[:_HtmlBlockScript] = rule_info("HtmlBlockScript", "HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript")
Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)")
Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)")
Rules[:_HtmlBlock] = rule_info("HtmlBlock", "< (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) > @BlankLine+ { if html? then RDoc::Markup::Raw.new text end }")
Rules[:_HtmlUnclosed] = rule_info("HtmlUnclosed", "\"<\" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl \">\"")
Rules[:_HtmlUnclosedType] = rule_info("HtmlUnclosedType", "(\"HR\" | \"hr\")")

View file

@ -286,7 +286,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@res << to_html(heading.text)
unless @options.pipe then
@res << "<span><a href=\"##{label}\">&para;</a>"
@res << " <a href=\"#documentation\">&uarr;</a></span>"
@res << " <a href=\"#top\">&uarr;</a></span>"
end
@res << "</h#{level}>\n"
end
@ -379,11 +379,12 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
end
##
# Returns true if Ripper is available it can create a sexp from +text+
# Returns true if text is valid ruby syntax
def parseable? text
text =~ /\b(def|class|module|require) |=>|\{\s?\||do \|/ and
text !~ /<%|%>/
eval("BEGIN {return true}\n#{text}")
rescue SyntaxError
false
end
##

View file

@ -31,7 +31,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
def convert text
label = convert_flow @am.flow text
CGI.escape label
CGI.escape(label).gsub('%', '-').sub(/^-/, '')
end
##

View file

@ -745,11 +745,11 @@ class RDoc::Parser::C < RDoc::Parser
elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
(?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
comment = "/*\n#{$1}"
elsif @content =~ %r%.*((?>/\*.*?\*/\s+))
([\w\.\s]+\s* = \s+)?rb_define_(class|module).*?"(#{class_name})"%xm then
elsif @content =~ %r%((?>/\*.*?\*/\s+))
([\w\.\s]+\s* = \s+)?rb_define_(class|module)[\t (]*?"(#{class_name})"%xm then
comment = $1
elsif @content =~ %r%.*((?>/\*.*?\*/\s+))
([\w\.\s]+\s* = \s+)?rb_define_(class|module)_under.*?"(#{class_name.split('::').last})"%xm then
elsif @content =~ %r%((?>/\*.*?\*/\s+))
([\w\. \t]+ = \s+)?rb_define_(class|module)_under[\t\w, (]*?"(#{class_name.split('::').last})"%xm then
comment = $1
else
comment = ''

View file

@ -1,6 +1,6 @@
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.11
# This file is automatically generated by Racc 1.4.12
# from Racc grammer file "".
#
@ -677,54 +677,54 @@ Racc_debug_parser = false
# reduce 0 omitted
def _reduce_1(val, _values, result)
result = RDoc::Markup::Document.new(*val[0])
result = RDoc::Markup::Document.new(*val[0])
result
end
def _reduce_2(val, _values, result)
raise ParseError, "file empty"
raise ParseError, "file empty"
result
end
def _reduce_3(val, _values, result)
result = val[0].concat val[1]
result = val[0].concat val[1]
result
end
def _reduce_4(val, _values, result)
result = val[0]
result = val[0]
result
end
def _reduce_5(val, _values, result)
result = val
result = val
result
end
def _reduce_6(val, _values, result)
result = val
result = val
result
end
# reduce 7 omitted
def _reduce_8(val, _values, result)
result = val
result = val
result
end
def _reduce_9(val, _values, result)
result = val
result = val
result
end
def _reduce_10(val, _values, result)
result = [RDoc::Markup::BlankLine.new]
result = [RDoc::Markup::BlankLine.new]
result
end
def _reduce_11(val, _values, result)
result = val[0].parts
result = val[0].parts
result
end
@ -732,30 +732,30 @@ def _reduce_12(val, _values, result)
# val[0] is like [level, title]
title = @inline_parser.parse(val[0][1])
result = RDoc::Markup::Heading.new(val[0][0], title)
result
end
def _reduce_13(val, _values, result)
result = RDoc::Markup::Include.new val[0], @include_path
result
end
def _reduce_14(val, _values, result)
# val[0] is Array of String
result = paragraph val[0]
result
end
def _reduce_15(val, _values, result)
result << val[1].rstrip
result << val[1].rstrip
result
end
def _reduce_16(val, _values, result)
result = [val[0].rstrip]
result = [val[0].rstrip]
result
end
@ -766,7 +766,7 @@ def _reduce_17(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
@ -777,25 +777,25 @@ def _reduce_18(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
def _reduce_19(val, _values, result)
result << val[1]
result
end
def _reduce_20(val, _values, result)
result.concat val[2]
result
end
def _reduce_21(val, _values, result)
result << "\n"
result
end
@ -803,7 +803,7 @@ def _reduce_22(val, _values, result)
result = val
# inform to lexer.
@in_verbatim = true
result
end
@ -817,89 +817,89 @@ end
def _reduce_27(val, _values, result)
result = val[0]
result
end
def _reduce_28(val, _values, result)
result = val[1]
result
end
def _reduce_29(val, _values, result)
result = val[1].push(val[2])
result
end
def _reduce_30(val, _values, result)
result = val[0] << val[1]
result = val[0] << val[1]
result
end
def _reduce_31(val, _values, result)
result = [val[0]]
result = [val[0]]
result
end
def _reduce_32(val, _values, result)
result = RDoc::Markup::List.new :BULLET, *val[0]
result
end
def _reduce_33(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_34(val, _values, result)
result = val
result = val
result
end
def _reduce_35(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_36(val, _values, result)
result = RDoc::Markup::List.new :NUMBER, *val[0]
result
end
def _reduce_37(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_38(val, _values, result)
result = val
result = val
result
end
def _reduce_39(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_40(val, _values, result)
result = RDoc::Markup::List.new :NOTE, *val[0]
result
end
def _reduce_41(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_42(val, _values, result)
result = val
result = val
result
end
@ -907,77 +907,77 @@ def _reduce_43(val, _values, result)
term = @inline_parser.parse val[0].strip
result = RDoc::Markup::ListItem.new term, *val[1]
result
end
def _reduce_44(val, _values, result)
result = RDoc::Markup::List.new :LABEL, *val[0]
result
end
def _reduce_45(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_46(val, _values, result)
result = val
result = val
result
end
def _reduce_47(val, _values, result)
result = RDoc::Markup::ListItem.new "<tt>#{val[0].strip}</tt>", *val[1]
result
end
def _reduce_48(val, _values, result)
result = [val[1]].concat(val[2])
result
end
def _reduce_49(val, _values, result)
result = [val[1]]
result
end
def _reduce_50(val, _values, result)
result = val[2]
result
end
def _reduce_51(val, _values, result)
result = []
result
end
def _reduce_52(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
# reduce 53 omitted
def _reduce_54(val, _values, result)
result = val
result = val
result
end
def _reduce_55(val, _values, result)
result = val
result = val
result
end
# reduce 56 omitted
def _reduce_57(val, _values, result)
result = []
result = []
result
end
@ -991,58 +991,58 @@ end
def _reduce_62(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_63(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_64(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_65(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_66(val, _values, result)
result = [val[0]].concat(val[1])
result
end
def _reduce_67(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
def _reduce_68(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_69(val, _values, result)
result = val
result = val
result
end
# reduce 70 omitted
def _reduce_71(val, _values, result)
result = []
result = []
result
end
def _reduce_72(val, _values, result)
result = []
result = []
result
end

View file

@ -1,6 +1,6 @@
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.11
# This file is automatically generated by Racc 1.4.12
# from Racc grammer file "".
#
@ -732,12 +732,12 @@ Racc_debug_parser = false
# reduce 1 omitted
def _reduce_2(val, _values, result)
result.append val[1]
result.append val[1]
result
end
def _reduce_3(val, _values, result)
result = val[0]
result = val[0]
result
end
@ -762,28 +762,28 @@ end
def _reduce_13(val, _values, result)
content = val[1]
result = inline "<em>#{content}</em>", content
result
end
def _reduce_14(val, _values, result)
content = val[1]
result = inline "<code>#{content}</code>", content
result
end
def _reduce_15(val, _values, result)
content = val[1]
result = inline "+#{content}+", content
result
end
def _reduce_16(val, _values, result)
content = val[1]
result = inline "<tt>#{content}</tt>", content
result
end
@ -791,13 +791,13 @@ def _reduce_17(val, _values, result)
label = val[1]
@block_parser.add_label label.reference
result = "<span id=\"label-#{label}\">#{label}</span>"
result
end
def _reduce_18(val, _values, result)
result = "{#{val[1]}}[#{val[2].join}]"
result
end
@ -805,13 +805,13 @@ def _reduce_19(val, _values, result)
scheme, inline = val[1]
result = "{#{inline}}[#{scheme}#{inline.reference}]"
result
end
def _reduce_20(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -820,25 +820,25 @@ def _reduce_21(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_22(val, _values, result)
result = ['rdoc-label:', val[0].reference]
result
end
def _reduce_23(val, _values, result)
result = ['rdoc-label:', "#{val[0].reference}/"]
result
end
def _reduce_24(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -847,92 +847,92 @@ def _reduce_25(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_26(val, _values, result)
result = ['rdoc-label:', val[0]]
result
end
def _reduce_27(val, _values, result)
ref = val[0].reference
result = ['rdoc-label:', inline(ref, "#{ref}/")]
result
end
# reduce 28 omitted
def _reduce_29(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_30(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_31(val, _values, result)
result = inline val[0]
result
end
def _reduce_32(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
def _reduce_33(val, _values, result)
result = inline val[0]
result
end
def _reduce_34(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
# reduce 35 omitted
def _reduce_36(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_37(val, _values, result)
result = inline val[1]
result = inline val[1]
result
end
def _reduce_38(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_39(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_40(val, _values, result)
result = val[0]
result
end
def _reduce_41(val, _values, result)
result = inline val[0]
result
end
@ -940,25 +940,25 @@ end
def _reduce_43(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_44(val, _values, result)
result = inline val[0]
result
end
def _reduce_45(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_46(val, _values, result)
result = val[0]
result
end
@ -984,24 +984,24 @@ end
def _reduce_57(val, _values, result)
result = val[0]
result
end
def _reduce_58(val, _values, result)
result = inline val[0]
result
end
def _reduce_59(val, _values, result)
result = inline val[0]
result
end
def _reduce_60(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1009,7 +1009,7 @@ end
def _reduce_62(val, _values, result)
result << val[1]
result
end
@ -1017,7 +1017,7 @@ end
def _reduce_64(val, _values, result)
result << val[1]
result
end
@ -1048,7 +1048,7 @@ end
# reduce 77 omitted
def _reduce_78(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1099,13 +1099,13 @@ end
def _reduce_101(val, _values, result)
index = @block_parser.add_footnote val[1].rdoc
result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]"
result
end
def _reduce_102(val, _values, result)
result = inline "<tt>#{val[1]}</tt>", val[1]
result
end
@ -1122,7 +1122,7 @@ end
# reduce 108 omitted
def _reduce_109(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1130,24 +1130,24 @@ end
def _reduce_111(val, _values, result)
result = inline val[0]
result
end
# reduce 112 omitted
def _reduce_113(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_114(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_115(val, _values, result)
result = val[1]
result = val[1]
result
end
@ -1192,7 +1192,7 @@ end
# reduce 135 omitted
def _reduce_136(val, _values, result)
result << val[1]
result << val[1]
result
end

71
lib/rdoc/ri/task.rb Normal file
View file

@ -0,0 +1,71 @@
require 'rubygems'
begin
gem 'rdoc'
rescue Gem::LoadError
end unless defined?(RDoc)
require 'rdoc/task'
##
# RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
#
# It contains the following tasks:
#
# [ri]
# Build ri data
#
# [clobber_ri]
# Delete ri data files. This target is automatically added to the main
# clobber target.
#
# [reri]
# Rebuild the ri data from scratch even if they are not out of date.
#
# Simple example:
#
# require 'rdoc/ri/task'
#
# RDoc::RI::Task.new do |ri|
# ri.main = 'README.rdoc'
# ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
# end
#
# For further configuration details see RDoc::Task.
class RDoc::RI::Task < RDoc::Task
DEFAULT_NAMES = { # :nodoc:
:clobber_rdoc => :clobber_ri,
:rdoc => :ri,
:rerdoc => :reri,
}
##
# Create an ri task with the given name. See RDoc::Task for documentation on
# setting names.
def initialize name = DEFAULT_NAMES # :yield: self
super
end
def clobber_task_description # :nodoc:
"Remove RI data files"
end
##
# Sets default task values
def defaults
super
@rdoc_dir = '.rdoc'
end
def rdoc_task_description # :nodoc:
'Build RI data files'
end
def rerdoc_task_description # :nodoc:
'Rebuild RI data files'
end
end

View file

@ -10,6 +10,10 @@ class RDoc::SingleClass < RDoc::ClassModule
superclass ? super + [superclass] : super
end
def aref_prefix # :nodoc:
'sclass'
end
##
# The definition of this singleton class, <tt>class << MyClassName</tt>

View file

@ -4,6 +4,8 @@
class RDoc::Stats
include RDoc::Text
##
# Output level for the coverage report
@ -438,6 +440,8 @@ class RDoc::Stats
params = method.param_list
params = params.map { |param| param.gsub(/^\*\*?/, '') }
return 0, [] if params.empty?
document = parse method.comment

View file

@ -2,7 +2,7 @@ require 'rubygems'
begin
gem 'minitest', '~> 4.0' unless defined?(Test::Unit)
rescue NoMethodError
rescue NoMethodError, Gem::LoadError
# for ruby tests
end

View file

@ -76,8 +76,8 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
assert_file 'table_of_contents.html'
assert_file 'js/search_index.js'
assert_hard_link 'rdoc.css'
assert_hard_link 'fonts.css'
assert_hard_link 'css/rdoc.css'
assert_hard_link 'css/fonts.css'
assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
assert_hard_link 'fonts/SourceCodePro-Regular.ttf'

View file

@ -136,6 +136,61 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
assert_equal expected, index
end
def test_generate_gzipped
require 'zlib'
@g.generate
@g.generate_gzipped
assert_file 'js/searcher.js'
assert_file 'js/searcher.js.gz'
assert_file 'js/navigation.js'
assert_file 'js/navigation.js.gz'
assert_file 'js/search_index.js'
assert_file 'js/search_index.js.gz'
gzip = File.open 'js/search_index.js.gz'
json = Zlib::GzipReader.new(gzip).read
json =~ /\Avar search_data = /
assignment = $&
index = $'
refute_empty assignment
index = JSON.parse index
info = [
@klass.search_record[2..-1],
@nest_klass.search_record[2..-1],
@meth.search_record[2..-1],
@nest_meth.search_record[2..-1],
@page.search_record[2..-1],
]
expected = {
'index' => {
'searchIndex' => [
'c',
'd',
'meth()',
'meth()',
'page',
],
'longSearchIndex' => [
'c',
'c::d',
'c#meth()',
'c::d#meth()',
'',
],
'info' => info,
},
}
assert_equal expected, index
end
def test_generate_utf_8
skip "Encoding not implemented" unless Object.const_defined? :Encoding

View file

@ -38,7 +38,7 @@ class TestRDocGeneratorMarkup < RDoc::TestCase
@comment = '= Hello'
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", description
end

View file

@ -141,6 +141,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal(["cat ", @em_on, "_", @em_off, " dog"],
@am.flow("cat ___ dog"))
assert_equal(["cat and ", @em_on, "5", @em_off, " dogs"],
@am.flow("cat and _5_ dogs"))
end
def test_bold

View file

@ -9,16 +9,16 @@ class TestRDocMarkupHeading < RDoc::TestCase
end
def test_aref
assert_equal 'label-Hello+Friend%21', @h.aref
assert_equal 'label-Hello+Friend-21', @h.aref
end
def test_label
assert_equal 'label-Hello+Friend%21', @h.label
assert_equal 'label-Hello+Friend%21', @h.label(nil)
assert_equal 'label-Hello+Friend-21', @h.label
assert_equal 'label-Hello+Friend-21', @h.label(nil)
context = RDoc::NormalClass.new 'Foo'
assert_equal 'class-Foo-label-Hello+Friend%21', @h.label(context)
assert_equal 'class-Foo-label-Hello+Friend-21', @h.label(context)
end
def test_plain_html

View file

@ -24,7 +24,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def accept_heading
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
expected = "\n<h5 id=\"label-Hello\">Hello#{links}</h5>\n"
assert_equal expected, @to.res.join
@ -32,35 +32,35 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def accept_heading_1
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
end
def accept_heading_2
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h2 id=\"label-Hello\">Hello#{links}</h2>\n", @to.res.join
end
def accept_heading_3
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h3 id=\"label-Hello\">Hello#{links}</h3>\n", @to.res.join
end
def accept_heading_4
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h4 id=\"label-Hello\">Hello#{links}</h4>\n", @to.res.join
end
def accept_heading_b
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
inner = "<strong>Hello</strong>"
assert_equal "\n<h1 id=\"label-Hello\">#{inner}#{links}</h1>\n",
@ -69,7 +69,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def accept_heading_suppressed_crossref
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
end
@ -292,7 +292,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def accept_verbatim
assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\n", @to.res.join
end
def end_accepting
@ -348,7 +348,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading @RM::Heading.new(7, 'Hello')
links = '<span><a href="#label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h6 id=\"label-Hello\">Hello#{links}</h6>\n", @to.res.join
end
@ -360,7 +360,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading head(1, 'Hello')
links = '<span><a href="#class-Foo-label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"class-Foo-label-Hello\">Hello#{links}</h1>\n",
@to.res.join
@ -373,7 +373,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading @RM::Heading.new(1, 'Hello')
links = '<span><a href="#method-i-foo-label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
'<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello#{links}</h1>\n",
@to.res.join
@ -404,7 +404,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading @RM::Heading.new(1, 'Hello')
assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>\n", @to.res.join
assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#top\">&uarr;</a></span></h1>\n", @to.res.join
end
def test_accept_heading_output_decoration_with_pipe
@ -444,8 +444,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
expected = <<-EXPECTED
<pre>#{inner}
</pre>
<pre>#{inner}</pre>
EXPECTED
assert_equal expected, @to.res.join
@ -604,8 +603,9 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
<ul><li>
<p>one</p>
<pre>verb1
verb2</pre>
<pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
<span class=\"ruby-identifier\">verb2</span>
</pre>
</li><li>
<p>two</p>
</li></ul>
@ -615,16 +615,36 @@ verb2</pre>
end
def test_parseable_eh
assert @to.parseable?('def x() end'), 'def'
assert @to.parseable?('class C end'), 'class'
assert @to.parseable?('module M end'), 'module'
assert @to.parseable?('a # => blah'), '=>'
assert @to.parseable?('x { |y| ... }'), '{ |x|'
assert @to.parseable?('x do |y| ... end'), 'do |x|'
refute @to.parseable?('* 1'), '* 1'
refute @to.parseable?('# only a comment'), '# only a comment'
refute @to.parseable?('<% require "foo" %>'), 'ERB'
refute @to.parseable?('class="foo"'), 'HTML class'
valid_syntax = [
'def x() end',
'def x; end',
'class C; end',
"module M end",
'a # => blah',
'x { |y| nil }',
'x do |y| nil end',
'# only a comment',
'require "foo"',
'cls="foo"'
]
invalid_syntax = [
'def x end',
'class C end',
'class C < end',
'module M < C end',
'a=># blah',
'x { |y| ... }',
'x do |y| ... end',
'// only a comment',
'<% require "foo" %>',
'class="foo"'
]
valid_syntax.each do |t|
assert @to.parseable?(t), "valid syntax considered invalid: #{t}"
end
invalid_syntax.each do |t|
refute @to.parseable?(t), "invalid syntax considered valid: #{t}"
end
end
def test_to_html

View file

@ -309,7 +309,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
end
def accept_verbatim
assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\n", @to.res.join
assert_equal 10, @to.characters
end
@ -427,8 +427,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
expected = <<-EXPECTED
<pre>#{inner}
</pre>
<pre>#{inner}</pre>
EXPECTED
assert_equal expected, @to.res.join
@ -588,8 +587,9 @@ This routine modifies its +comment+ parameter.
expected = <<-EXPECTED
<p>Look for directives in a normal comment block:
<pre># :stopdoc:
#{inner}</pre>
<pre class=\"ruby\"><span class=\"ruby-comment\"># :stopdoc:</span>
<span class=\"ruby-comment\">#{inner}</span>
</pre>
EXPECTED
actual = @to.convert rdoc
@ -665,8 +665,9 @@ This routine modifies its +comment+ parameter.
expected = <<-EXPECTED
<p>one
<pre>verb1
verb2</pre>
<pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
<span class=\"ruby-identifier\">verb2</span>
</pre>
<p>two
EXPECTED

View file

@ -82,8 +82,8 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
assert_equal 'some_method', @to.convert('some_method')
assert_equal 'some_method', @to.convert('\\some_method')
assert_equal '%23some_method', @to.convert('#some_method')
assert_equal '%23some_method', @to.convert('\\#some_method')
assert_equal '23some_method', @to.convert('#some_method')
assert_equal '23some_method', @to.convert('\\#some_method')
end
def test_convert_em
@ -92,11 +92,11 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
end
def test_convert_em_dash # for HTML conversion
assert_equal '--', @to.convert('--')
assert_equal '-', @to.convert('--')
end
def test_convert_escape
assert_equal 'a+%3E+b', @to.convert('a > b')
assert_equal 'a+-3E+b', @to.convert('a > b')
end
def test_convert_tidylink

View file

@ -1,11 +1,19 @@
require File.expand_path '../xref_test_case', __FILE__
require 'rdoc/test_case'
class TestRDocSingleClass < XrefTestCase
class TestRDocSingleClass < RDoc::TestCase
def setup
super
@c = RDoc::SingleClass.new 'C'
end
def test_aref_prefix
assert_equal 'sclass', @c.aref_prefix
end
def test_definition
c = RDoc::SingleClass.new 'C'
assert_equal 'class << C', c.definition
assert_equal 'class << C', @c.definition
end
end

View file

@ -663,5 +663,60 @@ m(a, b) { |c, d| ... }
RDoc::Markup::ToRdoc.new
end
def test_undoc_params
method = RDoc::AnyMethod.new [], 'm'
method.params = '(a)'
method.comment = comment 'comment'
total, undoc = @s.undoc_params method
assert_equal 1, total
assert_equal %w[a], undoc
end
def test_undoc_params_block
method = RDoc::AnyMethod.new [], 'm'
method.params = '(&a)'
method.comment = comment '+a+'
total, undoc = @s.undoc_params method
assert_equal 1, total
assert_empty undoc
end
def test_undoc_params_documented
method = RDoc::AnyMethod.new [], 'm'
method.params = '(a)'
method.comment = comment '+a+'
total, undoc = @s.undoc_params method
assert_equal 1, total
assert_empty undoc
end
def test_undoc_params_keywords
method = RDoc::AnyMethod.new [], 'm'
method.params = '(**a)'
method.comment = comment '+a+'
total, undoc = @s.undoc_params method
assert_equal 1, total
assert_empty undoc
end
def test_undoc_params_splat
method = RDoc::AnyMethod.new [], 'm'
method.params = '(*a)'
method.comment = comment '+a+'
total, undoc = @s.undoc_params method
assert_equal 1, total
assert_empty undoc
end
end