summaryrefslogtreecommitdiffstats
path: root/lib/rdoc/ri/ri_writer.rb
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-16 05:44:25 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-16 05:44:25 +0000
commitd3e92ce85e33191d2bbdf5bbb0d2afdd31dbd162 (patch)
tree0d09db2cbe31c84eac3c29575e7008c9d7a6d57b /lib/rdoc/ri/ri_writer.rb
parent23bbc2f292b4bd0c4cf7af906e69aaf9533f998c (diff)
Initial load of support for ri/rdoc integration
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/ri_writer.rb')
-rw-r--r--lib/rdoc/ri/ri_writer.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
new file mode 100644
index 000000000..072b3acfe
--- /dev/null
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -0,0 +1,48 @@
+require 'fileutils'
+
+module RI
+ class RiWriter
+
+ def RiWriter.class_desc_path(dir, class_desc)
+ File.join(dir, "cdesc-" + class_desc.name + ".yaml")
+ end
+
+
+ def initialize(base_dir)
+ @base_dir = base_dir
+ end
+
+ def remove_class(class_desc)
+ FileUtils.rm_rf(path_to_dir(class_desc.full_name))
+ end
+
+ def add_class(class_desc)
+ dir = path_to_dir(class_desc.full_name)
+ FileUtils.mkdir_p(dir)
+ class_file_name = RiWriter.class_desc_path(dir, class_desc)
+ File.open(class_file_name, "w") do |f|
+ f.write(class_desc.serialize)
+ end
+ end
+
+ def add_method(class_desc, method_desc)
+ dir = path_to_dir(class_desc.full_name)
+ meth_file_name = File.join(dir, method_desc.name)
+ if method_desc.is_class_method
+ 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
+
+ private
+
+ def path_to_dir(class_name)
+ File.join(@base_dir, *class_name.split('::'))
+ end
+ end
+end