summaryrefslogtreecommitdiff
path: root/lib/rdoc/parsers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/parsers')
-rw-r--r--lib/rdoc/parsers/parse_c.rb9
-rw-r--r--lib/rdoc/parsers/parse_f95.rb3
-rw-r--r--lib/rdoc/parsers/parse_rb.rb7
-rw-r--r--lib/rdoc/parsers/parse_simple.rb2
-rw-r--r--lib/rdoc/parsers/parserfactory.rb5
5 files changed, 19 insertions, 7 deletions
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index 4aca5eeb67..904aeb9417 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -127,13 +127,14 @@ module RDoc
@@known_bodies = {}
# prepare to parse a C file
- def initialize(top_level, file_name, body, options)
+ def initialize(top_level, file_name, body, options, stats)
@known_classes = KNOWN_CLASSES.dup
@body = body
@options = options
+ @stats = stats
@top_level = top_level
@classes = Hash.new
- @file_dir = File.dirname(file_name)
+ @file_dir = File.dirname(file_name)
end
# Extract the classes/modules and methods from a C file
@@ -173,8 +174,10 @@ module RDoc
if class_mod == "class"
cm = enclosure.add_class(NormalClass, class_name, parent_name)
+ @stats.num_classes += 1
else
cm = enclosure.add_module(NormalModule, class_name)
+ @stats.num_modules += 1
end
cm.record_location(enclosure.toplevel)
@@ -302,6 +305,8 @@ module RDoc
def handle_method(type, var_name, meth_name,
meth_body, param_count, source_file = nil)
+
+ @stats.num_methods += 1
class_name = @known_classes[var_name] || var_name
class_obj = find_class(var_name, class_name)
diff --git a/lib/rdoc/parsers/parse_f95.rb b/lib/rdoc/parsers/parse_f95.rb
index 3adf29d933..518e421c60 100644
--- a/lib/rdoc/parsers/parse_f95.rb
+++ b/lib/rdoc/parsers/parse_f95.rb
@@ -32,8 +32,9 @@ module RDoc
parse_files_matching(/\.(f9(0|5)|F)$/)
# prepare to parse a Fortran 95 file
- def initialize(top_level, file_name, body, options)
+ def initialize(top_level, file_name, body, options, stats)
@body = body
+ @stats = stats
@options = options
@top_level = top_level
@progress = $stderr unless options.quiet
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
index 380025ef8d..b8044c119b 100644
--- a/lib/rdoc/parsers/parse_rb.rb
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -1374,8 +1374,9 @@ module RDoc
parse_files_matching(/\.rbw?$/)
- def initialize(top_level, file_name, content, options)
+ def initialize(top_level, file_name, content, options, stats)
@options = options
+ @stats = stats
@size = 0
@token_listeners = nil
@input_file_name = file_name
@@ -1710,6 +1711,8 @@ module RDoc
def parse_class(container, single, tk, comment, &block)
progress("c")
+ @stats.num_classes += 1
+
container, name_t = get_class_or_module(container)
case name_t
@@ -1762,6 +1765,7 @@ module RDoc
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
@@ -1853,6 +1857,7 @@ module RDoc
def parse_method(container, single, tk, comment)
progress(".")
+ @stats.num_methods += 1
line_no = tk.line_no
column = tk.char_no
diff --git a/lib/rdoc/parsers/parse_simple.rb b/lib/rdoc/parsers/parse_simple.rb
index 754f650793..b01104574e 100644
--- a/lib/rdoc/parsers/parse_simple.rb
+++ b/lib/rdoc/parsers/parse_simple.rb
@@ -12,7 +12,7 @@ module RDoc
class SimpleParser
# prepare to parse a plain file
- def initialize(top_level, file_name, body, options)
+ def initialize(top_level, file_name, body, options, stats)
preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
diff --git a/lib/rdoc/parsers/parserfactory.rb b/lib/rdoc/parsers/parserfactory.rb
index dc7d629903..b19bd0ca9b 100644
--- a/lib/rdoc/parsers/parserfactory.rb
+++ b/lib/rdoc/parsers/parserfactory.rb
@@ -73,14 +73,15 @@ module RDoc
# Find the correct parser for a particular file name. Return a
# SimpleParser for ones that we don't know
- def ParserFactory.parser_for(top_level, file_name, body, options)
+ def ParserFactory.parser_for(top_level, file_name, body, options, stats)
parser_description = can_parse(file_name)
if parser_description
parser = parser_description.parser
else
parser = SimpleParser
end
- parser.new(top_level, file_name, body, options)
+
+ parser.new(top_level, file_name, body, options, stats)
end
end
end