晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby18/lib64/ruby/1.8/rdoc/ri/ |
| Current File : //opt/alt/ruby18/lib64/ruby/1.8/rdoc/ri/ri_driver.rb |
require 'rdoc/ri/ri_paths'
require 'rdoc/usage'
require 'rdoc/ri/ri_cache'
require 'rdoc/ri/ri_util'
require 'rdoc/ri/ri_reader'
require 'rdoc/ri/ri_formatter'
require 'rdoc/ri/ri_options'
######################################################################
class RiDriver
def initialize
@options = RI::Options.instance
args = ARGV
if ENV["RI"]
args = ENV["RI"].split.concat(ARGV)
end
@options.parse(args)
path = @options.path
report_missing_documentation @options.raw_path if path.empty?
@ri_reader = RI::RiReader.new(RI::RiCache.new(path))
@display = @options.displayer
end
# Couldn't find documentation in +path+, so tell the user what to do
def report_missing_documentation(path)
STDERR.puts "No ri documentation found in:"
path.each do |d|
STDERR.puts " #{d}"
end
STDERR.puts "\nWas rdoc run to create documentation?\n\n"
RDoc::usage("Installing Documentation")
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
method = @ri_reader.get_method(methods[0])
@display.display_method_info(method)
else
entries = methods.find_all {|m| m.name == requested_method_name}
if entries.size == 1
method = @ri_reader.get_method(entries[0])
@display.display_method_info(method)
else
@display.display_method_list(methods)
end
end
end
######################################################################
def report_class_stuff(namespaces)
if namespaces.size == 1
klass = @ri_reader.get_class(namespaces[0])
@display.display_class_info(klass, @ri_reader)
else
# entries = namespaces.find_all {|m| m.full_name == requested_class_name}
# if entries.size == 1
# klass = @ri_reader.get_class(entries[0])
# @display.display_class_info(klass, @ri_reader)
# else
@display.display_class_list(namespaces)
# end
end
end
######################################################################
def get_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
# at this point, if we have multiple possible namespaces, but one
# is an exact match for our requested class, prune down to just it
full_class_name = desc.full_class_name
entries = namespaces.find_all {|m| m.full_name == full_class_name}
namespaces = entries if entries.size == 1
if desc.method_name.nil?
report_class_stuff(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
end
######################################################################
def process_args
if @options.list_classes
classes = @ri_reader.full_class_names
@display.list_known_classes(classes)
elsif @options.list_names
names = @ri_reader.all_names
@display.list_known_names(names)
else
if ARGV.size.zero?
@display.display_usage
else
begin
ARGV.each do |arg|
get_info_for(arg)
end
rescue RiError => e
STDERR.puts(e.message)
exit(1)
end
end
end
end
end # class RiDriver
|