Class: RDoc::Store
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Inherits: | Object |
Defined in: | lib/rdoc/store.rb |
Overview
A set of rdoc data for a single project (gem, path, etc.).
The store manages reading and writing ri data for a project and maintains a cache of methods, classes and ancestors in the store.
The store maintains a #cache of its contents for faster lookup. After adding items to the store it must be flushed using #save_cache. The cache contains the following structures:
@cache = {
:ancestors => {}, # class name => ancestor names
:attributes => {}, # class name => attributes
:class_methods => {}, # class name => class methods
:instance_methods => {}, # class name => instance methods
:modules => [], # classes and modules in this store
:pages => [], # page names
}
Constant Summary
-
MarshalFilter =
private
# File 'lib/rdoc/store.rb', line 989proc do |obj| case obj when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text else unless obj.class.name.start_with?("RDoc::") raise TypeError, "not permitted class: #{obj.class.name}" end end obj end
Class Method Summary
- .new(path = nil, type = nil) ⇒ Store constructor
Instance Attribute Summary
-
#c_class_variables
readonly
Maps C variables to class or module names for each parsed C file.
-
#c_singleton_class_variables
readonly
Maps C variables to singleton class names for each parsed C file.
-
#cache
readonly
The contents of the
Store
. -
#dry_run
rw
If true this
Store
will not write any files. -
#encoding
rw
The encoding of the contents in the
Store
. -
#main
rw
Gets the main page for this
RDoc
store. -
#main=(page)
rw
Sets the main page for this
RDoc
store. -
#path
rw
Path this store reads or writes.
-
#rdoc
rw
The
RDoc
driver for this parse tree. -
#title
rw
Gets the title for this
RDoc
store. -
#title=(title)
rw
Sets the title page for this
RDoc
store. -
#type
rw
Type of ri datastore this was loaded from.
-
#unmatched_constant_alias
readonly
The lazy constants alias will be discovered in passing.
-
#c_enclosure_classes
readonly
Internal use only
Stores the name of the C variable a class belongs to.
- #c_enclosure_names readonly Internal use only
Instance Method Summary
-
#add_c_enclosure(variable, namespace)
Adds
module
as an enclosure (namespace) for the givenvariable
for C files. -
#add_c_variables(c_parser)
Adds C variables from an
Parser::C
-
#add_file(absolute_name, relative_name: absolute_name, parser: nil)
Adds the file with
name
as anTopLevel
to the store. -
#all_classes
Returns all classes discovered by
RDoc
. -
#all_classes_and_modules
Returns all classes and modules discovered by
RDoc
. -
#all_files
All TopLevels known to
RDoc
. -
#all_modules
Returns all modules discovered by
RDoc
. -
#ancestors
Ancestors cache accessor.
-
#attributes
Attributes cache accessor.
-
#cache_path
Path to the cache file.
-
#class_file(klass_name)
Path to the ri data for
klass_name
-
#class_methods
Class methods cache accessor.
-
#class_path(klass_name)
Path where data for
klass_name
will be stored (methods or class data). -
#classes_hash
Hash of all classes known to
RDoc
. -
#complete(min_visibility)
Prepares the
RDoc
code object tree for use by a generator. -
#files_hash
Hash of all files known to
RDoc
. -
#find_c_enclosure(variable)
Finds the enclosure (namespace) for the given C
variable
. -
#find_class_named(name)
Finds the class with
name
in all discovered classes. -
#find_class_named_from(name, from)
Finds the class with
name
starting in namespacefrom
-
#find_class_or_module(name)
Finds the class or module with
name
-
#find_file_named(name)
Finds the file with
name
in all discovered files. -
#find_module_named(name)
Finds the module with
name
in all discovered modules. -
#find_text_page(file_name)
Returns the
TopLevel
that is a text file and has the givenfile_name
-
#find_unique(all_hash)
Finds unique classes/modules defined in
all_hash
, and returns them as an array. -
#fix_basic_object_inheritance
Fixes the erroneous
BasicObject < Object
in 1.9. -
#friendly_path
Friendly rendition of #path
-
#instance_methods
Instance methods cache accessor.
-
#load_all
Loads all items from this store into memory.
-
#load_cache
Loads cache file for this store.
-
#load_class(klass_name)
Loads ri data for
klass_name
and hooks it up to this store. -
#load_class_data(klass_name)
Loads ri data for
klass_name
-
#load_method(klass_name, method_name)
Loads ri data for
method_name
inklass_name
-
#load_page(page_name)
Loads ri data for
page_name
-
#make_variable_map(variables)
Converts the variable =>
ClassModule
mapvariables
from a C parser into a variable => class name map. -
#method_file(klass_name, method_name)
Path to the ri data for
method_name
inklass_name
-
#module_names
Modules cache accessor.
-
#modules_hash
Hash of all modules known to
RDoc
. -
#page(name)
Returns the
TopLevel
that is a text file and has the givenname
-
#page_file(page_name)
Path to the ri data for
page_name
-
#remove_nodoc(all_hash)
Removes from
all_hash
the contexts that are nodoc or have no content. -
#resolve_c_superclasses
Make sure any references to C variable names are resolved to the corresponding class.
-
#save
Saves all entries in the store.
-
#save_cache
Writes the cache file for this store.
-
#save_class(klass)
Writes the ri data for
klass
(or module). -
#save_method(klass, method)
Writes the ri data for
method
onklass
-
#save_page(page)
Writes the ri data for #page
-
#source
Source of the contents of this store.
-
#unique_classes
Returns the unique classes discovered by
RDoc
. -
#unique_classes_and_modules
Returns the unique classes and modules discovered by
RDoc
. -
#unique_modules
Returns the unique modules discovered by
RDoc
. -
#update_parser_of_file(absolute_name, parser)
Sets the parser of
absolute_name
, unless it from a source code file. - #marshal_load(file) private
-
#clean_cache_collection(collection)
Internal use only
Removes empty items and ensures item in each collection are unique and sorted.
- #inspect Internal use only
Constructor Details
.new(path = nil, type = nil) ⇒ Store
[ GitHub ]
# File 'lib/rdoc/store.rb', line 127
def initialize path = nil, type = nil @dry_run = false @encoding = nil @path = path @rdoc = nil @type = type @cache = { :ancestors => {}, :attributes => {}, :class_methods => {}, :c_class_variables => {}, :c_singleton_class_variables => {}, :encoding => @encoding, :instance_methods => {}, :main => nil, :modules => [], :pages => [], :title => nil, } @classes_hash = {} @modules_hash = {} @files_hash = {} @text_files_hash = {} @c_enclosure_classes = {} @c_enclosure_names = {} @c_class_variables = {} @c_singleton_class_variables = {} @unique_classes = nil @unique_modules = nil @unmatched_constant_alias = {} end
Instance Attribute Details
#c_class_variables (readonly)
Maps C variables to class or module names for each parsed C file.
# File 'lib/rdoc/store.rb', line 80
attr_reader :c_class_variables
#c_enclosure_classes (readonly)
Stores the name of the C variable a class belongs to. This helps wire up classes defined from C across files.
# File 'lib/rdoc/store.rb', line 73
attr_reader :c_enclosure_classes # :nodoc:
#c_enclosure_names (readonly)
# File 'lib/rdoc/store.rb', line 75
attr_reader :c_enclosure_names # :nodoc:
#c_singleton_class_variables (readonly)
Maps C variables to singleton class names for each parsed C file.
# File 'lib/rdoc/store.rb', line 85
attr_reader :c_singleton_class_variables
#cache (readonly)
The contents of the Store
# File 'lib/rdoc/store.rb', line 112
attr_reader :cache
#dry_run (rw)
If true this Store
will not write any files
# File 'lib/rdoc/store.rb', line 90
attr_accessor :dry_run
#encoding (rw)
The encoding of the contents in the Store
# File 'lib/rdoc/store.rb', line 117
attr_accessor :encoding
#main (rw)
[ GitHub ]# File 'lib/rdoc/store.rb', line 673
def main @cache[:main] end
#main=(page) (rw)
Sets the main page for this RDoc
store.
#path (rw)
Path this store reads or writes
# File 'lib/rdoc/store.rb', line 95
attr_accessor :path
#rdoc (rw)
The RDoc
driver for this parse tree. This allows classes consulting the documentation tree to access user-set options, for example.
# File 'lib/rdoc/store.rb', line 101
attr_accessor :rdoc
#title (rw)
[ GitHub ]# File 'lib/rdoc/store.rb', line 948
def title @cache[:title] end
#title=(title) (rw)
Sets the title page for this RDoc
store.
#type (rw)
Type of ri datastore this was loaded from. See RI::Driver
, RI::Paths
.
# File 'lib/rdoc/store.rb', line 107
attr_accessor :type
#unmatched_constant_alias (readonly)
The lazy constants alias will be discovered in passing
# File 'lib/rdoc/store.rb', line 122
attr_reader :unmatched_constant_alias
Instance Method Details
#add_c_enclosure(variable, namespace)
Adds module
as an enclosure (namespace) for the given variable
for C files.
# File 'lib/rdoc/store.rb', line 169
def add_c_enclosure variable, namespace @c_enclosure_classes[variable] = namespace end
#add_c_variables(c_parser)
Adds C variables from an Parser::C
# File 'lib/rdoc/store.rb', line 176
def add_c_variables c_parser filename = c_parser.top_level.relative_name @c_class_variables[filename] = make_variable_map c_parser.classes @c_singleton_class_variables[filename] = c_parser.singleton_classes end
#add_file(absolute_name, relative_name: absolute_name, parser: nil)
[ GitHub ]# File 'lib/rdoc/store.rb', line 188
def add_file absolute_name, relative_name: absolute_name, parser: nil unless top_level = @files_hash[relative_name] then top_level = RDoc::TopLevel.new absolute_name, relative_name top_level.parser = parser if parser top_level.store = self @files_hash[relative_name] = top_level @text_files_hash[relative_name] = top_level if top_level.text? end top_level end
#all_classes
Returns all classes discovered by RDoc
# File 'lib/rdoc/store.rb', line 224
def all_classes @classes_hash.values end
#all_classes_and_modules
Returns all classes and modules discovered by RDoc
# File 'lib/rdoc/store.rb', line 231
def all_classes_and_modules @classes_hash.values + @modules_hash.values end
#all_files
All TopLevels known to RDoc
# File 'lib/rdoc/store.rb', line 238
def all_files @files_hash.values end
#all_modules
Returns all modules discovered by RDoc
# File 'lib/rdoc/store.rb', line 245
def all_modules modules_hash.values end
#ancestors
Ancestors cache accessor. Maps a klass name to an Array of its ancestors in this store. If Foo in this store inherits from Object, Kernel won’t be listed (it will be included from ruby’s ri store).
# File 'lib/rdoc/store.rb', line 254
def ancestors @cache[:ancestors] end
#attributes
Attributes cache accessor. Maps a class to an Array of its attributes.
# File 'lib/rdoc/store.rb', line 261
def attributes @cache[:attributes] end
#cache_path
Path to the cache file
# File 'lib/rdoc/store.rb', line 268
def cache_path File.join @path, 'cache.ri' end
#class_file(klass_name)
Path to the ri data for klass_name
# File 'lib/rdoc/store.rb', line 275
def class_file klass_name name = klass_name.split('::').last File.join class_path(klass_name), "cdesc-#{name}.ri" end
#class_methods
Class methods cache accessor. Maps a class to an Array of its class methods (not full name).
# File 'lib/rdoc/store.rb', line 284
def class_methods @cache[:class_methods] end
#class_path(klass_name)
Path where data for klass_name
will be stored (methods or class data)
# File 'lib/rdoc/store.rb', line 291
def class_path klass_name File.join @path, *klass_name.split('::') end
#classes_hash
Hash of all classes known to RDoc
# File 'lib/rdoc/store.rb', line 298
def classes_hash @classes_hash end
#clean_cache_collection(collection)
Removes empty items and ensures item in each collection are unique and sorted
# File 'lib/rdoc/store.rb', line 306
def clean_cache_collection collection # :nodoc: collection.each do |name, item| if item.empty? then collection.delete name else # HACK mongrel-1.1.5 documents its files twice item.uniq! item.sort! end end end
#complete(min_visibility)
Prepares the RDoc
code object tree for use by a generator.
It finds unique classes/modules defined, and replaces classes/modules that are aliases for another one by a copy with ClassModule#is_alias_for set.
It updates the ClassModule#constant_aliases attribute of “real” classes or modules.
It also completely removes the classes and modules that should be removed from the documentation and the methods that have a visibility below min_visibility
, which is the --visibility
option.
See also Context#remove_from_documentation?
# File 'lib/rdoc/store.rb', line 334
def complete min_visibility fix_basic_object_inheritance # cache included modules before they are removed from the documentation all_classes_and_modules.each { |cm| cm.ancestors } unless min_visibility == :nodoc then remove_nodoc @classes_hash remove_nodoc @modules_hash end @unique_classes = find_unique @classes_hash @unique_modules = find_unique @modules_hash unique_classes_and_modules.each do |cm| cm.complete min_visibility end @files_hash.each_key do |file_name| tl = @files_hash[file_name] unless tl.text? then tl.modules_hash.clear tl.classes_hash.clear tl.classes_or_modules.each do |cm| name = cm.full_name if cm.type == 'class' then tl.classes_hash[name] = cm if @classes_hash[name] else tl.modules_hash[name] = cm if @modules_hash[name] end end end end end
#files_hash
Hash of all files known to RDoc
# File 'lib/rdoc/store.rb', line 374
def files_hash @files_hash end
#find_c_enclosure(variable)
Finds the enclosure (namespace) for the given C variable
.
# File 'lib/rdoc/store.rb', line 381
def find_c_enclosure variable @c_enclosure_classes.fetch variable do break unless name = @c_enclosure_names[variable] mod = find_class_or_module name unless mod then loaded_mod = load_class_data name file = loaded_mod.in_files.first return unless file # legacy data source file.store = self mod = file.add_module RDoc::NormalModule, name end @c_enclosure_classes[variable] = mod end end
#find_class_named(name)
Finds the class with name
in all discovered classes
# File 'lib/rdoc/store.rb', line 406
def find_class_named name @classes_hash[name] end
#find_class_named_from(name, from)
Finds the class with name
starting in namespace from
# File 'lib/rdoc/store.rb', line 413
def find_class_named_from name, from from = find_class_named from unless RDoc::Context === from until RDoc::TopLevel === from do return nil unless from klass = from.find_class_named name return klass if klass from = from.parent end find_class_named name end
#find_class_or_module(name)
Finds the class or module with name
# File 'lib/rdoc/store.rb', line 431
def find_class_or_module name name = $' if name =~ /^::/ @classes_hash[name] || @modules_hash[name] end
#find_file_named(name)
Finds the file with name
in all discovered files
# File 'lib/rdoc/store.rb', line 439
def find_file_named name @files_hash[name] end
#find_module_named(name)
Finds the module with name
in all discovered modules
# File 'lib/rdoc/store.rb', line 446
def find_module_named name @modules_hash[name] end
#find_text_page(file_name)
Returns the TopLevel
that is a text file and has the given file_name
# File 'lib/rdoc/store.rb', line 454
def find_text_page file_name @text_files_hash.each_value.find do |file| file.full_name == file_name end end
#find_unique(all_hash)
Finds unique classes/modules defined in all_hash
, and returns them as an array. Performs the alias updates in all_hash
: see #complete.
# File 'lib/rdoc/store.rb', line 467
def find_unique all_hash unique = [] all_hash.each_pair do |full_name, cm| unique << cm if full_name == cm.full_name end unique end
#fix_basic_object_inheritance
Fixes the erroneous BasicObject < Object
in 1.9.
Because we assumed all classes without a stated superclass inherit from Object, we have the above wrong inheritance.
We fix BasicObject right away if we are running in a Ruby version >= 1.9.
# File 'lib/rdoc/store.rb', line 486
def fix_basic_object_inheritance basic = classes_hash['BasicObject'] return unless basic basic.superclass = nil end
#friendly_path
Friendly rendition of #path
#inspect
# File 'lib/rdoc/store.rb', line 507
def inspect # :nodoc: "#<%s:0x%x %s %p>" % [self.class, object_id, @path, module_names.sort] end
#instance_methods
Instance methods cache accessor. Maps a class to an Array of its instance methods (not full name).
# File 'lib/rdoc/store.rb', line 515
def instance_methods @cache[:instance_methods] end
#load_all
Loads all items from this store into memory. This recreates a documentation tree for use by a generator
# File 'lib/rdoc/store.rb', line 523
def load_all load_cache module_names.each do |module_name| mod = find_class_or_module(module_name) || load_class(module_name) # load method documentation since the loaded class/module does not have # it loaded_methods = mod.method_list.map do |method| load_method module_name, method.full_name end mod.method_list.replace loaded_methods loaded_attributes = mod.attributes.map do |attribute| load_method module_name, attribute.full_name end mod.attributes.replace loaded_attributes end all_classes_and_modules.each do |mod| descendent_re = /^#{mod.full_name}::[^:]+$/ module_names.each do |name| next unless name =~ descendent_re descendent = find_class_or_module name case descendent when RDoc::NormalClass then mod.classes_hash[name] = descendent when RDoc::NormalModule then mod.modules_hash[name] = descendent end end end @cache[:pages].each do |page_name| page = load_page page_name @files_hash[page_name] = page @text_files_hash[page_name] = page if page.text? end end
#load_cache
Loads cache file for this store
# File 'lib/rdoc/store.rb', line 571
def load_cache #orig_enc = @encoding @cache = marshal_load(cache_path) load_enc = @cache[:encoding] # TODO this feature will be time-consuming to add: # a) Encodings may be incompatible but transcodeable # b) Need to warn in the appropriate spots, wherever they may be # c) Need to handle cross-cache differences in encodings # d) Need to warn when generating into a cache with different encodings # #if orig_enc and load_enc != orig_enc then # warn "Cached encoding #{load_enc} is incompatible with #{orig_enc}\n" \ # "from #{path}/cache.ri" unless # Encoding.compatible? orig_enc, load_enc #end @encoding = load_enc unless @encoding @cache[:pages] ||= [] @cache[:main] ||= nil @cache[:c_class_variables] ||= {} @cache[:c_singleton_class_variables] ||= {} @cache[:c_class_variables].each do |_, map| map.each do |variable, name| @c_enclosure_names[variable] = name end end @cache rescue Errno::ENOENT end
#load_class(klass_name)
Loads ri data for klass_name
and hooks it up to this store.
# File 'lib/rdoc/store.rb', line 610
def load_class klass_name obj = load_class_data klass_name obj.store = self case obj when RDoc::NormalClass then @classes_hash[klass_name] = obj when RDoc::SingleClass then @classes_hash[klass_name] = obj when RDoc::NormalModule then @modules_hash[klass_name] = obj end end
#load_class_data(klass_name)
Loads ri data for klass_name
# File 'lib/rdoc/store.rb', line 628
def load_class_data klass_name file = class_file klass_name marshal_load(file) rescue Errno::ENOENT => e error = MissingFileError.new(self, file, klass_name) error.set_backtrace e.backtrace raise error end
#load_method(klass_name, method_name)
Loads ri data for method_name
in klass_name
# File 'lib/rdoc/store.rb', line 641
def load_method klass_name, method_name file = method_file klass_name, method_name obj = marshal_load(file) obj.store = self obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name) obj rescue Errno::ENOENT => e error = MissingFileError.new(self, file, klass_name + method_name) error.set_backtrace e.backtrace raise error end
#load_page(page_name)
Loads ri data for page_name
# File 'lib/rdoc/store.rb', line 657
def load_page page_name file = page_file page_name obj = marshal_load(file) obj.store = self obj rescue Errno::ENOENT => e error = MissingFileError.new(self, file, page_name) error.set_backtrace e.backtrace raise error end
#make_variable_map(variables)
Converts the variable => ClassModule
map variables
from a C parser into a variable => class name map.
# File 'lib/rdoc/store.rb', line 688
def make_variable_map variables map = {} variables.each { |variable, class_module| map[variable] = class_module.full_name } map end
#marshal_load(file) (private)
[ GitHub ]# File 'lib/rdoc/store.rb', line 985
def marshal_load(file) File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)} end
#method_file(klass_name, method_name)
Path to the ri data for method_name
in klass_name
# File 'lib/rdoc/store.rb', line 701
def method_file klass_name, method_name method_name = method_name.split('::').last method_name =~ /#(.*)/ method_type = $1 ? 'i' : 'c' method_name = $1 if $1 method_name = method_name.gsub(/\W/) { "%%%02x" % $&[0].ord } File.join class_path(klass_name), "#{method_name}-#{method_type}.ri" end
#module_names
Modules cache accessor. An Array of all the module (and class) names in the store.
# File 'lib/rdoc/store.rb', line 715
def module_names @cache[:modules] end
#modules_hash
Hash of all modules known to RDoc
# File 'lib/rdoc/store.rb', line 722
def modules_hash @modules_hash end
#page(name)
Returns the TopLevel
that is a text file and has the given name
# File 'lib/rdoc/store.rb', line 729
def page name @text_files_hash.each_value.find do |file| file.page_name == name or file.base_name == name end end
#page_file(page_name)
Path to the ri data for page_name
# File 'lib/rdoc/store.rb', line 738
def page_file page_name file_name = File.basename(page_name).gsub('.', '_') File.join @path, File.dirname(page_name), "page-#{file_name}.ri" end
#remove_nodoc(all_hash)
Removes from all_hash
the contexts that are nodoc or have no content.
# File 'lib/rdoc/store.rb', line 749
def remove_nodoc all_hash all_hash.keys.each do |name| context = all_hash[name] all_hash.delete(name) if context.remove_from_documentation? end end
#resolve_c_superclasses
Make sure any references to C variable names are resolved to the corresponding class.
# File 'lib/rdoc/store.rb', line 204
def resolve_c_superclasses @classes_hash.each_value do |klass| if klass.superclass.is_a?(String) && (candidate = find_c_enclosure(klass.superclass)) klass.superclass = candidate end end end
#save
Saves all entries in the store
# File 'lib/rdoc/store.rb', line 759
def save load_cache all_classes_and_modules.each do |klass| save_class klass klass.each_method do |method| save_method klass, method end klass.each_attribute do |attribute| save_method klass, attribute end end all_files.each do |file| save_page file end save_cache end
#save_cache
Writes the cache file for this store
# File 'lib/rdoc/store.rb', line 784
def save_cache clean_cache_collection @cache[:ancestors] clean_cache_collection @cache[:attributes] clean_cache_collection @cache[:class_methods] clean_cache_collection @cache[:instance_methods] @cache[:modules].uniq! @cache[:modules].sort! @cache[:pages].uniq! @cache[:pages].sort! @cache[:encoding] = @encoding # this gets set twice due to assert_cache @cache[:c_class_variables].merge! @c_class_variables @cache[:c_singleton_class_variables].merge! @c_singleton_class_variables return if @dry_run File.open cache_path, 'wb' do |io| Marshal.dump @cache, io end end
#save_class(klass)
Writes the ri data for klass
(or module)
# File 'lib/rdoc/store.rb', line 811
def save_class klass full_name = klass.full_name FileUtils.mkdir_p class_path(full_name) unless @dry_run @cache[:modules] << full_name path = class_file full_name begin disk_klass = load_class full_name klass = disk_klass.merge klass rescue MissingFileError end # BasicObject has no ancestors ancestors = klass.direct_ancestors.compact.map do |ancestor| # HACK for classes we don't know about (class X < RuntimeError) String === ancestor ? ancestor : ancestor.full_name end @cache[:ancestors][full_name] ||= [] @cache[:ancestors][full_name].concat ancestors attribute_definitions = klass.attributes.map do |attribute| "#{attribute.definition} #{attribute.name}" end unless attribute_definitions.empty? then @cache[:attributes][full_name] ||= [] @cache[:attributes][full_name].concat attribute_definitions end to_delete = [] unless klass.method_list.empty? then @cache[:class_methods][full_name] ||= [] @cache[:instance_methods][full_name] ||= [] class_methods, instance_methods = klass.method_list.partition { |meth| meth.singleton } class_methods = class_methods. map { |method| method.name } instance_methods = instance_methods.map { |method| method.name } attribute_names = klass.attributes.map { |attr| attr.name } old = @cache[:class_methods][full_name] - class_methods to_delete.concat old.map { |method| method_file full_name, "#{full_name}::#{method}" } old = @cache[:instance_methods][full_name] - instance_methods - attribute_names to_delete.concat old.map { |method| method_file full_name, "#{full_name}##{method}" } @cache[:class_methods][full_name] = class_methods @cache[:instance_methods][full_name] = instance_methods end return if @dry_run FileUtils.rm_f to_delete File.open path, 'wb' do |io| Marshal.dump klass, io end end
#save_method(klass, method)
Writes the ri data for method
on klass
# File 'lib/rdoc/store.rb', line 885
def save_method klass, method full_name = klass.full_name FileUtils.mkdir_p class_path(full_name) unless @dry_run cache = if method.singleton then @cache[:class_methods] else @cache[:instance_methods] end cache[full_name] ||= [] cache[full_name] << method.name return if @dry_run File.open method_file(full_name, method.full_name), 'wb' do |io| Marshal.dump method, io end end
#save_page(page)
Writes the ri data for #page
#source
Source of the contents of this store.
For a store from a gem the source is the gem name. For a store from the home directory the source is “home”. For system ri store (the standard library documentation) the source is“ruby”. For a store from the site ri directory the store is “site”. For other stores the source is the #path.
#unique_classes
# File 'lib/rdoc/store.rb', line 964
def unique_classes @unique_classes end
#unique_classes_and_modules
# File 'lib/rdoc/store.rb', line 972
def unique_classes_and_modules @unique_classes + @unique_modules end
#unique_modules
# File 'lib/rdoc/store.rb', line 980
def unique_modules @unique_modules end
#update_parser_of_file(absolute_name, parser)
Sets the parser of absolute_name
, unless it from a source code file.
# File 'lib/rdoc/store.rb', line 215
def update_parser_of_file(absolute_name, parser) if top_level = @files_hash[absolute_name] then @text_files_hash[absolute_name] = top_level if top_level.text? end end