git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aycabta 2018-10-17 06:28:20 +00:00
Родитель 2a59b579fe
Коммит 1b43644edc
38 изменённых файлов: 602 добавлений и 528 удалений

Просмотреть файл

@ -23,8 +23,8 @@ class RDoc::CrossReference
##
# Regular expressions matching text that should potentially have
# cross-reference links generated are passed to add_special. Note that
# these expressions are meant to pick up text for which cross-references
# cross-reference links generated are passed to add_regexp_handling. Note
# that these expressions are meant to pick up text for which cross-references
# have been suppressed, since the suppression characters are removed by the
# code that is triggered.

Просмотреть файл

@ -65,17 +65,16 @@
# puts h.convert(input_string)
#
# You can extend the RDoc::Markup parser to recognize new markup
# sequences, and to add special processing for text that matches a
# regular expression. Here we make WikiWords significant to the parser,
# and also make the sequences {word} and \<no>text...</no> signify
# sequences, and to add regexp handling. Here we make WikiWords significant to
# the parser, and also make the sequences {word} and \<no>text...</no> signify
# strike-through text. We then subclass the HTML output class to deal
# with these:
#
# require 'rdoc'
#
# class WikiHtml < RDoc::Markup::ToHtml
# def handle_special_WIKIWORD(special)
# "<font color=red>" + special.text + "</font>"
# def handle_regexp_WIKIWORD(target)
# "<font color=red>" + target.text + "</font>"
# end
# end
#
@ -83,7 +82,7 @@
# markup.add_word_pair("{", "}", :STRIKE)
# markup.add_html("no", :STRIKE)
#
# markup.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
# markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
#
# wh = WikiHtml.new RDoc::Options.new, markup
# wh.add_tag(:STRIKE, "<strike>", "</strike>")
@ -800,13 +799,12 @@ https://github.com/ruby/rdoc/issues
# Add to other inline sequences. For example, we could add WikiWords using
# something like:
#
# parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
# parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
#
# Each wiki word will be presented to the output formatter via the
# accept_special method.
# Each wiki word will be presented to the output formatter.
def add_special(pattern, name)
@attribute_manager.add_special(pattern, name)
def add_regexp_handling(pattern, name)
@attribute_manager.add_regexp_handling(pattern, name)
end
##
@ -832,7 +830,7 @@ https://github.com/ruby/rdoc/issues
autoload :AttrSpan, 'rdoc/markup/attr_span'
autoload :Attributes, 'rdoc/markup/attributes'
autoload :AttributeManager, 'rdoc/markup/attribute_manager'
autoload :Special, 'rdoc/markup/special'
autoload :RegexpHandling, 'rdoc/markup/regexp_handling'
# RDoc::Markup AST
autoload :BlankLine, 'rdoc/markup/blank_line'

Просмотреть файл

@ -53,10 +53,10 @@ class RDoc::Markup::AttributeManager
attr_reader :protectable
##
# And this maps _special_ sequences to a name. A special sequence is
# something like a WikiWord
# And this maps _regexp handling_ sequences to a name. A regexp handling
# sequence is something like a WikiWord
attr_reader :special
attr_reader :regexp_handlings
##
# Creates a new attribute manager that understands bold, emphasized and
@ -66,7 +66,7 @@ class RDoc::Markup::AttributeManager
@html_tags = {}
@matching_word_pairs = {}
@protectable = %w[<]
@special = []
@regexp_handlings = []
@word_pair_map = {}
@attributes = RDoc::Markup::Attributes.new
@ -166,22 +166,22 @@ class RDoc::Markup::AttributeManager
end
##
# Converts special sequences to RDoc attributes
# Converts regexp handling sequences to RDoc attributes
def convert_specials str, attrs
@special.each do |regexp, attribute|
def convert_regexp_handlings str, attrs
@regexp_handlings.each do |regexp, attribute|
str.scan(regexp) do
capture = $~.size == 1 ? 0 : 1
s, e = $~.offset capture
attrs.set_attrs s, e - s, attribute | @attributes.special
attrs.set_attrs s, e - s, attribute | @attributes.regexp_handling
end
end
end
##
# Escapes special sequences of text to prevent conversion to RDoc
# Escapes regexp handling sequences of text to prevent conversion to RDoc
def mask_protected_sequences
# protect __send__, __FILE__, etc.
@ -193,7 +193,7 @@ class RDoc::Markup::AttributeManager
end
##
# Unescapes special sequences of text
# Unescapes regexp handling sequences of text
def unmask_protected_sequences
@str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
@ -233,17 +233,17 @@ class RDoc::Markup::AttributeManager
end
##
# Adds a special handler for +pattern+ with +name+. A simple URL handler
# Adds a regexp handling for +pattern+ with +name+. A simple URL handler
# would be:
#
# @am.add_special(/((https?:)\S+\w)/, :HYPERLINK)
# @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
def add_special pattern, name
@special << [pattern, @attributes.bitmap_for(name)]
def add_regexp_handling pattern, name
@regexp_handlings << [pattern, @attributes.bitmap_for(name)]
end
##
# Processes +str+ converting attributes, HTML and specials
# Processes +str+ converting attributes, HTML and regexp handlings
def flow str
@str = str.dup
@ -252,9 +252,9 @@ class RDoc::Markup::AttributeManager
@attrs = RDoc::Markup::AttrSpan.new @str.length
convert_attrs @str, @attrs
convert_html @str, @attrs
convert_specials @str, @attrs
convert_attrs @str, @attrs
convert_html @str, @attrs
convert_regexp_handlings @str, @attrs
unmask_protected_sequences
@ -312,12 +312,12 @@ class RDoc::Markup::AttributeManager
res << change_attribute(current_attr, new_attr)
current_attr = new_attr
if (current_attr & @attributes.special) != 0 then
if (current_attr & @attributes.regexp_handling) != 0 then
i += 1 while
i < str_len and (@attrs[i] & @attributes.special) != 0
i < str_len and (@attrs[i] & @attributes.regexp_handling) != 0
res << RDoc::Markup::Special.new(current_attr,
copy_string(start_pos, i))
res << RDoc::Markup::RegexpHandling.new(current_attr,
copy_string(start_pos, i))
start_pos = i
next
end

Просмотреть файл

@ -6,21 +6,21 @@
class RDoc::Markup::Attributes
##
# The special attribute type. See RDoc::Markup#add_special
# The regexp handling attribute type. See RDoc::Markup#add_regexp_handling
attr_reader :special
attr_reader :regexp_handling
##
# Creates a new attributes set.
def initialize
@special = 1
@regexp_handling = 1
@name_to_bitmap = [
[:_SPECIAL_, @special],
[:_REGEXP_HANDLING_, @regexp_handling],
]
@next_bitmap = @special << 1
@next_bitmap = @regexp_handling << 1
end
##
@ -61,7 +61,7 @@ class RDoc::Markup::Attributes
return enum_for __method__, bitmap unless block_given?
@name_to_bitmap.each do |name, bit|
next if bit == @special
next if bit == @regexp_handling
yield name.to_s if (bitmap & bit) != 0
end

Просмотреть файл

@ -50,7 +50,7 @@ class RDoc::Markup::Formatter
@markup = markup || RDoc::Markup.new
@am = @markup.attribute_manager
@am.add_special(/<br>/, :HARD_BREAK)
@am.add_regexp_handling(/<br>/, :HARD_BREAK)
@attributes = @am.attributes
@ -78,23 +78,24 @@ class RDoc::Markup::Formatter
end
##
# Adds a special for links of the form rdoc-...:
# Adds a regexp handling for links of the form rdoc-...:
def add_special_RDOCLINK
@markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
def add_regexp_handling_RDOCLINK
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
end
##
# Adds a special for links of the form {<text>}[<url>] and <word>[<url>]
# Adds a regexp handling for links of the form {<text>}[<url>] and
# <word>[<url>]
def add_special_TIDYLINK
@markup.add_special(/(?:
\{.*?\} | # multi-word label
\b[^\s{}]+? # single-word label
)
def add_regexp_handling_TIDYLINK
@markup.add_regexp_handling(/(?:
\{.*?\} | # multi-word label
\b[^\s{}]+? # single-word label
)
\[\S+?\] # link target
/x, :TIDYLINK)
\[\S+?\] # link target
/x, :TIDYLINK)
end
##
@ -133,8 +134,8 @@ class RDoc::Markup::Formatter
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
when RDoc::Markup::Special then
res << convert_special(item)
when RDoc::Markup::RegexpHandling then
res << convert_regexp_handling(item)
else
raise "Unknown flow element: #{item.inspect}"
end
@ -144,29 +145,29 @@ class RDoc::Markup::Formatter
end
##
# Converts added specials. See RDoc::Markup#add_special
# Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
def convert_special special
return special.text if in_tt?
def convert_regexp_handling target
return target.text if in_tt?
handled = false
@attributes.each_name_of special.type do |name|
method_name = "handle_special_#{name}"
@attributes.each_name_of target.type do |name|
method_name = "handle_regexp_#{name}"
if respond_to? method_name then
special.text = send method_name, special
target.text = send method_name, target
handled = true
end
end
unless handled then
special_name = @attributes.as_string special.type
target_name = @attributes.as_string target.type
raise RDoc::Error, "Unhandled special #{special_name}: #{special}"
raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
end
special.text
target.text
end
##

Просмотреть файл

@ -23,12 +23,12 @@ RDoc::Markup::Heading =
return @to_html if @to_html
markup = RDoc::Markup.new
markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
@to_html = RDoc::Markup::ToHtml.new nil
def @to_html.handle_special_CROSSREF special
special.text.sub(/^\\/, '')
def @to_html.handle_regexp_CROSSREF target
target.text.sub(/^\\/, '')
end
@to_html

Просмотреть файл

@ -1,2 +0,0 @@
# frozen_string_literal: true
warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w

Просмотреть файл

@ -0,0 +1,41 @@
# frozen_string_literal: true
##
# Hold details of a regexp handling sequence
class RDoc::Markup::RegexpHandling
##
# Regexp handling type
attr_reader :type
##
# Regexp handling text
attr_accessor :text
##
# Creates a new regexp handling sequence of +type+ with +text+
def initialize(type, text)
@type, @text = type, text
end
##
# Regexp handlings are equal when the have the same text and type
def ==(o)
self.text == o.text && self.type == o.type
end
def inspect # :nodoc:
"#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
object_id, @type, text.dump]
end
def to_s # :nodoc:
"RegexpHandling: type=#{type} text=#{text.dump}"
end
end

Просмотреть файл

@ -1,41 +0,0 @@
# frozen_string_literal: true
##
# Hold details of a special sequence
class RDoc::Markup::Special
##
# Special type
attr_reader :type
##
# Special text
attr_accessor :text
##
# Creates a new special sequence of +type+ with +text+
def initialize(type, text)
@type, @text = type, text
end
##
# Specials are equal when the have the same text and type
def ==(o)
self.text == o.text && self.type == o.type
end
def inspect # :nodoc:
"#<RDoc::Markup::Special:0x%x @type=%p, @text=%p>" % [
object_id, @type, text.dump]
end
def to_s # :nodoc:
"Special: type=#{type} text=#{text.dump}"
end
end

Просмотреть файл

@ -41,7 +41,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
end
##
# Turns on or off special handling for +convert_string+
# Turns on or off regexp handling for +convert_string+
def annotate tag
case tag
@ -54,9 +54,9 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
end
##
# Calls convert_string on the result of convert_special
# Calls convert_string on the result of convert_regexp_handling
def convert_special special
def convert_regexp_handling target
convert_string super
end

Просмотреть файл

@ -53,18 +53,18 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@hard_break = "<br>\n"
# external links
@markup.add_special(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
:HYPERLINK)
@markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
:HYPERLINK)
add_special_RDOCLINK
add_special_TIDYLINK
add_regexp_handling_RDOCLINK
add_regexp_handling_TIDYLINK
init_tags
end
# :section: Special Handling
# :section: Regexp Handling
#
# These methods handle special markup added by RDoc::Markup#add_special.
# These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
def handle_RDOCLINK url # :nodoc:
case url
@ -91,14 +91,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
end
##
# +special+ is a <code><br></code>
# +target+ is a <code><br></code>
def handle_special_HARD_BREAK special
def handle_regexp_HARD_BREAK target
'<br>'
end
##
# +special+ is a potential link. The following schemes are handled:
# +target+ is a potential link. The following schemes are handled:
#
# <tt>mailto:</tt>::
# Inserted as-is.
@ -109,14 +109,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
# <tt>link:</tt>::
# Reference to a local file relative to the output directory.
def handle_special_HYPERLINK(special)
url = special.text
def handle_regexp_HYPERLINK(target)
url = target.text
gen_url url, url
end
##
# +special+ is an rdoc-schemed link that will be converted into a hyperlink.
# +target+ is an rdoc-schemed link that will be converted into a hyperlink.
#
# For the +rdoc-ref+ scheme the named reference will be returned without
# creating a link.
@ -124,16 +124,16 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
# For the +rdoc-label+ scheme the footnote and label prefixes are stripped
# when creating a link. All other contents will be linked verbatim.
def handle_special_RDOCLINK special
handle_RDOCLINK special.text
def handle_regexp_RDOCLINK target
handle_RDOCLINK target.text
end
##
# This +special+ is a link where the label is different from the URL
# This +target+ is a link where the label is different from the URL
# <tt>label[url]</tt> or <tt>{long label}[url]</tt>
def handle_special_TIDYLINK(special)
text = special.text
def handle_regexp_TIDYLINK(target)
text = target.text
return text unless
text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
@ -186,7 +186,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@res << "\n<p>"
text = paragraph.text @hard_break
text = text.gsub(/\r?\n/, ' ')
@res << wrap(to_html(text))
@res << to_html(text)
@res << "</p>\n"
end
@ -312,7 +312,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
##
# Generate a link to +url+ with content +text+. Handles the special cases
# for img: and link: described under handle_special_HYPERLINK
# for img: and link: described under handle_regexp_HYPERLINK
def gen_url url, text
scheme, url, id = parse_url url

Просмотреть файл

