mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Finish documenting internal stuff. See Changelog for other details
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eee1377a60
commit
88c127c19b
20 changed files with 1453 additions and 266 deletions
11
.document
Normal file
11
.document
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# This file determines which files in the
|
||||||
|
# Ruby hierarchy will be processed by the RDoc
|
||||||
|
# tool when it is given the top-level directory
|
||||||
|
# as an argument
|
||||||
|
|
||||||
|
# Process all the C source files
|
||||||
|
*.c
|
||||||
|
|
||||||
|
# the lib/ directory (which has its own .document file)
|
||||||
|
|
||||||
|
lib
|
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
Fri Jan 2 14:54:11 2004 Dave Thomas <dave@pragprog.com>
|
||||||
|
|
||||||
|
* bin/ri: Add new --classes option, and arrange for
|
||||||
|
help messages to be paged too.
|
||||||
|
|
||||||
|
* bin/rdoc: Add statistics.
|
||||||
|
|
||||||
|
* process.c: (MG) Added Process documentation
|
||||||
|
|
||||||
|
* lib/rdoc/ri/ri_formatter.rb (RI::AttributeFormatter::wrap):
|
||||||
|
Fix problem with labels not displaying in RI labeled
|
||||||
|
lists using BS and ANSI modes.
|
||||||
|
|
||||||
Thu Jan 1 09:03:20 2004 Dave Thomas <dave@pragprog.com>
|
Thu Jan 1 09:03:20 2004 Dave Thomas <dave@pragprog.com>
|
||||||
|
|
||||||
* bin/ri (report_class_stuff): Fix problem with ambiguous nested
|
* bin/ri (report_class_stuff): Fix problem with ambiguous nested
|
||||||
|
|
2
MANIFEST
2
MANIFEST
|
@ -1,3 +1,4 @@
|
||||||
|
.document
|
||||||
COPYING
|
COPYING
|
||||||
COPYING.ja
|
COPYING.ja
|
||||||
ChangeLog
|
ChangeLog
|
||||||
|
@ -109,6 +110,7 @@ ext/Setup.emx
|
||||||
ext/Setup.nt
|
ext/Setup.nt
|
||||||
ext/Setup.x68
|
ext/Setup.x68
|
||||||
ext/extmk.rb
|
ext/extmk.rb
|
||||||
|
lib/.document
|
||||||
lib/English.rb
|
lib/English.rb
|
||||||
lib/Env.rb
|
lib/Env.rb
|
||||||
lib/README
|
lib/README
|
||||||
|
|
407
bin/ri
407
bin/ri
|
@ -20,17 +20,6 @@ require 'rdoc/ri/ri_reader'
|
||||||
require 'rdoc/ri/ri_formatter'
|
require 'rdoc/ri/ri_formatter'
|
||||||
require 'rdoc/ri/ri_options'
|
require 'rdoc/ri/ri_options'
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
def display_usage
|
|
||||||
RI::Options::OptionList.usage(short_form=true)
|
|
||||||
# File.open(__FILE__) do |f|
|
|
||||||
# f.gets
|
|
||||||
# puts $1 while (f.gets =~ /^# ?(.*)/)
|
|
||||||
# end
|
|
||||||
# exit
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -53,31 +42,43 @@ class RiDisplay
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def display_usage
|
||||||
|
setup_pager
|
||||||
|
RI::Options::OptionList.usage(short_form=true)
|
||||||
|
page_output
|
||||||
|
end
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def setup_pager
|
def setup_pager
|
||||||
require 'tempfile'
|
unless @options.use_stdout
|
||||||
|
require 'tempfile'
|
||||||
|
|
||||||
@save_stdout = STDOUT.clone
|
@save_stdout = STDOUT.clone
|
||||||
STDOUT.reopen(Tempfile.new("ri_"))
|
STDOUT.reopen(Tempfile.new("ri_"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def page_output
|
def page_output
|
||||||
path = STDOUT.path
|
unless @options.use_stdout
|
||||||
STDOUT.reopen(@save_stdout)
|
path = STDOUT.path
|
||||||
@save_stdout = nil
|
STDOUT.reopen(@save_stdout)
|
||||||
paged = false
|
@save_stdout = nil
|
||||||
for pager in [ ENV['PAGER'], "less", "more <", 'pager' ].compact.uniq
|
paged = false
|
||||||
if system("#{pager} #{path}")
|
for pager in [ ENV['PAGER'], "less", "more <", 'pager' ].compact.uniq
|
||||||
paged = true
|
if system("#{pager} #{path}")
|
||||||
break
|
paged = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if !paged
|
||||||
|
@options.use_stdout = true
|
||||||
|
puts File.read(path)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if !paged
|
|
||||||
@options.use_stdout = true
|
|
||||||
puts File.read(path)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,171 +108,209 @@ class RiDisplay
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def display_method_info(method_entry)
|
|
||||||
method = @ri_reader.get_method(method_entry)
|
|
||||||
@formatter.draw_line(method.full_name)
|
|
||||||
display_params(method)
|
|
||||||
@formatter.draw_line
|
|
||||||
display_flow(method.comment)
|
|
||||||
if method.aliases && !method.aliases.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
aka = "(also known as "
|
|
||||||
aka << method.aliases.map {|a| a.name }.join(", ")
|
|
||||||
aka << ")"
|
|
||||||
@formatter.wrap(aka)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
def display_class_info(class_entry)
|
|
||||||
klass = @ri_reader.get_class(class_entry)
|
|
||||||
@formatter.draw_line(klass.display_name + ": " + klass.full_name)
|
|
||||||
display_flow(klass.comment)
|
|
||||||
@formatter.draw_line
|
|
||||||
|
|
||||||
unless klass.includes.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
@formatter.display_heading("Includes:", 2, "")
|
|
||||||
incs = []
|
|
||||||
klass.includes.each do |inc|
|
|
||||||
inc_desc = @ri_reader.find_class_by_name(inc.name)
|
|
||||||
if inc_desc
|
|
||||||
str = inc.name + "("
|
|
||||||
str << inc_desc.instance_methods.map{|m| m.name}.join(", ")
|
|
||||||
str << ")"
|
|
||||||
incs << str
|
|
||||||
else
|
|
||||||
incs << inc.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@formatter.wrap(incs.sort.join(', '))
|
|
||||||
end
|
|
||||||
|
|
||||||
unless klass.constants.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
@formatter.display_heading("Constants:", 2, "")
|
|
||||||
len = 0
|
|
||||||
klass.constants.each { |c| len = c.name.length if c.name.length > len }
|
|
||||||
len += 2
|
|
||||||
klass.constants.each do |c|
|
|
||||||
@formatter.wrap(c.value,
|
|
||||||
@formatter.indent+((c.name+":").ljust(len)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
unless klass.class_methods.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
@formatter.display_heading("Class methods:", 2, "")
|
|
||||||
@formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', '))
|
|
||||||
end
|
|
||||||
|
|
||||||
unless klass.instance_methods.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
@formatter.display_heading("Instance methods:", 2, "")
|
|
||||||
@formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', '))
|
|
||||||
end
|
|
||||||
|
|
||||||
unless klass.attributes.empty?
|
|
||||||
@formatter.blankline
|
|
||||||
@formatter.wrap("Attributes:", "")
|
|
||||||
@formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', '))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
# If the list of matching methods contains exactly one entry, or
|
|
||||||
# if it contains an entry that exactly matches the requested method,
|
|
||||||
# then display that entry, otherwise display the list of
|
|
||||||
# matching method names
|
|
||||||
|
|
||||||
def report_method_stuff(requested_method_name, methods)
|
|
||||||
if methods.size == 1
|
|
||||||
display_method_info(methods[0])
|
|
||||||
else
|
|
||||||
entries = methods.find_all {|m| m.name == requested_method_name}
|
|
||||||
if entries.size == 1
|
|
||||||
display_method_info(entries[0])
|
|
||||||
else
|
|
||||||
puts "More than one method matched your request. You can refine"
|
|
||||||
puts "your search by asking for information on one of:\n\n"
|
|
||||||
@formatter.wrap(methods.map {|m| m.full_name} .join(", "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
def report_class_stuff(requested_class_name, namespaces)
|
|
||||||
if namespaces.size == 1
|
|
||||||
display_class_info(namespaces[0])
|
|
||||||
else
|
|
||||||
entries = namespaces.find_all {|m| m.full_name == requested_class_name}
|
|
||||||
if entries.size == 1
|
|
||||||
display_class_info(entries[0])
|
|
||||||
else
|
|
||||||
puts "More than one class or module matched your request. You can refine"
|
|
||||||
puts "your search by asking for information on one of:\n\n"
|
|
||||||
@formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
|
|
||||||
def display_info_for(arg)
|
|
||||||
desc = NameDescriptor.new(arg)
|
|
||||||
|
|
||||||
namespaces = @ri_reader.top_level_namespace
|
|
||||||
|
|
||||||
for class_name in desc.class_names
|
|
||||||
namespaces = @ri_reader.lookup_namespace_in(class_name, namespaces)
|
|
||||||
if namespaces.empty?
|
|
||||||
raise RiError.new("Nothing known about #{arg}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
setup_pager unless @options.use_stdout
|
|
||||||
|
|
||||||
begin
|
def display_method_info(method_entry)
|
||||||
if desc.method_name.nil?
|
method = @ri_reader.get_method(method_entry)
|
||||||
report_class_stuff(desc.class_names.join('::'), namespaces)
|
@formatter.draw_line(method.full_name)
|
||||||
|
display_params(method)
|
||||||
|
@formatter.draw_line
|
||||||
|
display_flow(method.comment)
|
||||||
|
if method.aliases && !method.aliases.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
aka = "(also known as "
|
||||||
|
aka << method.aliases.map {|a| a.name }.join(", ")
|
||||||
|
aka << ")"
|
||||||
|
@formatter.wrap(aka)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def display_class_info(class_entry)
|
||||||
|
klass = @ri_reader.get_class(class_entry)
|
||||||
|
superclass = klass.superclass_string
|
||||||
|
|
||||||
|
if superclass
|
||||||
|
superclass = " < " + superclass
|
||||||
else
|
else
|
||||||
methods = @ri_reader.find_methods(desc.method_name,
|
superclass = ""
|
||||||
desc.is_class_method,
|
end
|
||||||
namespaces)
|
|
||||||
|
@formatter.draw_line(klass.display_name + ": " +
|
||||||
if methods.empty?
|
klass.full_name + superclass)
|
||||||
raise RiError.new("Nothing known about #{arg}")
|
|
||||||
|
display_flow(klass.comment)
|
||||||
|
@formatter.draw_line
|
||||||
|
|
||||||
|
unless klass.includes.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.display_heading("Includes:", 2, "")
|
||||||
|
incs = []
|
||||||
|
klass.includes.each do |inc|
|
||||||
|
inc_desc = @ri_reader.find_class_by_name(inc.name)
|
||||||
|
if inc_desc
|
||||||
|
str = inc.name + "("
|
||||||
|
str << inc_desc.instance_methods.map{|m| m.name}.join(", ")
|
||||||
|
str << ")"
|
||||||
|
incs << str
|
||||||
|
else
|
||||||
|
incs << inc.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@formatter.wrap(incs.sort.join(', '))
|
||||||
|
end
|
||||||
|
|
||||||
|
unless klass.constants.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.display_heading("Constants:", 2, "")
|
||||||
|
len = 0
|
||||||
|
klass.constants.each { |c| len = c.name.length if c.name.length > len }
|
||||||
|
len += 2
|
||||||
|
klass.constants.each do |c|
|
||||||
|
@formatter.wrap(c.value,
|
||||||
|
@formatter.indent+((c.name+":").ljust(len)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless klass.class_methods.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.display_heading("Class methods:", 2, "")
|
||||||
|
@formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', '))
|
||||||
|
end
|
||||||
|
|
||||||
|
unless klass.instance_methods.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.display_heading("Instance methods:", 2, "")
|
||||||
|
@formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', '))
|
||||||
|
end
|
||||||
|
|
||||||
|
unless klass.attributes.empty?
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.wrap("Attributes:", "")
|
||||||
|
@formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', '))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# If the list of matching methods contains exactly one entry, or
|
||||||
|
# if it contains an entry that exactly matches the requested method,
|
||||||
|
# then display that entry, otherwise display the list of
|
||||||
|
# matching method names
|
||||||
|
|
||||||
|
def report_method_stuff(requested_method_name, methods)
|
||||||
|
if methods.size == 1
|
||||||
|
display_method_info(methods[0])
|
||||||
|
else
|
||||||
|
entries = methods.find_all {|m| m.name == requested_method_name}
|
||||||
|
if entries.size == 1
|
||||||
|
display_method_info(entries[0])
|
||||||
else
|
else
|
||||||
report_method_stuff(desc.method_name, methods)
|
puts "More than one method matched your request. You can refine"
|
||||||
|
puts "your search by asking for information on one of:\n\n"
|
||||||
|
@formatter.wrap(methods.map {|m| m.full_name} .join(", "))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
page_output unless @options.use_stdout
|
|
||||||
ensure
|
|
||||||
STDOUT.reopen(@save_stdout) if @save_stdout
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def report_class_stuff(requested_class_name, namespaces)
|
||||||
|
if namespaces.size == 1
|
||||||
|
display_class_info(namespaces[0])
|
||||||
|
else
|
||||||
|
entries = namespaces.find_all {|m| m.full_name == requested_class_name}
|
||||||
|
if entries.size == 1
|
||||||
|
display_class_info(entries[0])
|
||||||
|
else
|
||||||
|
puts "More than one class or module matched your request. You can refine"
|
||||||
|
puts "your search by asking for information on one of:\n\n"
|
||||||
|
@formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
|
def display_info_for(arg)
|
||||||
|
desc = NameDescriptor.new(arg)
|
||||||
|
|
||||||
end
|
namespaces = @ri_reader.top_level_namespace
|
||||||
end
|
|
||||||
|
for class_name in desc.class_names
|
||||||
|
namespaces = @ri_reader.lookup_namespace_in(class_name, namespaces)
|
||||||
|
if namespaces.empty?
|
||||||
|
raise RiError.new("Nothing known about #{arg}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setup_pager
|
||||||
|
|
||||||
|
begin
|
||||||
|
if desc.method_name.nil?
|
||||||
|
report_class_stuff(desc.class_names.join('::'), namespaces)
|
||||||
|
else
|
||||||
|
methods = @ri_reader.find_methods(desc.method_name,
|
||||||
|
desc.is_class_method,
|
||||||
|
namespaces)
|
||||||
|
|
||||||
|
if methods.empty?
|
||||||
|
raise RiError.new("Nothing known about #{arg}")
|
||||||
|
else
|
||||||
|
report_method_stuff(desc.method_name, methods)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
page_output
|
||||||
|
ensure
|
||||||
|
STDOUT.reopen(@save_stdout) if @save_stdout
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def process_args
|
||||||
|
if @options.list_classes
|
||||||
|
display_class_list
|
||||||
|
else
|
||||||
|
if ARGV.size.zero?
|
||||||
|
display_usage
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
ARGV.each do |arg|
|
||||||
|
display_info_for(arg)
|
||||||
|
end
|
||||||
|
rescue RiError => e
|
||||||
|
$stderr.puts(e.message)
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def display_class_list
|
||||||
|
classes = @ri_reader.class_names
|
||||||
|
if classes.empty?
|
||||||
|
puts "Before using ri, you need to generate documentation"
|
||||||
|
puts "using 'rdoc' with the --ri option"
|
||||||
|
else
|
||||||
|
setup_pager
|
||||||
|
@formatter.draw_line("Known classes and modules")
|
||||||
|
@formatter.blankline
|
||||||
|
@formatter.wrap(@ri_reader.class_names.sort.join(", "))
|
||||||
|
page_output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end # class RiDisplay
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
if ARGV.size.zero?
|
ri = RiDisplay.new
|
||||||
display_usage
|
ri.process_args
|
||||||
else
|
|
||||||
ri = RiDisplay.new
|
|
||||||
begin
|
|
||||||
ARGV.each do |arg|
|
|
||||||
ri.display_info_for(arg)
|
|
||||||
end
|
|
||||||
rescue RiError => e
|
|
||||||
$stderr.puts(e.message)
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
13
eval.c
13
eval.c
|
@ -4181,9 +4181,12 @@ rb_exit(status)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* exit(integer=0)
|
* exit(integer=0)
|
||||||
|
* Kernel::exit(integer=0)
|
||||||
|
* Process::exit(integer=0)
|
||||||
*
|
*
|
||||||
* Initiates the termination of the Ruby script by raising the
|
* Initiates the termination of the Ruby script by raising the
|
||||||
* <code>SystemExit</code> exception. This exception may be caught. The
|
* <code>SystemExit</code> exception. This exception may be caught. The
|
||||||
|
@ -4203,9 +4206,9 @@ rb_exit(status)
|
||||||
* rescued a SystemExit exception
|
* rescued a SystemExit exception
|
||||||
* after begin block
|
* after begin block
|
||||||
*
|
*
|
||||||
* Just prior to termination, Ruby executes any <code>at_exit</code>
|
* Just prior to termination, Ruby executes any <code>at_exit</code> functions
|
||||||
* functions and runs any object finalizers (see
|
* (see Kernel::at_exit) and runs any object finalizers (see
|
||||||
* <code>ObjectSpace</code> beginning on page 434).
|
* ObjectSpace::define_finalizer).
|
||||||
*
|
*
|
||||||
* at_exit { puts "at_exit function" }
|
* at_exit { puts "at_exit function" }
|
||||||
* ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
|
* ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
|
||||||
|
@ -4246,10 +4249,12 @@ rb_f_exit(argc, argv)
|
||||||
return Qnil; /* not reached */
|
return Qnil; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* abort
|
* abort
|
||||||
* abort(msg)
|
* Kernel::abort
|
||||||
|
* Process::abort
|
||||||
*
|
*
|
||||||
* Terminate execution immediately, effectively by calling
|
* Terminate execution immediately, effectively by calling
|
||||||
* <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
|
* <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
|
||||||
|
|
4
lib/.document
Normal file
4
lib/.document
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# We only run RDoc on the top-level files in here: we skip
|
||||||
|
# all the helper stuff in sub-directories
|
||||||
|
|
||||||
|
*.rb
|
|
@ -263,6 +263,11 @@ module RDoc
|
||||||
return self if self.name == name
|
return self if self.name == name
|
||||||
res = @modules[name] || @classes[name]
|
res = @modules[name] || @classes[name]
|
||||||
return res if res
|
return res if res
|
||||||
|
find_enclosing_module_named(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
# find a module at a higher scope
|
||||||
|
def find_enclosing_module_named(name)
|
||||||
parent && parent.find_module_named(name)
|
parent && parent.find_module_named(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -316,6 +321,7 @@ module RDoc
|
||||||
if result
|
if result
|
||||||
modules.each do |module_name|
|
modules.each do |module_name|
|
||||||
result = result.find_module_named(module_name)
|
result = result.find_module_named(module_name)
|
||||||
|
break unless result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,10 +97,10 @@ module Generators
|
||||||
|
|
||||||
def generate_class_info(cls)
|
def generate_class_info(cls)
|
||||||
if cls === RDoc::NormalModule
|
if cls === RDoc::NormalModule
|
||||||
|
cls_desc = RI::ModuleDescription.new
|
||||||
|
else
|
||||||
cls_desc = RI::ClassDescription.new
|
cls_desc = RI::ClassDescription.new
|
||||||
cls_desc.superclass = cls.superclass
|
cls_desc.superclass = cls.superclass
|
||||||
else
|
|
||||||
cls_desc = RI::ModuleDescription.new
|
|
||||||
end
|
end
|
||||||
cls_desc.name = cls.name
|
cls_desc.name = cls.name
|
||||||
cls_desc.full_name = cls.full_name
|
cls_desc.full_name = cls.full_name
|
||||||
|
|
|
@ -127,13 +127,14 @@ module RDoc
|
||||||
@@known_bodies = {}
|
@@known_bodies = {}
|
||||||
|
|
||||||
# prepare to parse a C file
|
# 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
|
@known_classes = KNOWN_CLASSES.dup
|
||||||
@body = body
|
@body = body
|
||||||
@options = options
|
@options = options
|
||||||
|
@stats = stats
|
||||||
@top_level = top_level
|
@top_level = top_level
|
||||||
@classes = Hash.new
|
@classes = Hash.new
|
||||||
@file_dir = File.dirname(file_name)
|
@file_dir = File.dirname(file_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extract the classes/modules and methods from a C file
|
# Extract the classes/modules and methods from a C file
|
||||||
|
@ -173,8 +174,10 @@ module RDoc
|
||||||
|
|
||||||
if class_mod == "class"
|
if class_mod == "class"
|
||||||
cm = enclosure.add_class(NormalClass, class_name, parent_name)
|
cm = enclosure.add_class(NormalClass, class_name, parent_name)
|
||||||
|
@stats.num_classes += 1
|
||||||
else
|
else
|
||||||
cm = enclosure.add_module(NormalModule, class_name)
|
cm = enclosure.add_module(NormalModule, class_name)
|
||||||
|
@stats.num_modules += 1
|
||||||
end
|
end
|
||||||
cm.record_location(enclosure.toplevel)
|
cm.record_location(enclosure.toplevel)
|
||||||
|
|
||||||
|
@ -302,6 +305,8 @@ module RDoc
|
||||||
|
|
||||||
def handle_method(type, var_name, meth_name,
|
def handle_method(type, var_name, meth_name,
|
||||||
meth_body, param_count, source_file = nil)
|
meth_body, param_count, source_file = nil)
|
||||||
|
|
||||||
|
@stats.num_methods += 1
|
||||||
|
|
||||||
class_name = @known_classes[var_name] || var_name
|
class_name = @known_classes[var_name] || var_name
|
||||||
class_obj = find_class(var_name, class_name)
|
class_obj = find_class(var_name, class_name)
|
||||||
|
|
|
@ -32,8 +32,9 @@ module RDoc
|
||||||
parse_files_matching(/\.(f9(0|5)|F)$/)
|
parse_files_matching(/\.(f9(0|5)|F)$/)
|
||||||
|
|
||||||
# prepare to parse a Fortran 95 file
|
# 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
|
@body = body
|
||||||
|
@stats = stats
|
||||||
@options = options
|
@options = options
|
||||||
@top_level = top_level
|
@top_level = top_level
|
||||||
@progress = $stderr unless options.quiet
|
@progress = $stderr unless options.quiet
|
||||||
|
|
|
@ -1374,8 +1374,9 @@ module RDoc
|
||||||
parse_files_matching(/\.rbw?$/)
|
parse_files_matching(/\.rbw?$/)
|
||||||
|
|
||||||
|
|
||||||
def initialize(top_level, file_name, content, options)
|
def initialize(top_level, file_name, content, options, stats)
|
||||||
@options = options
|
@options = options
|
||||||
|
@stats = stats
|
||||||
@size = 0
|
@size = 0
|
||||||
@token_listeners = nil
|
@token_listeners = nil
|
||||||
@input_file_name = file_name
|
@input_file_name = file_name
|
||||||
|
@ -1710,6 +1711,8 @@ module RDoc
|
||||||
def parse_class(container, single, tk, comment, &block)
|
def parse_class(container, single, tk, comment, &block)
|
||||||
progress("c")
|
progress("c")
|
||||||
|
|
||||||
|
@stats.num_classes += 1
|
||||||
|
|
||||||
container, name_t = get_class_or_module(container)
|
container, name_t = get_class_or_module(container)
|
||||||
|
|
||||||
case name_t
|
case name_t
|
||||||
|
@ -1762,6 +1765,7 @@ module RDoc
|
||||||
|
|
||||||
def parse_module(container, single, tk, comment)
|
def parse_module(container, single, tk, comment)
|
||||||
progress("m")
|
progress("m")
|
||||||
|
@stats.num_modules += 1
|
||||||
container, name_t = get_class_or_module(container)
|
container, name_t = get_class_or_module(container)
|
||||||
# skip_tkspace
|
# skip_tkspace
|
||||||
name = name_t.name
|
name = name_t.name
|
||||||
|
@ -1853,6 +1857,7 @@ module RDoc
|
||||||
|
|
||||||
def parse_method(container, single, tk, comment)
|
def parse_method(container, single, tk, comment)
|
||||||
progress(".")
|
progress(".")
|
||||||
|
@stats.num_methods += 1
|
||||||
line_no = tk.line_no
|
line_no = tk.line_no
|
||||||
column = tk.char_no
|
column = tk.char_no
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module RDoc
|
||||||
class SimpleParser
|
class SimpleParser
|
||||||
|
|
||||||
# prepare to parse a plain file
|
# 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)
|
preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,15 @@ module RDoc
|
||||||
# Find the correct parser for a particular file name. Return a
|
# Find the correct parser for a particular file name. Return a
|
||||||
# SimpleParser for ones that we don't know
|
# 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)
|
parser_description = can_parse(file_name)
|
||||||
if parser_description
|
if parser_description
|
||||||
parser = parser_description.parser
|
parser = parser_description.parser
|
||||||
else
|
else
|
||||||
parser = SimpleParser
|
parser = SimpleParser
|
||||||
end
|
end
|
||||||
parser.new(top_level, file_name, body, options)
|
|
||||||
|
parser.new(top_level, file_name, body, options, stats)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,27 @@ require 'ftools'
|
||||||
|
|
||||||
module RDoc
|
module RDoc
|
||||||
|
|
||||||
|
# Name of the dotfile that contains the description of files to be
|
||||||
|
# processed in the current directory
|
||||||
|
DOT_DOC_FILENAME = ".document"
|
||||||
|
|
||||||
|
# Simple stats collector
|
||||||
|
class Stats
|
||||||
|
attr_accessor :num_files, :num_classes, :num_modules, :num_methods
|
||||||
|
def initialize
|
||||||
|
@num_files = @num_classes = @num_modules = @num_methods = 0
|
||||||
|
@start = Time.now
|
||||||
|
end
|
||||||
|
def print
|
||||||
|
puts "Files: #@num_files"
|
||||||
|
puts "Classes: #@num_classes"
|
||||||
|
puts "Modules: #@num_modules"
|
||||||
|
puts "Methods: #@num_methods"
|
||||||
|
puts "Elapsed: " + sprintf("%0.3fs", Time.now - @start)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Exception thrown by any rdoc error. Only the #message part is
|
# Exception thrown by any rdoc error. Only the #message part is
|
||||||
# of use externally.
|
# of use externally.
|
||||||
|
|
||||||
|
@ -110,25 +131,40 @@ module RDoc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# The .document file contains a list of file and directory name
|
||||||
|
# patterns, representing candidates for documentation. It may
|
||||||
|
# also contain comments (starting with '#')
|
||||||
|
def parse_dot_doc_file(in_dir, filename, options)
|
||||||
|
# read and strip comments
|
||||||
|
patterns = File.read(filename).gsub(/#.*/, '')
|
||||||
|
|
||||||
|
result = []
|
||||||
|
|
||||||
|
patterns.split.each do |patt|
|
||||||
|
candidates = Dir.glob(File.join(in_dir, patt))
|
||||||
|
result.concat(normalized_file_list(options, candidates))
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Given a list of files and directories, create a list
|
# Given a list of files and directories, create a list
|
||||||
# of all the Ruby files they contain.
|
# of all the Ruby files they contain.
|
||||||
|
|
||||||
def normalized_file_list(options, *relative_files)
|
def normalized_file_list(options, relative_files)
|
||||||
file_list = []
|
file_list = []
|
||||||
|
|
||||||
relative_files.each do |rel_file_name|
|
relative_files.each do |rel_file_name|
|
||||||
|
|
||||||
case type = File.stat(rel_file_name).ftype
|
case type = File.stat(rel_file_name).ftype
|
||||||
when "file"
|
when "file"
|
||||||
file_list << rel_file_name
|
file_list << rel_file_name
|
||||||
when "directory"
|
when "directory"
|
||||||
next if options.exclude && options.exclude =~ rel_file_name
|
next if options.exclude && options.exclude =~ rel_file_name
|
||||||
Find.find(rel_file_name) do |fn|
|
dot_doc = File.join(rel_file_name, DOT_DOC_FILENAME)
|
||||||
next if options.exclude && options.exclude =~ fn
|
if File.file?(dot_doc)
|
||||||
next unless ParserFactory.can_parse(fn)
|
file_list.concat(parse_dot_doc_file(rel_file_name, dot_doc, options))
|
||||||
next unless File.file?(fn)
|
else
|
||||||
|
file_list.concat(list_files_in_directory(rel_file_name, options))
|
||||||
file_list << fn.sub(%r{\./}, '')
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise RDocError.new("I can't deal with a #{type} #{rel_file_name}")
|
raise RDocError.new("I can't deal with a #{type} #{rel_file_name}")
|
||||||
|
@ -137,6 +173,16 @@ module RDoc
|
||||||
file_list
|
file_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return a list of the files to be processed in
|
||||||
|
# a directory. We know that this directory doesn't have
|
||||||
|
# a .document file, so we're looking for real files. However
|
||||||
|
# we may well contain subdirectories which must
|
||||||
|
# be tested for .document files
|
||||||
|
def list_files_in_directory(dir, options)
|
||||||
|
normalized_file_list(options, Dir.glob(File.join(dir, "*")))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Parse each file on the command line, recursively entering
|
# Parse each file on the command line, recursively entering
|
||||||
# directories
|
# directories
|
||||||
|
|
||||||
|
@ -147,7 +193,7 @@ module RDoc
|
||||||
files = options.files
|
files = options.files
|
||||||
files = ["."] if files.empty?
|
files = ["."] if files.empty?
|
||||||
|
|
||||||
file_list = normalized_file_list(options, *files)
|
file_list = normalized_file_list(options, files)
|
||||||
|
|
||||||
file_list.each do |fn|
|
file_list.each do |fn|
|
||||||
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
|
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
|
||||||
|
@ -155,8 +201,9 @@ module RDoc
|
||||||
content = File.open(fn, "r") {|f| f.read}
|
content = File.open(fn, "r") {|f| f.read}
|
||||||
|
|
||||||
top_level = TopLevel.new(fn)
|
top_level = TopLevel.new(fn)
|
||||||
parser = ParserFactory.parser_for(top_level, fn, content, options)
|
parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
|
||||||
file_info << parser.scan
|
file_info << parser.scan
|
||||||
|
@stats.num_files += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
file_info
|
file_info
|
||||||
|
@ -182,6 +229,8 @@ module RDoc
|
||||||
|
|
||||||
TopLevel::reset
|
TopLevel::reset
|
||||||
|
|
||||||
|
@stats = Stats.new
|
||||||
|
|
||||||
options = Options.instance
|
options = Options.instance
|
||||||
options.parse(argv, GENERATORS)
|
options.parse(argv, GENERATORS)
|
||||||
|
|
||||||
|
@ -211,7 +260,11 @@ module RDoc
|
||||||
ensure
|
ensure
|
||||||
Dir.chdir(pwd)
|
Dir.chdir(pwd)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless options.quiet
|
||||||
|
puts
|
||||||
|
@stats.print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,6 +100,12 @@ module RI
|
||||||
"Module"
|
"Module"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# the 'ClassDescription' subclass overrides this
|
||||||
|
# to format up the name of a parent
|
||||||
|
def superclass_string
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def merge(into, from)
|
def merge(into, from)
|
||||||
|
@ -116,6 +122,14 @@ module RI
|
||||||
def display_name
|
def display_name
|
||||||
"Class"
|
"Class"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def superclass_string
|
||||||
|
if @superclass && @superclass != "Object"
|
||||||
|
@superclass
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,6 @@ module RI
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
def display_flow(flow)
|
def display_flow(flow)
|
||||||
flow.each do |f|
|
flow.each do |f|
|
||||||
|
@ -207,6 +206,7 @@ module RI
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
# Handle text with attributes. We're a base class: there are
|
# Handle text with attributes. We're a base class: there are
|
||||||
# different presentation classes (one, for example, uses overstrikes
|
# different presentation classes (one, for example, uses overstrikes
|
||||||
# to handle bold and underlinig, while another using ANSI escape
|
# to handle bold and underlinig, while another using ANSI escape
|
||||||
|
@ -278,27 +278,30 @@ module RI
|
||||||
return unless txt && !txt.empty?
|
return unless txt && !txt.empty?
|
||||||
|
|
||||||
txt = add_attributes_to(txt)
|
txt = add_attributes_to(txt)
|
||||||
|
next_prefix = prefix.tr("^ ", " ")
|
||||||
|
linelen -= prefix.size
|
||||||
|
|
||||||
line = []
|
line = []
|
||||||
|
|
||||||
until txt.empty?
|
until txt.empty?
|
||||||
word = txt.next_word
|
word = txt.next_word
|
||||||
if word.size + line.size > linelen - @indent.size
|
if word.size + line.size > linelen
|
||||||
write_attribute_text(line)
|
write_attribute_text(prefix, line)
|
||||||
|
prefix = next_prefix
|
||||||
line = []
|
line = []
|
||||||
end
|
end
|
||||||
line.concat(word)
|
line.concat(word)
|
||||||
end
|
end
|
||||||
|
|
||||||
write_attribute_text(line) if line.length > 0
|
write_attribute_text(prefix, line) if line.length > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# overridden in specific formatters
|
# overridden in specific formatters
|
||||||
|
|
||||||
def write_attribute_text(line)
|
def write_attribute_text(prefix, line)
|
||||||
print @indent
|
print prefix
|
||||||
line.each do |achar|
|
line.each do |achar|
|
||||||
print achar.char
|
print achar.char
|
||||||
end
|
end
|
||||||
|
@ -340,8 +343,8 @@ module RI
|
||||||
|
|
||||||
BS = "\C-h"
|
BS = "\C-h"
|
||||||
|
|
||||||
def write_attribute_text(line)
|
def write_attribute_text(prefix, line)
|
||||||
print @indent
|
print prefix
|
||||||
line.each do |achar|
|
line.each do |achar|
|
||||||
attr = achar.attr
|
attr = achar.attr
|
||||||
if (attr & (ITALIC+CODE)) != 0
|
if (attr & (ITALIC+CODE)) != 0
|
||||||
|
@ -371,15 +374,13 @@ module RI
|
||||||
|
|
||||||
class AnsiFormatter < AttributeFormatter
|
class AnsiFormatter < AttributeFormatter
|
||||||
|
|
||||||
BS = "\C-h"
|
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
print "\033[0m"
|
print "\033[0m"
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_attribute_text(line)
|
def write_attribute_text(prefix, line)
|
||||||
print @indent
|
print prefix
|
||||||
curr_attr = 0
|
curr_attr = 0
|
||||||
line.each do |achar|
|
line.each do |achar|
|
||||||
attr = achar.attr
|
attr = achar.attr
|
||||||
|
|
|
@ -16,6 +16,9 @@ module RI
|
||||||
# can't find a pager
|
# can't find a pager
|
||||||
attr_accessor :use_stdout
|
attr_accessor :use_stdout
|
||||||
|
|
||||||
|
# should we just display a class list and exit
|
||||||
|
attr_reader :list_classes
|
||||||
|
|
||||||
# The width of the output line
|
# The width of the output line
|
||||||
attr_reader :width
|
attr_reader :width
|
||||||
|
|
||||||
|
@ -28,6 +31,10 @@ module RI
|
||||||
[ "--help", "-h", nil,
|
[ "--help", "-h", nil,
|
||||||
"you're looking at it" ],
|
"you're looking at it" ],
|
||||||
|
|
||||||
|
[ "--classes", "-c", nil,
|
||||||
|
"Display the names of classes and modules we\n" +
|
||||||
|
"know about"],
|
||||||
|
|
||||||
[ "--format", "-f", "<name>",
|
[ "--format", "-f", "<name>",
|
||||||
"Format to use when displaying output:\n" +
|
"Format to use when displaying output:\n" +
|
||||||
" " + RI::TextFormatter.list + "\n" +
|
" " + RI::TextFormatter.list + "\n" +
|
||||||
|
@ -112,8 +119,8 @@ module RI
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
if short_form
|
if short_form
|
||||||
class_list
|
puts "For help on options, type 'ri -h'"
|
||||||
puts "For help, type 'ri -h'"
|
puts "For a list of classes I know about, type 'ri -c'"
|
||||||
else
|
else
|
||||||
puts "Options:\n\n"
|
puts "Options:\n\n"
|
||||||
OPTION_LIST.each do |long, short, arg, desc|
|
OPTION_LIST.each do |long, short, arg, desc|
|
||||||
|
@ -136,30 +143,16 @@ module RI
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def OptionList.class_list
|
|
||||||
paths = RI::Paths::PATH
|
|
||||||
if paths.empty?
|
|
||||||
puts "Before using ri, you need to generate documentation"
|
|
||||||
puts "using 'rdoc' with the --ri option"
|
|
||||||
else
|
|
||||||
@ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
|
|
||||||
puts
|
|
||||||
puts "Classes and modules I know about:"
|
|
||||||
puts
|
|
||||||
puts @ri_reader.class_names.sort.join(", ")
|
|
||||||
puts
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parse command line options.
|
# Parse command line options.
|
||||||
|
|
||||||
def parse
|
def parse
|
||||||
|
|
||||||
@use_stdout = !STDOUT.tty?
|
@use_stdout = !STDOUT.tty?
|
||||||
@width = 72
|
@width = 72
|
||||||
@formatter = RI::TextFormatter.for("plain")
|
@formatter = RI::TextFormatter.for("plain")
|
||||||
|
@list_classes = false
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
@ -170,6 +163,8 @@ module RI
|
||||||
case opt
|
case opt
|
||||||
when "--help" then OptionList.usage
|
when "--help" then OptionList.usage
|
||||||
when "--no-pager" then @use_stdout = true
|
when "--no-pager" then @use_stdout = true
|
||||||
|
when "--classes" then @list_classes = true
|
||||||
|
|
||||||
when "--format"
|
when "--format"
|
||||||
@formatter = RI::TextFormatter.for(arg)
|
@formatter = RI::TextFormatter.for(arg)
|
||||||
unless @formatter
|
unless @formatter
|
||||||
|
|
55
object.c
55
object.c
|
@ -1171,7 +1171,7 @@ sym_to_sym(sym)
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* Document-class: Module
|
* Document-class: Module
|
||||||
*
|
*
|
||||||
* A <code>Module</code> is a collection of methods and constants. The
|
* A <code>Module</code> is a collection of methods and constants. The
|
||||||
* methods in a module may be instance methods or module methods.
|
* methods in a module may be instance methods or module methods.
|
||||||
|
@ -1197,6 +1197,15 @@ sym_to_sym(sym)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* mod.to_s => string
|
||||||
|
*
|
||||||
|
* Return a string representing this module or class. For basic
|
||||||
|
* classes and modules, this is the name. For singletons, we
|
||||||
|
* show information on the thing we're attached to as well.
|
||||||
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mod_to_s(klass)
|
rb_mod_to_s(klass)
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
|
@ -2395,30 +2404,28 @@ VALUE ruby_top_self;
|
||||||
*
|
*
|
||||||
* Creating a new Name
|
* Creating a new Name
|
||||||
*
|
*
|
||||||
* Classes, modules, and objects are interrelated. In the diagram
|
* Classes, modules, and objects are interrelated. In the diagram
|
||||||
* that follows, the arrows represent inheritance, and the
|
* that follows, the arrows represent inheritance, and the
|
||||||
* parentheses meta-classes. All metaclasses are instances
|
* parentheses meta-classes. All metaclasses are instances
|
||||||
* of the class `Class'.
|
* of the class `Class'.
|
||||||
*
|
|
||||||
* +------------------+
|
|
||||||
* | |
|
|
||||||
* Object---->(Object) |
|
|
||||||
* ^ ^ ^ ^ |
|
|
||||||
* | | | | |
|
|
||||||
* | | +-----+ +---------+ |
|
|
||||||
* | | | | |
|
|
||||||
* | +-----------+ | |
|
|
||||||
* | | | | |
|
|
||||||
* +------+ | Module--->(Module) |
|
|
||||||
* | | ^ ^ |
|
|
||||||
* OtherClass-->(OtherClass) | | |
|
|
||||||
* | | |
|
|
||||||
* Class---->(Class) |
|
|
||||||
* ^ |
|
|
||||||
* | |
|
|
||||||
* +----------------+
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
|
* +------------------+
|
||||||
|
* | |
|
||||||
|
* Object---->(Object) |
|
||||||
|
* ^ ^ ^ ^ |
|
||||||
|
* | | | | |
|
||||||
|
* | | +-----+ +---------+ |
|
||||||
|
* | | | | |
|
||||||
|
* | +-----------+ | |
|
||||||
|
* | | | | |
|
||||||
|
* +------+ | Module--->(Module) |
|
||||||
|
* | | ^ ^ |
|
||||||
|
* OtherClass-->(OtherClass) | | |
|
||||||
|
* | | |
|
||||||
|
* Class---->(Class) |
|
||||||
|
* ^ |
|
||||||
|
* | |
|
||||||
|
* +----------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
24
signal.c
24
signal.c
|
@ -198,6 +198,30 @@ ruby_signal_name(no)
|
||||||
return signo2signm(no);
|
return signo2signm(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* Process.kill(signal, pid, ...) => fixnum
|
||||||
|
*
|
||||||
|
* Sends the given signal to the specified process id(s), or to the
|
||||||
|
* current process if _pid_ is zero. _signal_ may be an
|
||||||
|
* integer signal number or a POSIX signal name (either with or without
|
||||||
|
* a +SIG+ prefix). If _signal_ is negative (or starts
|
||||||
|
* with a minus sign), kills process groups instead of
|
||||||
|
* processes. Not all signals are available on all platforms.
|
||||||
|
*
|
||||||
|
* pid = fork do
|
||||||
|
* Signal.trap("HUP") { puts "Ouch!"; exit }
|
||||||
|
* # ... do some work ...
|
||||||
|
* end
|
||||||
|
* # ...
|
||||||
|
* Process.kill("HUP", pid)
|
||||||
|
* Process.wait
|
||||||
|
*
|
||||||
|
* <em>produces:</em>
|
||||||
|
*
|
||||||
|
* Ouch!
|
||||||
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_f_kill(argc, argv)
|
rb_f_kill(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue