1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Import RDoc 3

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2010-12-20 03:22:49 +00:00
parent d7effd506f
commit 2ef9c50c6e
106 changed files with 8878 additions and 4179 deletions

View file

@ -10,6 +10,11 @@ require 'fileutils'
class RDoc::RI::Store
##
# If true this Store will not write any files
attr_accessor :dry_run
##
# Path this store reads or writes
@ -21,14 +26,18 @@ class RDoc::RI::Store
attr_accessor :type
##
# The contents of the Store
attr_reader :cache
##
# Creates a new Store of +type+ that will load or save to +path+
def initialize path, type = nil
@type = type
@path = path
@dry_run = false
@type = type
@path = path
@cache = {
:class_methods => {},
@ -178,6 +187,8 @@ class RDoc::RI::Store
@cache[:instance_methods].each do |_, m| m.uniq!; m.sort! end
@cache[:modules].uniq!; @cache[:modules].sort!
return if @dry_run
open cache_path, 'wb' do |io|
Marshal.dump @cache, io
end
@ -187,7 +198,7 @@ class RDoc::RI::Store
# Writes the ri data for +klass+
def save_class klass
FileUtils.mkdir_p class_path(klass.full_name)
FileUtils.mkdir_p class_path(klass.full_name) unless @dry_run
@cache[:modules] << klass.full_name
@ -214,7 +225,7 @@ class RDoc::RI::Store
@cache[:ancestors][klass.full_name].push(*ancestors)
attributes = klass.attributes.map do |attribute|
"#{attribute.type} #{attribute.name}"
"#{attribute.definition} #{attribute.name}"
end
unless attributes.empty? then
@ -222,6 +233,8 @@ class RDoc::RI::Store
@cache[:attributes][klass.full_name].push(*attributes)
end
return if @dry_run
open path, 'wb' do |io|
Marshal.dump klass, io
end
@ -231,7 +244,7 @@ class RDoc::RI::Store
# Writes the ri data for +method+ on +klass+
def save_method klass, method
FileUtils.mkdir_p class_path(klass.full_name)
FileUtils.mkdir_p class_path(klass.full_name) unless @dry_run
cache = if method.singleton then
@cache[:class_methods]
@ -241,6 +254,8 @@ class RDoc::RI::Store
cache[klass.full_name] ||= []
cache[klass.full_name] << method.name
return if @dry_run
open method_file(klass.full_name, method.full_name), 'wb' do |io|
Marshal.dump method, io
end