aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/parser
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-21 18:35:14 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-21 18:35:14 +0000
commitcd9e9c6debcf893ea5fa70e42dc1875afaf0066f (patch)
tree5921615c87529d73ed017b58ee1ce57ef6861cfc /lib/rdoc/parser
parentc62db0676bbb8051dac4f462240962e044db6cd4 (diff)
downloadruby-cd9e9c6debcf893ea5fa70e42dc1875afaf0066f.tar.gz
Update to RDoc 2.1.0 r112
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/parser')
-rw-r--r--lib/rdoc/parser/c.rb32
-rw-r--r--lib/rdoc/parser/f95.rb58
-rw-r--r--lib/rdoc/parser/ruby.rb72
3 files changed, 62 insertions, 100 deletions
diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index 1db1e442c7..43bb767da9 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -95,8 +95,6 @@ class RDoc::Parser::C < RDoc::Parser
parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
- attr_writer :progress
-
@@enclosure_classes = {}
@@known_bodies = {}
@@ -115,11 +113,12 @@ class RDoc::Parser::C < RDoc::Parser
def do_aliases
@content.scan(%r{rb_define_alias\s*\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
|var_name, new_name, old_name|
- @stats.num_methods += 1
class_name = @known_classes[var_name] || var_name
class_obj = find_class(var_name, class_name)
- class_obj.add_alias RDoc::Alias.new("", old_name, new_name, "")
+ as = class_obj.add_alias RDoc::Alias.new("", old_name, new_name, "")
+
+ @stats.add_alias as
end
end
@@ -306,7 +305,7 @@ class RDoc::Parser::C < RDoc::Parser
meth_obj.comment = mangle_comment(comment) + meth_obj.comment
when %r{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m
unless find_body($1, meth_obj, body, true)
- warn "No definition for #{meth_name}" unless quiet
+ warn "No definition for #{meth_name}" unless @options.quiet
return false
end
else
@@ -318,7 +317,7 @@ class RDoc::Parser::C < RDoc::Parser
find_modifiers(comment, meth_obj)
meth_obj.comment = mangle_comment(comment)
else
- warn "No definition for #{meth_name}" unless quiet
+ warn "No definition for #{meth_name}" unless @options.quiet
return false
end
end
@@ -460,8 +459,6 @@ class RDoc::Parser::C < RDoc::Parser
end
def handle_class_module(var_name, class_mod, class_name, parent, in_module)
- progress(class_mod[0, 1])
-
parent_name = @known_classes[parent] || parent
if in_module
@@ -482,13 +479,14 @@ class RDoc::Parser::C < RDoc::Parser
enclosure = @top_level
end
- if class_mod == "class"
+ if class_mod == "class" then
cm = enclosure.add_class RDoc::NormalClass, class_name, parent_name
- @stats.num_classes += 1
+ @stats.add_class cm
else
cm = enclosure.add_module RDoc::NormalModule, class_name
- @stats.num_modules += 1
+ @stats.add_module cm
end
+
cm.record_location(enclosure.toplevel)
find_class_comment(cm.full_name, cm)
@@ -560,9 +558,6 @@ class RDoc::Parser::C < RDoc::Parser
def handle_method(type, var_name, meth_name, meth_body, param_count,
source_file = nil)
- progress(".")
-
- @stats.num_methods += 1
class_name = @known_classes[var_name]
return unless class_name
@@ -578,6 +573,8 @@ class RDoc::Parser::C < RDoc::Parser
meth_obj.singleton =
%w{singleton_method module_function}.include?(type)
+ @stats.add_method meth_obj
+
p_count = (Integer(param_count) rescue -1)
if p_count < 0
@@ -622,13 +619,6 @@ class RDoc::Parser::C < RDoc::Parser
comment
end
- def progress(char)
- unless @options.quiet
- @progress.print(char)
- @progress.flush
- end
- end
-
##
# Removes lines that are commented out that might otherwise get picked up
# when scanning for classes and methods
diff --git a/lib/rdoc/parser/f95.rb b/lib/rdoc/parser/f95.rb
index 6312bbaaff..fd372b098b 100644
--- a/lib/rdoc/parser/f95.rb
+++ b/lib/rdoc/parser/f95.rb
@@ -289,11 +289,12 @@ class RDoc::Parser::F95 < RDoc::Parser
module_name = module_program_name
module_code = module_program_code
module_trailing = module_program_trailing
- progress "m"
- @stats.num_modules += 1
+
f9x_module = @top_level.add_module NormalClass, module_name
f9x_module.record_location @top_level
+ @stats.add_module f9x_module
+
f9x_comment = COMMENTS_ARE_UPPER ?
find_comments(pre_comment.join("\n")) + "\n" + module_trailing :
module_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, ''))
@@ -318,7 +319,7 @@ class RDoc::Parser::F95 < RDoc::Parser
program_name = module_program_name
program_code = module_program_code
program_trailing = module_program_trailing
- progress "p"
+ # progress "p" # HACK what stats thingy does this correspond to?
program_comment = COMMENTS_ARE_UPPER ?
find_comments(pre_comment.join("\n")) + "\n" + program_trailing :
program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, ''))
@@ -396,7 +397,7 @@ class RDoc::Parser::F95 < RDoc::Parser
used_trailing = $3 || ""
next if used_trailing =~ /!:nodoc:/
if !container.include_includes?(used_mod_name, @options.ignore_case)
- progress "."
+ # progress "." # HACK what stats thingy does this correspond to?
container.add_include Include.new(used_mod_name, "")
end
if ! (used_list =~ /\,\s*?only\s*?:/i )
@@ -460,7 +461,7 @@ class RDoc::Parser::F95 < RDoc::Parser
used_trailing = $3 || ""
next if used_trailing =~ /!:nodoc:/
if !container.include_includes?(used_mod_name, @options.ignore_case)
- progress "."
+ # progress "." # HACK what stats thingy does this correspond to?
container.add_include Include.new(used_mod_name, "")
end
end
@@ -532,8 +533,9 @@ class RDoc::Parser::F95 < RDoc::Parser
type.comment = "<b><em> Derived Type </em></b> :: <tt></tt>\n"
type.comment << args_comment if args_comment
type.comment << type_comment if type_comment
- progress "t"
- @stats.num_methods += 1
+
+ @stats.add_method type
+
container.add_method type
set_visibility(container, typename, visibility_default, @@public_methods)
@@ -607,8 +609,9 @@ class RDoc::Parser::F95 < RDoc::Parser
self_comment = find_arguments([defitem.varname], before_contains_code)
const_or_var.comment = "<b><em>" + const_or_var_type + "</em></b> :: <tt></tt>\n"
const_or_var.comment << self_comment if self_comment
- progress const_or_var_progress
- @stats.num_methods += 1
+
+ @stats.add_method const_or_var_progress
+
container.add_method const_or_var
set_visibility(container, defitem.varname, visibility_default, @@public_methods)
@@ -737,8 +740,9 @@ class RDoc::Parser::F95 < RDoc::Parser
parse_subprogram(subroutine, subroutine_params,
subroutine_comment, subroutine_code,
before_contains_code, nil, subroutine_prefix)
- progress "s"
- @stats.num_methods += 1
+
+ @stats.add_method subroutine
+
container.add_method subroutine
subroutine_function = subroutine
@@ -774,8 +778,8 @@ class RDoc::Parser::F95 < RDoc::Parser
function.start_collecting_tokens
function.add_token Token.new(1,1).set_text(function_code_org)
- progress "f"
- @stats.num_methods += 1
+ @stats.add_method function
+
container.add_method function
subroutine_function = function
@@ -875,8 +879,8 @@ class RDoc::Parser::F95 < RDoc::Parser
true, nolink)
new_meth.singleton = old_meth.singleton
- progress "i"
- @stats.num_methods += 1
+ @stats.add_method new_meth
+
container.add_method new_meth
set_visibility(container, generic_name, visibility_default, @@public_methods)
@@ -939,8 +943,8 @@ class RDoc::Parser::F95 < RDoc::Parser
indicated_file,
indicated_method.comment)
- progress "e"
- @stats.num_methods += 1
+ @stats.add_method external_method
+
container.add_method external_method
set_visibility(container, generic_name, visibility_default, @@public_methods)
if !container.include_requires?(indicated_file, @options.ignore_case)
@@ -982,8 +986,9 @@ class RDoc::Parser::F95 < RDoc::Parser
if pub_meth["local_name"]
new_meth.name = pub_meth["local_name"]
end
- progress "e"
- @stats.num_methods += 1
+
+ @stats.add_method new_meth
+
container.add_method new_meth
end
}
@@ -1162,13 +1167,6 @@ EOF
nice_lines.shift
end
- def progress(char)
- unless @options.quiet
- @progress.print(char)
- @progress.flush
- end
- end
-
##
# Create method for internal alias
@@ -1332,8 +1330,8 @@ EOF
comment)
new_meth.visibility = alias_item["visibility"]
- progress "e"
- @stats.num_methods += 1
+ @stats.add_method new_meth
+
alias_item["file_or_module"].add_method(new_meth)
if !alias_item["file_or_module"].include_requires?(@file_name, @options.ignore_case)
@@ -1368,8 +1366,8 @@ EOF
new_meth.name = alias_item["local_name"]
end
- progress "e"
- @stats.num_methods += 1
+ @stats.add_method new_meth
+
alias_item["file_or_module"].add_method new_meth
end
}
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index 26757256ad..abbc85bde7 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -1847,8 +1847,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
nest = 0
loop do
- puts("Call param: #{tk}, #{@scanner.continue} " +
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
case tk
when TkSEMICOLON
break
@@ -1872,11 +1870,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
res
end
- def parse_class(container, single, tk, comment, &block)
- progress("c")
-
- @stats.num_classes += 1
-
+ def parse_class(container, single, tk, comment)
container, name_t = get_class_or_module(container)
case name_t
@@ -1891,22 +1885,21 @@ class RDoc::Parser::Ruby < RDoc::Parser
superclass = "<unknown>" if superclass.empty?
end
- if single == SINGLE
- cls_type = RDoc::SingleClass
- else
- cls_type = RDoc::NormalClass
- end
-
+ cls_type = single == SINGLE ? RDoc::SingleClass : RDoc::NormalClass
cls = container.add_class cls_type, name, superclass
+
+ @stats.add_class cls
+
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
- cls.record_location(@top_level)
- parse_statements(cls)
+ cls.record_location @top_level
+
+ parse_statements cls
cls.comment = comment
when TkLSHFT
case name = get_class_specification
when "self", container.name
- parse_statements(container, SINGLE, &block)
+ parse_statements(container, SINGLE)
else
other = RDoc::TopLevel.find_class_named(name)
unless other
@@ -1915,8 +1908,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
# other.comment = comment
other = RDoc::NormalClass.new "Dummy", nil
end
+
+ @stats.add_class other
+
read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
- parse_statements(other, SINGLE, &block)
+ parse_statements(other, SINGLE)
end
else
@@ -1946,9 +1942,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
loop do
- puts "Param: %p, %s %s %s" %
- [tk.text, @scanner.continue, @scanner.lex_state, nest] if $DEBUG_RDOC
-
case tk
when TkSEMICOLON
break
@@ -1982,8 +1975,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
def parse_comment(container, tk, comment)
- progress(".")
- @stats.num_methods += 1
line_no = tk.line_no
column = tk.char_no
@@ -1998,6 +1989,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth = RDoc::GhostMethod.new get_tkread, name
meth.singleton = singleton
+ @stats.add_method meth
+
meth.start_collecting_tokens
indent = TkSPACE.new 1, 1
indent.set_text " " * column
@@ -2030,8 +2023,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Parses a meta-programmed method
def parse_meta_method(container, single, tk, comment)
- progress(".")
- @stats.num_methods += 1
line_no = tk.line_no
column = tk.char_no
@@ -2063,6 +2054,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth = RDoc::MetaMethod.new get_tkread, name
meth.singleton = singleton
+ @stats.add_method meth
+
remove_token_listener self
meth.start_collecting_tokens
@@ -2105,8 +2098,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Parses a method
def parse_method(container, single, tk, comment)
- progress(".")
- @stats.num_methods += 1
line_no = tk.line_no
column = tk.char_no
@@ -2175,6 +2166,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth.singleton = (single == SINGLE)
end
+ @stats.add_method meth
+
remove_token_listener self
meth.start_collecting_tokens
@@ -2239,8 +2232,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
nest = 0
loop do
- puts "Param: %p, %s %s %s" %
- [tk.text, @scanner.continue, @scanner.lex_state, nest] if $DEBUG_RDOC
case tk
when TkSEMICOLON
break
@@ -2290,14 +2281,15 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
def parse_module(container, single, tk, comment)
- progress("m")
- @stats.num_modules += 1
container, name_t = get_class_or_module(container)
-# skip_tkspace
+
name = name_t.name
mod = container.add_module RDoc::NormalModule, name
mod.record_location @top_level
+
+ @stats.add_module mod
+
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
parse_statements(mod)
mod.comment = comment
@@ -2422,22 +2414,16 @@ class RDoc::Parser::Ruby < RDoc::Parser
when TkUNTIL, TkWHILE then
nest += 1
- puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
skip_optional_do_after_expression
# 'for' is trickier
when TkFOR then
nest += 1
- puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
skip_for_variable
skip_optional_do_after_expression
when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN then
nest += 1
- puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
when TkIDENTIFIER then
if nest == 1 and current_method.nil? then
@@ -2470,8 +2456,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
when TkEND then
nest -= 1
- puts "Found 'end' in #{container.name}, nest = #{nest}, line #{tk.line_no}" if $DEBUG_RDOC
- puts "Method = #{current_method.name}" if $DEBUG_RDOC and current_method
if nest == 0 then
read_documentation_modifiers container, RDoc::CLASS_MODIFIERS
container.ongoing_visibility = save_visibility
@@ -2641,13 +2625,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
tk
end
- def progress(char)
- unless @options.quiet
- @progress.print(char)
- @progress.flush
- end
- end
-
##
# Directives are modifier comments that can appear after class, module, or
# method names. For example:
@@ -2662,7 +2639,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
def read_directive(allowed)
tk = get_tk
- puts "directive: #{tk.text.inspect}" if $DEBUG_RDOC
result = nil
if TkCOMMENT === tk
if tk.text =~ /\s*:?(\w+):\s*(.*)/
@@ -2769,8 +2745,6 @@ The internal error was:
@scanner.instance_eval{@continue = false}
loop do
- puts("\nWhile: #{tk.text.inspect}, #{@scanner.continue} " \
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
case tk
when TkSEMICOLON
break