@ -40,7 +40,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
@show_hash = @options.show_hash
crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
@markup.add_special crossref_re, :CROSSREF
@markup.add_regexp_handling crossref_re, :CROSSREF
@cross_reference = RDoc::CrossReference.new @context
end
@ -68,8 +68,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
# because we look for it in module Markup first.
def handle_special_CROSSREF(special)
name = special.text
def handle_regexp_CROSSREF(target)
name = target.text
return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
@ -87,22 +87,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
# handle other schemes.
def handle_special_HYPERLINK special
return cross_reference $' if special.text =~ /\Ardoc-ref:/
def handle_regexp_HYPERLINK target
return cross_reference $' if target.text =~ /\Ardoc-ref:/
super
end
##
# +special+ is an rdoc-schemed link that will be converted into a hyperlink.
# +target+ is an rdoc-schemed link that will be converted into a hyperlink.
# For the rdoc-ref scheme the cross-reference will be looked up and the
# given name will be used.
#
# All other contents are handled by
# {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_special_RDOCLINK]
# {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
def handle_special_RDOCLINK special
url = special.text
def handle_regexp_RDOCLINK target
url = target.text
case url
when /\Ardoc-ref:/ then
@ -126,8 +126,6 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# Creates an HTML link to +name+ with the given +text+.
def link name, text
original_name = name
if name =~ /(.*[^#:])@/ then
name = $1
label = $'

Просмотреть файл

@ -44,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
@mask = 0
@paragraphs = 0
@markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
end
##
@ -71,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
text = paragraph.text @hard_break
@res << "#{para}#{wrap to_html text}\n"
@res << "#{para}#{to_html text}\n"
add_paragraph
end
@ -123,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
end
##
# Removes escaping from the cross-references in +special+
# Removes escaping from the cross-references in +target+
def handle_special_CROSSREF special
special.text.sub(/\A\\/, '')
def handle_regexp_CROSSREF target
target.text.sub(/\A\\/, '')
end
##
# +special+ is a <code><br></code>
# +target+ is a <code><br></code>
def handle_special_HARD_BREAK special
def handle_regexp_HARD_BREAK target
@characters -= 4
'<br>'
end
@ -226,8 +226,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
when String then
text = convert_string item
res << truncate(text)
when RDoc::Markup::Special then
text = convert_special item
when RDoc::Markup::RegexpHandling then
text = convert_regexp_handling item
res << truncate(text)
else
raise "Unknown flow element: #{item.inspect}"

Просмотреть файл

@ -16,8 +16,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
def initialize markup = nil
super nil, markup
@markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
@markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
@markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
add_tag :BOLD, '', ''
add_tag :TT, '', ''
@ -36,20 +36,20 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
end
##
# Converts the CROSSREF +special+ to plain text, removing the suppression
# Converts the CROSSREF +target+ to plain text, removing the suppression
# marker, if any
def handle_special_CROSSREF special
text = special.text
def handle_regexp_CROSSREF target
text = target.text
text.sub(/^\\/, '')
end
##
# Converts the TIDYLINK +special+ to just the text part
# Converts the TIDYLINK +target+ to just the text part
def handle_special_TIDYLINK special
text = special.text
def handle_regexp_TIDYLINK target
text = target.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
@ -68,7 +68,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
alias accept_rule ignore
alias accept_verbatim ignore
alias end_accepting ignore
alias handle_special_HARD_BREAK ignore
alias handle_regexp_HARD_BREAK ignore
alias start_accepting ignore
end

Просмотреть файл

@ -19,8 +19,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
@headings[5] = ['##### ', '']
@headings[6] = ['###### ', '']
add_special_RDOCLINK
add_special_TIDYLINK
add_regexp_handling_RDOCLINK
add_regexp_handling_TIDYLINK
@hard_break = " \n"
end
@ -37,7 +37,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Adds a newline to the output
def handle_special_HARD_BREAK special
def handle_regexp_HARD_BREAK target
" \n"
end
@ -166,8 +166,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Converts the RDoc markup tidylink into a Markdown.style link.
def handle_special_TIDYLINK special
text = special.text
def handle_regexp_TIDYLINK target
text = target.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
@ -184,8 +184,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Converts the rdoc-...: links into a Markdown.style links.
def handle_special_RDOCLINK special
handle_rdoc_link special.text
def handle_regexp_RDOCLINK target
handle_rdoc_link target.text
end
end

Просмотреть файл

@ -45,7 +45,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
def initialize markup = nil
super nil, markup
@markup.add_special(/\\\S/, :SUPPRESSED_CROSSREF)
@markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
@width = 78
init_tags
@ -253,10 +253,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
end
##
# Removes preceding \\ from the suppressed crossref +special+
# Removes preceding \\ from the suppressed crossref +target+
def handle_special_SUPPRESSED_CROSSREF special
text = special.text
def handle_regexp_SUPPRESSED_CROSSREF target
text = target.text
text = text.sub('\\', '') unless in_tt?
text
end
@ -264,7 +264,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
##
# Adds a newline to the output
def handle_special_HARD_BREAK special
def handle_regexp_HARD_BREAK target
"\n"
end

Просмотреть файл

@ -91,8 +91,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
when RDoc::Markup::Special then
@res << convert_special(item) if in_tt? # TODO can this happen?
when RDoc::Markup::RegexpHandling then
@res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
else
raise "Unknown flow element: #{item.inspect}"
end

Просмотреть файл

@ -50,7 +50,7 @@ class RDoc::Parser::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_ignored_nl(tok, data)
@ -61,7 +61,7 @@ class RDoc::Parser::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_op(tok, data)
@ -103,7 +103,7 @@ class RDoc::Parser::RipperStateLex
@lex_state = EXPR_BEG
end
end
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_kw(tok, data)
@ -132,54 +132,54 @@ class RDoc::Parser::RipperStateLex
@lex_state = EXPR_END
end
end
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_tstring_beg(tok, data)
@lex_state = EXPR_BEG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_tstring_end(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_CHAR(tok, data)
@lex_state = EXPR_END
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_period(tok, data)
@lex_state = EXPR_DOT
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_int(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_float(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_rational(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_imaginary(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_symbeg(tok, data)
@lex_state = EXPR_FNAME
@continue = true
@in_fname = true
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
private def on_variables(event, tok, data)
@ -198,7 +198,7 @@ class RDoc::Parser::RipperStateLex
else
@lex_state = EXPR_CMDARG
end
@callback.call(Token.new(lineno, column, event, tok, @lex_state))
data << Token.new(lineno, column, event, tok, @lex_state)
end
def on_ident(tok, data)
@ -227,32 +227,32 @@ class RDoc::Parser::RipperStateLex
def on_lparen(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_rparen(tok, data)
@lex_state = EXPR_ENDFN
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_lbrace(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_rbrace(tok, data)
@lex_state = EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_lbracket(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_rbracket(tok, data)
@lex_state = EXPR_ENDARG
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_const(tok, data)
@ -264,41 +264,43 @@ class RDoc::Parser::RipperStateLex
else
@lex_state = EXPR_CMDARG
end
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_sp(tok, data)
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_comma(tok, data)
@lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_comment(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_ignored_sp(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
end
def on_heredoc_beg(tok, data)
data << Token.new(lineno, column, __method__, tok, @lex_state)
@lex_state = EXPR_END
data
end
def on_heredoc_end(tok, data)
@callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
data << Token.new(lineno, column, __method__, tok, @lex_state)
@lex_state = EXPR_BEG
data
end
def on_default(event, tok, data)
reset
@callback.call(Token.new(lineno, column, event, tok, @lex_state))
end
def each(&block)
@callback = block
parse
data << Token.new(lineno, column, event, tok, @lex_state)
end
end unless RIPPER_HAS_LEX_STATE
@ -308,21 +310,17 @@ class RDoc::Parser::RipperStateLex
end
def on_default(event, tok, data)
@callback.call(Token.new(lineno, column, event, tok, state))
end
def each(&block)
@callback = block
parse
data << Token.new(lineno, column, event, tok, state)
end
end if RIPPER_HAS_LEX_STATE
def get_squashed_tk
if @buf.empty?
tk = @inner_lex_enumerator.next
tk = @tokens.shift
else
tk = @buf.shift
end
return nil if tk.nil?
case tk[:kind]
when :on_symbeg then
tk = get_symbol_tk(tk)
@ -472,7 +470,7 @@ class RDoc::Parser::RipperStateLex
string = ''
start_tk = nil
prev_tk = nil
until heredoc_end?(heredoc_name, indent, tk = @inner_lex_enumerator.next) do
until heredoc_end?(heredoc_name, indent, tk = @tokens.shift) do
start_tk = tk unless start_tk
if (prev_tk.nil? or "\n" == prev_tk[:text][-1]) and 0 != tk[:char_no]
string = string + (' ' * tk[:char_no])
@ -555,6 +553,10 @@ class RDoc::Parser::RipperStateLex
tk[:text] += tk_ahead[:text]
tk[:kind] = tk_ahead[:kind]
tk[:state] = tk_ahead[:state]
when :on_heredoc_beg, :on_tstring, :on_dstring # frozen/non-frozen string literal
tk[:text] += tk_ahead[:text]
tk[:kind] = tk_ahead[:kind]
tk[:state] = tk_ahead[:state]
else
@buf.unshift tk_ahead
end
@ -566,11 +568,7 @@ class RDoc::Parser::RipperStateLex
@buf = []
@heredoc_queue = []
@inner_lex = InnerStateLex.new(code)
@inner_lex_enumerator = Enumerator.new do |y|
@inner_lex.each do |tk|
y << tk
end
end
@tokens = @inner_lex.parse([])
end
def self.parse(code)

Просмотреть файл

@ -8,8 +8,6 @@
# by Keiju ISHITSUKA (Nippon Rational Inc.)
#
$TOKEN_DEBUG ||= nil
##
# Extracts code elements from a source file returning a TopLevel object
# containing the constituent file elements.
@ -267,7 +265,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
tk = get_tk
if :on_nl === tk then
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
end
end
@ -282,7 +280,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Consumes trailing whitespace from the token stream
def consume_trailing_spaces # :nodoc:
skip_tkspace false
skip_tkspace_without_nl
end
##
@ -354,7 +352,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
given_name << '::'
end
skip_tkspace false
skip_tkspace_without_nl
given_name << name_t[:text]
is_self = name_t[:kind] == :on_op && name_t[:text] == '<<'
@ -378,7 +376,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
record_location container
get_tk
skip_tkspace false
skip_tkspace_without_nl
name_t = get_tk
unless :on_const == name_t[:kind] || :on_ident == name_t[:kind]
raise RDoc::Error, "Invalid class or module definition: #{given_name}"
@ -390,7 +388,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
end
skip_tkspace false
skip_tkspace_without_nl
return [container, name_t, given_name, new_modules]
end
@ -410,7 +408,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
res = get_constant
skip_tkspace false
skip_tkspace_without_nl
get_tkread # empty out read buffer
@ -433,7 +431,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def get_constant
res = ""
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
while tk && ((:on_op == tk[:kind] && '::' == tk[:text]) || :on_const == tk[:kind]) do
@ -449,7 +447,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Get an included module that may be surrounded by parens
def get_included_module_with_optional_parens
skip_tkspace false
skip_tkspace_without_nl
get_tkread
tk = get_tk
end_token = get_end_token tk
@ -685,7 +683,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
if args.size > 0 then
name = args[0]
rw = "R"
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
if :on_comma == tk[:kind] then
@ -935,7 +933,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
line_no = tk[:line_no]
name = tk[:text]
skip_tkspace false
skip_tkspace_without_nl
return unless name =~ /^\w+$/
@ -961,7 +959,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
break if nest == 0
end
end
skip_tkspace false
skip_tkspace_without_nl
is_array_or_hash = true
end
@ -1298,7 +1296,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
add_token tk
add_token_listener self
skip_tkspace false
skip_tkspace_without_nl
comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
singleton = !!$~
@ -1487,7 +1485,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_method_name container # :nodoc:
skip_tkspace
name_t = get_tk
back_tk = skip_tkspace(false)
back_tk = skip_tkspace_without_nl
singleton = false
dot = get_tk
@ -1575,7 +1573,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_method_or_yield_parameters(method = nil,
modifiers = RDoc::METHOD_MODIFIERS)
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
end_token = get_end_token tk
return '' unless end_token
@ -1648,7 +1646,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
return if method.block_params
skip_tkspace false
skip_tkspace_without_nl
read_documentation_modifiers method, RDoc::METHOD_MODIFIERS
end
@ -1699,19 +1697,19 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Parses a rescue
def parse_rescue
skip_tkspace false
skip_tkspace_without_nl
while tk = get_tk
case tk[:kind]
when :on_nl, :on_semicolon, :on_comment then
break
when :on_comma then
skip_tkspace false
skip_tkspace_without_nl
get_tk if :on_nl == peek_tk[:kind]
end
skip_tkspace false
skip_tkspace_without_nl
end
end
@ -1784,7 +1782,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
comment += "\n" unless "\n" == comment_body.chars.to_a.last
if comment_body.size > 1 && "\n" == comment_body.chars.to_a.last then
skip_tkspace false # leading spaces
skip_tkspace_without_nl # leading spaces
end
tk = get_tk
end
@ -1968,7 +1966,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
loop do
skip_tkspace false
skip_tkspace_without_nl
tk1 = get_tk
if tk1.nil? || :on_comma != tk1[:kind] then
@ -2117,7 +2115,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# See also RDoc::Markup::PreProcess#handle_directive
def read_documentation_modifiers context, allowed
skip_tkspace(false)
skip_tkspace_without_nl
directive, value = read_directive allowed
return unless directive
@ -2195,7 +2193,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# while, until, and for have an optional do
def skip_optional_do_after_expression
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
b_nest = 0
@ -2227,7 +2225,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
tk = get_tk
end
skip_tkspace false
skip_tkspace_without_nl
get_tk if peek_tk && :on_kw == peek_tk[:kind] && 'do' == peek_tk[:text]
end
@ -2236,9 +2234,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
# skip the var [in] part of a 'for' statement
def skip_for_variable
skip_tkspace false
skip_tkspace_without_nl
get_tk
skip_tkspace false
skip_tkspace_without_nl
tk = get_tk
unget_tk(tk) unless :on_kw == tk[:kind] and 'in' == tk[:text]
end
@ -2257,7 +2255,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def skip_tkspace_comment(skip_nl = true)
loop do
skip_tkspace skip_nl
skip_nl ? skip_tkspace : skip_tkspace_without_nl
next_tk = peek_tk
return if next_tk.nil? || (:on_comment != next_tk[:kind] and :on_embdoc != next_tk[:kind])
get_tk

Просмотреть файл

@ -25,12 +25,10 @@ module RDoc::Parser::RubyTools
tk = @scanner[@scanner_point]
@scanner_point += 1
@read.push tk[:text]
puts "get_tk1 => #{tk.inspect}" if $TOKEN_DEBUG
end
else
@read.push @unget_read.shift
tk = @tokens.shift
puts "get_tk2 => #{tk.inspect}" if $TOKEN_DEBUG
end
if tk == nil || :on___end__ == tk[:kind]
@ -111,17 +109,27 @@ module RDoc::Parser::RubyTools
@scanner_point = 0
end
def tk_nl?(tk)
:on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]
##
# Skips whitespace tokens including newlines
def skip_tkspace
tokens = []
while (tk = get_tk) and (:on_sp == tk[:kind] or :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]) do
tokens.push(tk)
end
unget_tk(tk)
tokens
end
##
# Skips whitespace tokens including newlines if +skip_nl+ is true
# Skips whitespace tokens excluding newlines
def skip_tkspace(skip_nl = true)
def skip_tkspace_without_nl
tokens = []
while (tk = get_tk) and (:on_sp == tk[:kind] or (skip_nl and tk_nl?(tk))) do
while (tk = get_tk) and :on_sp == tk[:kind] do
tokens.push(tk)
end

Просмотреть файл

@ -420,52 +420,52 @@ end
racc_action_table = [
34, 35, 30, 33, 40, 34, 35, 30, 33, 40,
65, 34, 35, 30, 33, 14, 73, 14, 54, 76,
15, 88, 34, 35, 30, 33, 14, 73, 77, 33,
54, 15, 34, 35, 30, 33, 14, 73, 81, 38,
38, 15, 34, 35, 30, 33, 14, 73, 40, 36,
83, 15, 34, 35, 30, 33, 54, 47, 30, 35,
34, 15, 34, 35, 30, 33, 14, 73, 38, 67,
59, 15, 34, 35, 30, 33, 14, 9, 10, 11,
12, 15, 34, 35, 30, 33, 14, 73, 14, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, nil, 47, nil, nil,
65, 34, 35, 30, 33, 14, 73, 36, 38, 34,
15, 88, 34, 35, 30, 33, 14, 9, 10, 11,
12, 15, 34, 35, 30, 33, 14, 9, 10, 11,
12, 15, 34, 35, 30, 33, 35, 47, 30, 54,
33, 15, 34, 35, 30, 33, 54, 47, 14, 14,
59, 15, 34, 35, 30, 33, 14, 73, 67, 76,
77, 15, 34, 35, 30, 33, 14, 73, 54, 81,
38, 15, 34, 35, 30, 33, 14, 73, 38, 40,
83, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 9, 10, 11,
12, 15, 34, 35, 30, 33, 14, 73, 61, 63,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, 61, 63,
nil, 15, 14, 62, 60, 61, 63, 79, 61, 63,
62, 87, nil, 62, 34, 35, 30, 33 ]
racc_action_check = [
41, 41, 41, 41, 41, 15, 15, 15, 15, 15,
41, 86, 86, 86, 86, 86, 86, 34, 33, 49,
86, 86, 85, 85, 85, 85, 85, 85, 51, 31,
54, 85, 79, 79, 79, 79, 79, 79, 56, 57,
58, 79, 78, 78, 78, 78, 78, 78, 62, 1,
66, 78, 24, 24, 24, 24, 30, 24, 28, 25,
22, 24, 75, 75, 75, 75, 75, 75, 13, 44,
36, 75, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 46, 46, 46, 46, 46, 46, 35, nil,
nil, 46, 45, 45, 45, 45, 45, 45, nil, nil,
nil, 45, 27, 27, 27, 27, nil, 27, nil, nil,
nil, 27, 74, 74, 74, 74, 74, 74, nil, nil,
nil, 74, 68, 68, 68, 68, 68, 68, nil, nil,
nil, 68, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 47, 47, 47, 47, 47, 47, 39, 39,
nil, 47, 52, 39, 39, 82, 82, 52, 64, 64,
41, 86, 86, 86, 86, 86, 86, 1, 13, 22,
86, 86, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 24, 24, 24, 24, 25, 24, 28, 30,
31, 24, 27, 27, 27, 27, 33, 27, 34, 35,
36, 27, 45, 45, 45, 45, 45, 45, 44, 49,
51, 45, 46, 46, 46, 46, 46, 46, 54, 56,
57, 46, 47, 47, 47, 47, 47, 47, 58, 62,
66, 47, 68, 68, 68, 68, 68, 68, nil, nil,
nil, 68, 74, 74, 74, 74, 74, 74, nil, nil,
nil, 74, 75, 75, 75, 75, 75, 75, nil, nil,
nil, 75, 78, 78, 78, 78, 78, 78, nil, nil,
nil, 78, 79, 79, 79, 79, 79, 79, nil, nil,
nil, 79, 85, 85, 85, 85, 85, 85, 39, 39,
nil, 85, 52, 39, 39, 82, 82, 52, 64, 64,
82, 82, nil, 64, 20, 20, 20, 20 ]
racc_action_pointer = [
129, 49, 69, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, 61, nil, 2, nil, nil, nil, nil,
161, nil, 57, nil, 49, 55, nil, 99, 53, nil,
48, 23, nil, 10, 10, 81, 70, nil, nil, 141,
nil, -3, nil, nil, 56, 89, 79, 139, nil, 6,
nil, 15, 145, nil, 22, nil, 25, 32, 33, nil,
nil, nil, 41, nil, 151, nil, 37, nil, 119, nil,
nil, nil, nil, nil, 109, 59, nil, nil, 39, 29,
nil, nil, 148, nil, nil, 19, 8, nil, nil ]
19, 17, 29, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, 11, nil, 2, nil, nil, nil, nil,
161, nil, 16, nil, 39, 42, nil, 49, 43, nil,
41, 44, nil, 48, 51, 52, 60, nil, nil, 141,
nil, -3, nil, nil, 55, 59, 69, 79, nil, 56,
nil, 57, 145, nil, 70, nil, 66, 73, 81, nil,
nil, nil, 82, nil, 151, nil, 77, nil, 89, nil,
nil, nil, nil, nil, 99, 109, nil, nil, 119, 129,
nil, nil, 148, nil, nil, 139, 8, nil, nil ]
racc_action_default = [
-2, -73, -1, -4, -5, -6, -7, -8, -9, -10,
@ -479,26 +479,26 @@ racc_action_default = [
-60, -47, -73, -29, -52, -48, -73, -20, -50 ]
racc_goto_table = [
4, 39, 4, 68, 74, 75, 6, 5, 6, 5,
44, 42, 51, 49, 3, 56, 37, 57, 58, 80,
4, 39, 4, 68, 74, 75, 5, 6, 5, 6,
44, 42, 51, 49, 3, 56, 37, 57, 58, 1,
2, 66, 84, 41, 43, 48, 50, 64, 84, 84,
46, 45, 42, 46, 45, 55, 85, 86, 1, 84,
45, 46, 42, 45, 46, 55, 85, 86, 80, 84,
84, nil, nil, nil, nil, nil, nil, nil, 82, nil,
nil, nil, 78 ]
racc_goto_check = [
4, 10, 4, 31, 31, 31, 6, 5, 6, 5,
21, 12, 27, 21, 3, 27, 3, 9, 9, 33,
4, 10, 4, 31, 31, 31, 5, 6, 5, 6,
21, 12, 27, 21, 3, 27, 3, 9, 9, 1,
2, 11, 32, 17, 19, 23, 26, 10, 32, 32,
6, 5, 12, 6, 5, 29, 31, 31, 1, 32,
5, 6, 12, 5, 6, 29, 31, 31, 33, 32,
32, nil, nil, nil, nil, nil, nil, nil, 10, nil,
nil, nil, 4 ]
racc_goto_pointer = [
nil, 38, 20, 14, 0, 7, 6, nil, nil, -17,
nil, 19, 20, 14, 0, 6, 7, nil, nil, -17,
-14, -20, -9, nil, nil, nil, nil, 8, nil, 2,
nil, -14, nil, 0, nil, nil, -2, -18, nil, 4,
nil, -42, -46, -35 ]
nil, -42, -46, -16 ]
racc_goto_default = [
nil, nil, nil, nil, 70, 71, 72, 7, 8, 13,

Просмотреть файл

@ -244,23 +244,34 @@ end
##### State transition tables begin ###
racc_action_table = [
104, 103, 102, 100, 101, 99, 115, 116, 117, 86,
104, 103, 102, 100, 101, 99, 115, 116, 117, 29,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
164, 118, 119, 104, 103, 102, 100, 101, 99, 115,
116, 117, 175, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 85, 118, 119, 63, 64, 65, 61,
81, 62, 76, 78, 79, 84, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 77, 80, 149, 104,
103, 102, 100, 101, 99, 115, 116, 117, 29, 105,
106, 107, 108, 109, 110, 111, 112, 113, 114, 173,
84, 118, 119, 63, 64, 65, 61, 81, 62, 76,
78, 79, 85, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 77, 80, 149, 63, 64, 65, 153,
81, 62, 76, 78, 79, 86, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 77, 80, 152, 104,
103, 102, 100, 101, 99, 115, 116, 117, 87, 105,
106, 107, 108, 109, 110, 111, 112, 113, 114, 88,
118, 119, 104, 103, 102, 100, 101, 99, 115, 116,
117, 137, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 177, 118, 119, 63, 64, 65, 153, 81,
62, 76, 78, 79, 148, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 77, 80, 152, 22, 23,
24, 25, 26, 21, 18, 19, 176, 177, 13, 124,
14, 96, 15, 89, 16, 154, 17, 88, 137, 20,
22, 23, 24, 25, 26, 21, 18, 19, 87, 161,
117, 89, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 96, 118, 119, 104, 103, 102, 100, 101,
99, 115, 116, 117, 124, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 137, 118, 119, 22, 23,
24, 25, 26, 21, 18, 19, 176, 177, 13, 148,
14, 154, 15, 137, 16, 161, 17, 164, 173, 20,
22, 23, 24, 25, 26, 21, 18, 19, 175, 177,
13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
nil, 20, 22, 23, 24, 25, 26, 21, 18, 19,
nil, nil, 13, nil, 14, nil, 15, nil, 16, nil,
17, nil, nil, 20, 22, 23, 24, 25, 26, 21,
18, 19, nil, nil, 13, nil, 14, nil, 15, nil,
16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
15, nil, 16, nil, 17, nil, nil, 20, 22, 23,
24, 25, 26, 21, 18, 19, nil, nil, 13, nil,
14, nil, 15, nil, 16, nil, 17, nil, nil, 20,
22, 23, 24, 25, 26, 21, 18, 19, nil, nil,
13, nil, 14, nil, 15, nil, 16, nil, 17, 42,
nil, 20, 54, 38, 53, 55, 56, 57, nil, 13,
nil, 14, nil, 15, nil, 16, nil, 17, nil, nil,
@ -268,63 +279,63 @@ racc_action_table = [
nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
nil, nil, 20, 63, 64, 65, 61, 81, 62, 76,
78, 79, nil, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 77, 80, 145, nil, nil, 54, 133,
73, 74, 75, 77, 80, 122, nil, nil, 54, nil,
53, 55, 56, 57, nil, 13, nil, 14, nil, 15,
nil, 16, nil, 17, 145, nil, 20, 54, 133, 53,
55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
15, nil, 16, nil, 17, 145, nil, 20, 54, 133,
53, 55, 56, 57, nil, 13, nil, 14, nil, 15,
nil, 16, nil, 17, 145, nil, 20, 54, 133, 53,
55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
15, nil, 16, nil, 17, nil, nil, 20, 22, 23,
24, 25, 26, 21, 18, 19, nil, nil, 13, nil,
14, nil, 15, nil, 16, nil, 17, nil, nil, 20,
22, 23, 24, 25, 26, 21, 18, 19, nil, nil,
13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
nil, 20, 22, 23, 24, 25, 26, 21, 18, 19,
nil, nil, 13, nil, 14, nil, 15, nil, 16, 122,
17, nil, 54, 20, 53, 55, 56, 57, nil, 13,
nil, 14, nil, 15, nil, 16, nil, 17, nil, nil,
20, 135, 136, 54, 133, 53, 55, 56, 57, nil,
13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
nil, 20, 135, 136, 54, 133, 53, 55, 56, 57,
16, nil, 17, 145, nil, 20, 54, 133, 53, 55,
56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
nil, 17, 145, nil, 20, 54, 133, 53, 55, 56,
57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
17, 145, nil, 20, 54, 133, 53, 55, 56, 57,
nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
nil, nil, 20, 135, 136, 54, 133, 53, 55, 56,
57, nil, 13, nil, 14, nil, 15, nil, 16, 158,
17, nil, 54, 20, 53, 55, 56, 57, 95, nil,
nil, 54, 91, 53, 55, 56, 57, 145, nil, nil,
54, 133, 53, 55, 56, 57, 165, 135, 136, 54,
133, 53, 55, 56, 57, 145, nil, nil, 54, 133,
53, 55, 56, 57, 172, 135, 136, 54, 133, 53,
55, 56, 57, 174, 135, 136, 54, 133, 53, 55,
56, 57, 178, 135, 136, 54, 133, 53, 55, 56,
57, 135, 136, 54, 133, 53, 55, 56, 57, 135,
136, 54, 133, 53, 55, 56, 57, 135, 136, 54,
133, 53, 55, 56, 57, 22, 23, 24, 25, 26,
21 ]
57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
17, nil, nil, 20, 135, 136, 54, 133, 53, 55,
56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
nil, 17, nil, nil, 20, 135, 136, 54, 133, 53,
55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
16, nil, 17, 95, nil, 20, 54, 91, 53, 55,
56, 57, 145, nil, nil, 54, 133, 53, 55, 56,
57, 158, nil, nil, 54, nil, 53, 55, 56, 57,
165, 135, 136, 54, 133, 53, 55, 56, 57, 145,
nil, nil, 54, 133, 53, 55, 56, 57, 172, 135,
136, 54, 133, 53, 55, 56, 57, 174, 135, 136,
54, 133, 53, 55, 56, 57, 178, 135, 136, 54,
133, 53, 55, 56, 57, 135, 136, 54, 133, 53,
55, 56, 57, 135, 136, 54, 133, 53, 55, 56,
57, 135, 136, 54, 133, 53, 55, 56, 57, 22,
23, 24, 25, 26, 21 ]
racc_action_check = [
38, 38, 38, 38, 38, 38, 38, 38, 38, 32,
38, 38, 38, 38, 38, 38, 38, 38, 38, 1,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
125, 38, 38, 97, 97, 97, 97, 97, 97, 97,
97, 97, 164, 97, 97, 97, 97, 97, 97, 97,
97, 97, 97, 31, 97, 97, 59, 59, 59, 59,
59, 59, 59, 59, 59, 29, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 91,
91, 91, 91, 91, 91, 91, 91, 91, 1, 91,
91, 91, 91, 91, 91, 91, 91, 91, 91, 162,
91, 91, 155, 155, 155, 155, 155, 155, 155, 155,
155, 43, 155, 155, 155, 155, 155, 155, 155, 155,
155, 155, 172, 155, 155, 61, 61, 61, 61, 61,
61, 61, 61, 61, 58, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 16, 16,
16, 16, 16, 16, 16, 16, 165, 165, 16, 41,
16, 37, 16, 35, 16, 90, 16, 34, 94, 16,
17, 17, 17, 17, 17, 17, 17, 17, 33, 100,
29, 38, 38, 59, 59, 59, 59, 59, 59, 59,
59, 59, 31, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 61, 61, 61, 61,
61, 61, 61, 61, 61, 32, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 91,
91, 91, 91, 91, 91, 91, 91, 91, 33, 91,
91, 91, 91, 91, 91, 91, 91, 91, 91, 34,
91, 91, 97, 97, 97, 97, 97, 97, 97, 97,
97, 35, 97, 97, 97, 97, 97, 97, 97, 97,
97, 97, 37, 97, 97, 155, 155, 155, 155, 155,
155, 155, 155, 155, 41, 155, 155, 155, 155, 155,
155, 155, 155, 155, 155, 43, 155, 155, 0, 0,
0, 0, 0, 0, 0, 0, 165, 165, 0, 58,
0, 90, 0, 94, 0, 100, 0, 125, 162, 0,
2, 2, 2, 2, 2, 2, 2, 2, 164, 172,
2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
nil, 2, 13, 13, 13, 13, 13, 13, 13, 13,
nil, nil, 13, nil, 13, nil, 13, nil, 13, nil,
13, nil, nil, 13, 14, 14, 14, 14, 14, 14,
14, 14, nil, nil, 14, nil, 14, nil, 14, nil,
14, nil, 14, nil, nil, 14, 15, 15, 15, 15,
15, 15, 15, 15, nil, nil, 15, nil, 15, nil,
15, nil, 15, nil, 15, nil, nil, 15, 16, 16,
16, 16, 16, 16, 16, 16, nil, nil, 16, nil,
16, nil, 16, nil, 16, nil, 16, nil, nil, 16,
17, 17, 17, 17, 17, 17, 17, 17, nil, nil,
17, nil, 17, nil, 17, nil, 17, nil, 17, 18,
nil, 17, 18, 18, 18, 18, 18, 18, nil, 18,
nil, 18, nil, 18, nil, 18, nil, 18, nil, nil,
@ -332,64 +343,53 @@ racc_action_check = [
nil, 19, nil, 19, nil, 19, nil, 19, nil, 19,
nil, nil, 19, 20, 20, 20, 20, 20, 20, 20,
20, 20, nil, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 146, nil, nil, 146, 146,
146, 146, 146, 146, nil, 146, nil, 146, nil, 146,
nil, 146, nil, 146, 138, nil, 146, 138, 138, 138,
138, 138, 138, nil, 138, nil, 138, nil, 138, nil,
138, nil, 138, nil, nil, 138, 0, 0, 0, 0,
0, 0, 0, 0, nil, nil, 0, nil, 0, nil,
0, nil, 0, nil, 0, 45, nil, 0, 45, 45,
45, 45, 45, 45, nil, 45, nil, 45, nil, 45,
nil, 45, nil, 45, 44, nil, 45, 44, 44, 44,
20, 20, 20, 20, 20, 39, nil, nil, 39, nil,
39, 39, 39, 39, nil, 39, nil, 39, nil, 39,
nil, 39, nil, 39, 44, nil, 39, 44, 44, 44,
44, 44, 44, nil, 44, nil, 44, nil, 44, nil,
44, nil, 44, nil, nil, 44, 2, 2, 2, 2,
2, 2, 2, 2, nil, nil, 2, nil, 2, nil,
2, nil, 2, nil, 2, nil, nil, 2, 13, 13,
13, 13, 13, 13, 13, 13, nil, nil, 13, nil,
13, nil, 13, nil, 13, nil, 13, nil, nil, 13,
14, 14, 14, 14, 14, 14, 14, 14, nil, nil,
14, nil, 14, nil, 14, nil, 14, nil, 14, nil,
nil, 14, 15, 15, 15, 15, 15, 15, 15, 15,
nil, nil, 15, nil, 15, nil, 15, nil, 15, 39,
15, nil, 39, 15, 39, 39, 39, 39, nil, 39,
nil, 39, nil, 39, nil, 39, nil, 39, nil, nil,
39, 42, 42, 42, 42, 42, 42, 42, 42, nil,
44, nil, 44, 45, nil, 44, 45, 45, 45, 45,
45, 45, nil, 45, nil, 45, nil, 45, nil, 45,
nil, 45, 138, nil, 45, 138, 138, 138, 138, 138,
138, nil, 138, nil, 138, nil, 138, nil, 138, nil,
138, 146, nil, 138, 146, 146, 146, 146, 146, 146,
nil, 146, nil, 146, nil, 146, nil, 146, nil, 146,
nil, nil, 146, 42, 42, 42, 42, 42, 42, 42,
42, nil, 42, nil, 42, nil, 42, nil, 42, nil,
nil, 42, 127, 127, 127, 127, 127, 127, 127, 127,
nil, 127, nil, 127, nil, 127, nil, 127, nil, 127,
nil, nil, 127, 122, 122, 122, 122, 122, 122, 122,
122, nil, 122, nil, 122, nil, 122, nil, 122, 92,
122, nil, 92, 122, 92, 92, 92, 92, 36, nil,
nil, 36, 36, 36, 36, 36, 36, 52, nil, nil,
52, 52, 52, 52, 52, 52, 126, 126, 126, 126,
126, 126, 126, 126, 126, 142, nil, nil, 142, 142,
142, 142, 142, 142, 159, 159, 159, 159, 159, 159,
159, 159, 159, 163, 163, 163, 163, 163, 163, 163,
163, 163, 171, 171, 171, 171, 171, 171, 171, 171,
171, 95, 95, 95, 95, 95, 95, 95, 95, 158,
158, 158, 158, 158, 158, 158, 158, 168, 168, 168,
168, 168, 168, 168, 168, 27, 27, 27, 27, 27,
27 ]
42, nil, nil, 42, 122, 122, 122, 122, 122, 122,
122, 122, nil, 122, nil, 122, nil, 122, nil, 122,
nil, 122, nil, nil, 122, 127, 127, 127, 127, 127,
127, 127, 127, nil, 127, nil, 127, nil, 127, nil,
127, nil, 127, 36, nil, 127, 36, 36, 36, 36,
36, 36, 52, nil, nil, 52, 52, 52, 52, 52,
52, 92, nil, nil, 92, nil, 92, 92, 92, 92,
126, 126, 126, 126, 126, 126, 126, 126, 126, 142,
nil, nil, 142, 142, 142, 142, 142, 142, 159, 159,
159, 159, 159, 159, 159, 159, 159, 163, 163, 163,
163, 163, 163, 163, 163, 163, 171, 171, 171, 171,
171, 171, 171, 171, 171, 95, 95, 95, 95, 95,
95, 95, 95, 158, 158, 158, 158, 158, 158, 158,
158, 168, 168, 168, 168, 168, 168, 168, 168, 27,
27, 27, 27, 27, 27 ]
racc_action_pointer = [
283, 78, 343, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, 365, 387, 409, 135, 157, 176, 198,
220, nil, nil, nil, nil, nil, nil, 602, nil, 55,
nil, 29, -7, 150, 137, 131, 515, 128, -3, 426,
nil, 145, 447, 96, 321, 302, nil, nil, nil, nil,
nil, nil, 524, nil, nil, nil, nil, nil, 113, 43,
nil, 112, nil, nil, nil, nil, nil, nil, nil, nil,
135, 9, 157, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, 179, 201, 223, 245, 267, 286, 308,
330, nil, nil, nil, nil, nil, nil, 606, nil, 20,
nil, 18, 39, 60, 69, 79, 510, 89, -3, 352,
nil, 120, 449, 130, 371, 390, nil, nil, nil, nil,
nil, nil, 519, nil, nil, nil, nil, nil, 138, 20,
nil, 43, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
132, 66, 506, nil, 153, 577, nil, 20, nil, nil,
163, nil, nil, nil, nil, nil, nil, nil, nil, nil,
128, 66, 528, nil, 148, 581, nil, 89, nil, nil,
149, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, 489, nil, nil, 17, 533, 468, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, 261, nil,
nil, nil, 542, nil, nil, nil, 242, nil, nil, nil,
nil, nil, nil, nil, nil, 89, nil, nil, 585, 551,
nil, nil, 86, 560, 28, 142, nil, nil, 593, nil,
nil, 569, 107, nil, nil, nil, nil, nil, nil ]
nil, nil, 470, nil, nil, 154, 537, 491, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, 409, nil,
nil, nil, 546, nil, nil, nil, 428, nil, nil, nil,
nil, nil, nil, nil, nil, 112, nil, nil, 589, 555,
nil, nil, 155, 564, 164, 142, nil, nil, 597, nil,
nil, 573, 164, nil, nil, nil, nil, nil, nil ]
racc_action_default = [
-138, -138, -1, -3, -4, -5, -6, -7, -8, -9,
@ -412,15 +412,15 @@ racc_action_default = [
-60, -138, -34, -36, -37, -29, -30, -32, -34 ]
racc_goto_table = [
126, 44, 125, 52, 144, 144, 160, 93, 97, 43,
166, 82, 144, 41, 40, 39, 138, 146, 169, 90,
36, 52, 44, 1, 52, 129, 169, 94, 59, 83,
123, 30, 151, 92, 121, 120, 31, 32, 33, 34,
35, 170, 58, 166, 167, 147, 170, 166, 37, nil,
126, 44, 125, 43, 144, 144, 160, 93, 97, 52,
166, 82, 144, 40, 41, 39, 138, 146, 169, 30,
36, 94, 44, 1, 123, 129, 169, 52, 90, 37,
52, 167, 147, 92, 120, 121, 31, 32, 33, 34,
35, 170, 58, 166, 59, 83, 170, 166, 151, nil,
150, nil, 166, 159, 4, 166, 4, nil, nil, nil,
nil, 155, nil, 156, 160, nil, nil, 4, 4, 4,
4, 4, nil, 4, 5, nil, 5, 52, nil, nil,
163, nil, 162, 157, nil, 168, nil, 5, 5, 5,
4, 4, nil, 4, 5, nil, 5, 157, nil, nil,
163, nil, 162, 52, nil, 168, nil, 5, 5, 5,
5, 5, nil, 5, nil, nil, nil, nil, 144, nil,
nil, nil, 144, nil, nil, 129, 144, 144, nil, 6,
129, 6, nil, nil, nil, nil, 171, 7, nil, 7,
@ -430,15 +430,15 @@ racc_goto_table = [
11, 11, 11, nil, 11 ]
racc_goto_check = [
22, 24, 21, 34, 36, 36, 37, 18, 16, 23,
35, 41, 36, 20, 19, 17, 25, 25, 28, 14,
13, 34, 24, 1, 34, 24, 28, 23, 38, 39,
23, 3, 42, 17, 20, 19, 1, 1, 1, 1,
1, 33, 1, 35, 29, 32, 33, 35, 15, nil,
22, 24, 21, 23, 36, 36, 37, 18, 16, 34,
35, 41, 36, 19, 20, 17, 25, 25, 28, 3,
13, 23, 24, 1, 23, 24, 28, 34, 14, 15,
34, 29, 32, 17, 19, 20, 1, 1, 1, 1,
1, 33, 1, 35, 38, 39, 33, 35, 42, nil,
41, nil, 35, 22, 4, 35, 4, nil, nil, nil,
nil, 16, nil, 18, 37, nil, nil, 4, 4, 4,
4, 4, nil, 4, 5, nil, 5, 34, nil, nil,
22, nil, 21, 23, nil, 22, nil, 5, 5, 5,
4, 4, nil, 4, 5, nil, 5, 23, nil, nil,
22, nil, 21, 34, nil, 22, nil, 5, 5, 5,
5, 5, nil, 5, nil, nil, nil, nil, 36, nil,
nil, nil, 36, nil, nil, 24, 36, 36, nil, 6,
24, 6, nil, nil, nil, nil, 22, 7, nil, 7,
@ -448,11 +448,11 @@ racc_goto_check = [
11, 11, 11, nil, 11 ]
racc_goto_pointer = [
nil, 23, nil, 29, 54, 74, 109, 117, 127, nil,
nil, 135, nil, 2, -17, 30, -30, -3, -29, -4,
-5, -40, -42, -9, -17, -28, nil, nil, -120, -83,
nil, nil, -7, -101, -15, -116, -40, -91, 8, 2,
nil, -9, -29 ]
nil, 23, nil, 17, 54, 74, 109, 117, 127, nil,
nil, 135, nil, 2, -8, 11, -30, -3, -29, -5,
-4, -40, -42, -15, -17, -28, nil, nil, -120, -96,
nil, nil, -20, -101, -9, -116, -40, -91, 24, 18,
nil, -9, -13 ]
racc_goto_default = [
nil, nil, 2, 3, 46, 47, 48, 49, 50, 9,

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -355,7 +355,7 @@ option)
relative_path.relative_path_from @options.page_dir
end
top_level = @store.add_file filename, relative_path.to_s
top_level = @store.add_file filename, relative_name: relative_path.to_s
parser = RDoc::Parser.for top_level, filename, content, @options, @stats

Просмотреть файл

@ -148,6 +148,7 @@ class RDoc::Store
@classes_hash = {}
@modules_hash = {}
@files_hash = {}
@text_files_hash = {}
@c_enclosure_classes = {}
@c_enclosure_names = {}
@ -184,16 +185,24 @@ class RDoc::Store
# Adds the file with +name+ as an RDoc::TopLevel to the store. Returns the
# created RDoc::TopLevel.
def add_file absolute_name, relative_name = absolute_name
def add_file absolute_name, relative_name: absolute_name, parser: nil
unless top_level = @files_hash[relative_name] then
top_level = RDoc::TopLevel.new absolute_name, relative_name
top_level.parser = parser if parser
top_level.store = self
@files_hash[relative_name] = top_level
@text_files_hash[relative_name] = top_level if top_level.text?
end
top_level
end
def update_parser_of_file(absolute_name, parser)
if top_level = @files_hash[absolute_name] then
@text_files_hash[absolute_name] = top_level if top_level.text?
end
end
##
# Returns all classes discovered by RDoc
@ -428,8 +437,8 @@ class RDoc::Store
# +file_name+
def find_text_page file_name
@files_hash.each_value.find do |file|
file.text? and file.full_name == file_name
@text_files_hash.each_value.find do |file|
file.full_name == file_name
end
end
@ -537,6 +546,7 @@ class RDoc::Store
@cache[:pages].each do |page_name|
page = load_page page_name
@files_hash[page_name] = page
@text_files_hash[page_name] = page if page.text?
end
end
@ -712,8 +722,8 @@ class RDoc::Store
# Returns the RDoc::TopLevel that is a text file and has the given +name+
def page name
@files_hash.each_value.find do |file|
file.text? and file.page_name == name
@text_files_hash.each_value.find do |file|
file.page_name == name
end
end

Просмотреть файл

@ -33,7 +33,7 @@ class RDoc::TopLevel < RDoc::Context
##
# The parser class that processed this file
attr_accessor :parser
attr_reader :parser
##
# Creates a new TopLevel for the file at +absolute_name+. If documentation
@ -52,6 +52,12 @@ class RDoc::TopLevel < RDoc::Context
@classes_or_modules = []
end
def parser=(val)
@parser = val
@store.update_parser_of_file(absolute_name, val) if @store
@parser
end
##
# An RDoc::TopLevel is equal to another with the same relative_name
@ -272,7 +278,7 @@ class RDoc::TopLevel < RDoc::Context
# Is this TopLevel from a text file instead of a source code file?
def text?
@parser and @parser.ancestors.include? RDoc::Parser::Text
@parser and @parser.include? RDoc::Parser::Text
end
def to_s # :nodoc:

Просмотреть файл

@ -3,6 +3,6 @@ module RDoc
##
# RDoc version you are using
VERSION = '6.1.0.beta1'
VERSION = '6.1.0.beta2'
end

Просмотреть файл

@ -162,8 +162,7 @@ class TestRDocCrossReference < XrefTestCase
end
def test_resolve_page
page = @store.add_file 'README.txt'
page.parser = RDoc::Parser::Simple
page = @store.add_file 'README.txt', parser: RDoc::Parser::Simple
assert_ref page, 'README'
end

Просмотреть файл

@ -36,12 +36,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def crossref(text)
crossref_bitmap = @am.attributes.bitmap_for(:_SPECIAL_) |
crossref_bitmap = @am.attributes.bitmap_for(:_REGEXP_HANDLING_) |
@am.attributes.bitmap_for(:CROSSREF)
[ @am.changed_attribute_by_name([], [:CROSSREF, :_SPECIAL_]),
RDoc::Markup::Special.new(crossref_bitmap, text),
@am.changed_attribute_by_name([:CROSSREF, :_SPECIAL_], [])
[ @am.changed_attribute_by_name([], [:CROSSREF, :_REGEXP_HANDLING_]),
RDoc::Markup::RegexpHandling.new(crossref_bitmap, text),
@am.changed_attribute_by_name([:CROSSREF, :_REGEXP_HANDLING_], [])
]
end
@ -58,12 +58,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert(tags.has_key?("test"))
end
def test_add_special
@am.add_special "WikiWord", :WIKIWORD
specials = @am.special
def test_add_regexp_handling
@am.add_regexp_handling "WikiWord", :WIKIWORD
regexp_handlings = @am.regexp_handlings
assert_equal 1, specials.size
assert specials.assoc "WikiWord"
assert_equal 1, regexp_handlings.size
assert regexp_handlings.assoc "WikiWord"
end
def test_add_word_pair
@ -340,8 +340,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow(str))
end
def test_special
@am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)
def test_regexp_handling
@am.add_regexp_handling(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)
#
# The apostrophes in "cats'" and "dogs'" suppress the flagging of these

Просмотреть файл

@ -19,10 +19,10 @@ class TestRDocMarkupAttributes < RDoc::TestCase
@as.bitmap_for 'two'
@as.bitmap_for 'three'
assert_equal 'none', @as.as_string(0)
assert_equal '_SPECIAL_', @as.as_string(1)
assert_equal 'two', @as.as_string(2)
assert_equal '_SPECIAL_,two', @as.as_string(3)
assert_equal 'none', @as.as_string(0)
assert_equal '_REGEXP_HANDLING_', @as.as_string(1)
assert_equal 'two', @as.as_string(2)
assert_equal '_REGEXP_HANDLING_,two', @as.as_string(3)
end
def test_each_name_of

Просмотреть файл

@ -19,8 +19,8 @@ class TestRDocMarkupFormatter < RDoc::TestCase
convert_flow @am.flow text.dup
end
def handle_special_CAPS special
"handled #{special.text}"
def handle_regexp_CAPS target
"handled #{target.text}"
end
def start_accepting
@ -37,16 +37,16 @@ class TestRDocMarkupFormatter < RDoc::TestCase
super
@markup = @RM.new
@markup.add_special(/[A-Z]+/, :CAPS)
@markup.add_regexp_handling(/[A-Z]+/, :CAPS)
@attribute_manager = @markup.attribute_manager
@attributes = @attribute_manager.attributes
@to = ToTest.new @markup
@caps = @attributes.bitmap_for :CAPS
@special = @attributes.bitmap_for :_SPECIAL_
@tt = @attributes.bitmap_for :TT
@caps = @attributes.bitmap_for :CAPS
@regexp_handling = @attributes.bitmap_for :_REGEXP_HANDLING_
@tt = @attributes.bitmap_for :TT
end
def test_class_gen_relative_url
@ -62,19 +62,19 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'a/c.html', gen('a.html', 'a/c.html')
end
def special_names
@attribute_manager.special.map do |_, mask|
def regexp_handling_names
@attribute_manager.regexp_handlings.map do |_, mask|
@attributes.as_string mask
end
end
def test_add_special_RDOCLINK
@to.add_special_RDOCLINK
def test_add_regexp_handling_RDOCLINK
@to.add_regexp_handling_RDOCLINK
assert_includes special_names, 'RDOCLINK'
assert_includes regexp_handling_names, 'RDOCLINK'
def @to.handle_special_RDOCLINK special
"<#{special.text}>"
def @to.handle_regexp_RDOCLINK target
"<#{target.text}>"
end
document = doc(para('{foo}[rdoc-label:bar].'))
@ -84,13 +84,13 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal '{foo}[<rdoc-label:bar>].', formatted
end
def test_add_special_TIDYLINK
@to.add_special_TIDYLINK
def test_add_regexp_handling_TIDYLINK
@to.add_regexp_handling_TIDYLINK
assert_includes special_names, 'TIDYLINK'
assert_includes regexp_handling_names, 'TIDYLINK'
def @to.handle_special_TIDYLINK special
"<#{special.text}>"
def @to.handle_regexp_TIDYLINK target
"<#{target.text}>"
end
document = doc(para('foo[rdoc-label:bar].'))
@ -166,7 +166,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_nil id
end
def test_convert_tt_special
def test_convert_tt_regexp_handling
converted = @to.convert '<code>AAA</code>'
assert_equal '<code>AAA</code>', converted

Просмотреть файл

@ -395,7 +395,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_paragraph para("hello\n", "world\n")
assert_equal "\n<p>hello world</p>\n", @to.res.join
assert_equal "\n<p>hello world </p>\n", @to.res.join
end
def test_accept_heading_output_decoration
@ -727,18 +727,18 @@ EXPECTED
assert_equal '<img src="https://example.com/image.png" />', @to.gen_url('https://example.com/image.png', 'ignored')
end
def test_handle_special_HYPERLINK_link
special = RDoc::Markup::Special.new 0, 'link:README.txt'
def test_handle_regexp_HYPERLINK_link
target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt'
link = @to.handle_special_HYPERLINK special
link = @to.handle_regexp_HYPERLINK target
assert_equal '<a href="README.txt">README.txt</a>', link
end
def test_handle_special_HYPERLINK_irc
special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang'
def test_handle_regexp_HYPERLINK_irc
target = RDoc::Markup::RegexpHandling.new 0, 'irc://irc.freenode.net/#ruby-lang'
link = @to.handle_special_HYPERLINK special
link = @to.handle_regexp_HYPERLINK target
assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link
end

Просмотреть файл

@ -116,66 +116,66 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
@to.gen_url('http://example', 'HTTP example')
end
def test_handle_special_CROSSREF
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
def test_handle_regexp_CROSSREF
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", REGEXP_HANDLING('C2::C3')
end
def test_handle_special_CROSSREF_label
def test_handle_regexp_CROSSREF_label
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>",
SPECIAL('C1#m@foo')
REGEXP_HANDLING('C1#m@foo')
end
def test_handle_special_CROSSREF_show_hash_false
def test_handle_regexp_CROSSREF_show_hash_false
@to.show_hash = false
assert_equal "<a href=\"C1.html#method-i-m\">m</a>",
SPECIAL('#m')
REGEXP_HANDLING('#m')
end
def test_handle_special_HYPERLINK_rdoc
def test_handle_regexp_HYPERLINK_rdoc
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
link = @to.handle_special_HYPERLINK hyper 'C2::C3'
link = @to.handle_regexp_HYPERLINK hyper 'C2::C3'
assert_equal '<a href="C2/C3.html">C2::C3</a>', link
link = @to.handle_special_HYPERLINK hyper 'C4'
link = @to.handle_regexp_HYPERLINK hyper 'C4'
assert_equal '<a href="C4.html">C4</a>', link
link = @to.handle_special_HYPERLINK hyper 'README.txt'
link = @to.handle_regexp_HYPERLINK hyper 'README.txt'
assert_equal '<a href="README_txt.html">README.txt</a>', link
end
def test_handle_special_TIDYLINK_rdoc
def test_handle_regexp_TIDYLINK_rdoc
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
link = @to.handle_special_TIDYLINK tidy 'C2::C3'
link = @to.handle_regexp_TIDYLINK tidy 'C2::C3'
assert_equal '<a href="C2/C3.html">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'C4'
link = @to.handle_regexp_TIDYLINK tidy 'C4'
assert_equal '<a href="C4.html">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'C1#m'
link = @to.handle_regexp_TIDYLINK tidy 'C1#m'
assert_equal '<a href="C1.html#method-i-m">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'README.txt'
link = @to.handle_regexp_TIDYLINK tidy 'README.txt'
assert_equal '<a href="README_txt.html">tidy</a>', link
end
def test_handle_special_TIDYLINK_label
link = @to.handle_special_TIDYLINK tidy 'C1#m@foo'
def test_handle_regexp_TIDYLINK_label
link = @to.handle_regexp_TIDYLINK tidy 'C1#m@foo'
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">tidy</a>",
link, 'C1#m@foo'
@ -217,20 +217,20 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
"\n<p>#{text}</p>\n"
end
def SPECIAL text
@to.handle_special_CROSSREF special text
def REGEXP_HANDLING text
@to.handle_regexp_CROSSREF regexp_handling text
end
def hyper reference
RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}"
RDoc::Markup::RegexpHandling.new 0, "rdoc-ref:#{reference}"
end
def special text
RDoc::Markup::Special.new 0, text
def regexp_handling text
RDoc::Markup::RegexpHandling.new 0, text
end
def tidy reference
RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]"
RDoc::Markup::RegexpHandling.new 0, "{tidy}[rdoc-ref:#{reference}]"
end
end

Просмотреть файл

@ -458,8 +458,7 @@ So there you have it
expected = <<-EXPECTED
<p>Hello
<p>This is some text, it <strong>will</strong> be cut off after 100 characters
and an ellipsis must follow
<p>This is some text, it <strong>will</strong> be cut off after 100 characters and an ellipsis must follow
<p>So there you #{@ellipsis}
EXPECTED
@ -563,8 +562,7 @@ NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
RDOC
expected = <<-EXPECTED
<p>Extracts the class, selector and method name parts from <code>name</code>
like Foo::Bar#baz.
<p>Extracts the class, selector and method name parts from <code>name</code> like Foo::Bar#baz.
<p>NOTE: Given Foo::Bar, #{@ellipsis}
EXPECTED
@ -652,10 +650,10 @@ This routine modifies its +comment+ parameter.
assert_equal 3, @to.characters
end
def test_handle_special_HYPERLINK_link
special = RDoc::Markup::Special.new 0, 'link:README.txt'
def test_handle_regexp_HYPERLINK_link
target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt'
link = @to.handle_special_HYPERLINK special
link = @to.handle_regexp_HYPERLINK target
assert_equal 'README.txt', link
end

Просмотреть файл

@ -495,6 +495,43 @@ ruby
assert_equal 'my attr', bar.comment.text
end
def test_parse_attr_accessor_with_newline
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_accessor :foo, :bar,\n :baz,\n :qux"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 4, klass.attributes.length
foo = klass.attributes[0]
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal 'my attr', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 1, foo.line
bar = klass.attributes[1]
assert_equal 'bar', bar.name
assert_equal 'RW', bar.rw
assert_equal 'my attr', bar.comment.text
bar = klass.attributes[2]
assert_equal 'baz', bar.name
assert_equal 'RW', bar.rw
assert_equal 'my attr', bar.comment.text
bar = klass.attributes[3]
assert_equal 'qux', bar.name
assert_equal 'RW', bar.rw
assert_equal 'my attr', bar.comment.text
end
def test_parse_attr_accessor_nodoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@ -2848,6 +2885,35 @@ EXPECTED
assert_equal expected, markup_code
end
def test_parse_mutable_heredocbeg
@filename = 'file.rb'
util_parser <<RUBY
class Foo
def blah()
@str = -<<-EOM
EOM
end
end
RUBY
expected = <<EXPECTED
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>()
<span class="ruby-ivar">@str</span> = <span class="ruby-identifier">-&lt;&lt;-EOM</span>
<span class="ruby-value"></span><span class="ruby-identifier"> EOM</span>
<span class="ruby-keyword">end</span>
EXPECTED
expected = expected.rstrip
@parser.scan
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
markup_code = blah.markup_code.sub(/^.*\n/, '')
assert_equal expected, markup_code
end
def test_parse_statements_method_oneliner_with_regexp
util_parser <<RUBY
class Foo

Просмотреть файл

@ -224,8 +224,7 @@ class TestRDocServlet < RDoc::TestCase
generator = @s.generator_for store
readme = store.add_file 'README.rdoc'
readme.parser = RDoc::Parser::Simple
readme = store.add_file 'README.rdoc', parser: RDoc::Parser::Simple
@s.documentation_page store, generator, 'README_rdoc.html', @req, @res

Просмотреть файл

@ -14,8 +14,7 @@ class TestRDocStore < XrefTestCase
@top_level = @s.add_file 'file.rb'
@page = @s.add_file 'README.txt'
@page.parser = RDoc::Parser::Simple
@page = @s.add_file 'README.txt', parser: RDoc::Parser::Simple
@page.comment = RDoc::Comment.new 'This is a page', @page
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
@ -146,7 +145,7 @@ class TestRDocStore < XrefTestCase
end
def test_add_file_relative
top_level = @store.add_file 'path/file.rb', 'file.rb'
top_level = @store.add_file 'path/file.rb', relative_name: 'file.rb'
assert_kind_of RDoc::TopLevel, top_level
assert_equal @store, top_level.store
@ -310,8 +309,7 @@ class TestRDocStore < XrefTestCase
end
def test_find_text_page
page = @store.add_file 'PAGE.txt'
page.parser = RDoc::Parser::Simple
page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple
assert_nil @store.find_text_page 'no such page'
@ -601,8 +599,7 @@ class TestRDocStore < XrefTestCase
end
def test_page
page = @store.add_file 'PAGE.txt'
page.parser = RDoc::Parser::Simple
page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple
assert_nil @store.page 'no such page'

Просмотреть файл

@ -259,8 +259,7 @@ paragraph will be cut off some point after the one-hundredth character.
TEXT
expected = <<-EXPECTED
<p>This is one-hundred characters or more of text in a single paragraph. This
paragraph will be cut off
<p>This is one-hundred characters or more of text in a single paragraph. This paragraph will be cut off
EXPECTED
assert_equal expected, snippet(text)