In Files

  • rdoc/ri/writer.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::RI::Writer

Public Class Methods

class_desc_path(dir, class_desc) click to toggle source
 
               # File rdoc/ri/writer.rb, line 6
def self.class_desc_path(dir, class_desc)
  File.join(dir, "cdesc-" + class_desc.name + ".yaml")
end
            
external_to_internal(name) click to toggle source

And the reverse operation

 
               # File rdoc/ri/writer.rb, line 25
def self.external_to_internal(name)
  name.gsub(/%([0-9a-f]{2,2})/) { $1.to_i(16).chr }
end
            
internal_to_external(name) click to toggle source

Convert a name from internal form (containing punctuation) to an external form (where punctuation is replaced by %xx)

 
               # File rdoc/ri/writer.rb, line 14
def self.internal_to_external(name)
  if ''.respond_to? :ord then
    name.gsub(/\W/) { "%%%02x" % $&[0].ord }
  else
    name.gsub(/\W/) { "%%%02x" % $&[0] }
  end
end
            
new(base_dir) click to toggle source
 
               # File rdoc/ri/writer.rb, line 29
def initialize(base_dir)
  @base_dir = base_dir
end
            

Public Instance Methods

add_class(class_desc) click to toggle source
 
               # File rdoc/ri/writer.rb, line 37
def add_class(class_desc)
  dir = path_to_dir(class_desc.full_name)
  FileUtils.mkdir_p(dir)
  class_file_name = self.class.class_desc_path(dir, class_desc)
  File.open(class_file_name, "w") do |f|
    f.write(class_desc.serialize)
  end
end
            
add_method(class_desc, method_desc) click to toggle source
 
               # File rdoc/ri/writer.rb, line 46
def add_method(class_desc, method_desc)
  dir = path_to_dir(class_desc.full_name)
  file_name = self.class.internal_to_external(method_desc.name)
  meth_file_name = File.join(dir, file_name)
  if method_desc.is_singleton
    meth_file_name += "-c.yaml"
  else
    meth_file_name += "-i.yaml"
  end

  File.open(meth_file_name, "w") do |f|
    f.write(method_desc.serialize)
  end
end
            
remove_class(class_desc) click to toggle source
 
               # File rdoc/ri/writer.rb, line 33
def remove_class(class_desc)
  FileUtils.rm_rf(path_to_dir(class_desc.full_name))
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus