RDoc --force flag

Vincent Fourmond <[email protected]>
Newsgroups gmane.comp.lang.ruby.documentation
Message-ID <[email protected]>
  Hello !

  I use a lot rdoc, and I sometimes want to have an image/ subdirectory
in the output directory, to store images in a consistent way. However,
if I create a permanent doc/image/ directory, rdoc doesn't want to
output anything. I know the workaround is just to add a doc/created.rid
file, but at the same time, it would be great to simply say

  rdoc --force

  and have it work.

  I join a patch that does that, I just hope I'm sending it to the right
place.

  Regards

    Vincent Fourmond, newcomer...
rdoc_force_flag.diff (text/plain, 2.4 KB)
diff -Naur rdoc.old/options.rb rdoc.new/options.rb
--- rdoc.old/options.rb	2006-05-27 12:25:21.000000000 +0200
+++ rdoc.new/options.rb	2006-05-27 12:29:34.000000000 +0200
@@ -22,6 +22,9 @@
   # include private and protected methods in the
   # output
   attr_accessor :show_all
+
+  # If set, ignores the "already existing dir" error
+  attr_accessor :force_dir_overwrite
   
   # name of the file, class or module to display in
   # the initial index page (if not specified
@@ -137,6 +140,11 @@
       [ "--fmt",           "-f",   "format name",
         "set the output formatter (see below)" ],
 
+      [ "--force",         "-!",   nil,
+        "forces tp write the output, even if the \n" +
+        "directory doesn't look like it has been \n" +
+        "produced yb rdoc. Use with caution !" ],
+
       [ "--help",          "-h",   nil,
         "you're looking at it" ],
 
@@ -396,6 +404,7 @@
         when "--opname"        then @op_name       = arg
         when "--promiscuous"   then @promiscuous   = true
         when "--quiet"         then @quiet         = true
+        when "--force"         then @force_dir_overwrite = true
         when "--show-hash"     then @show_hash     = true
         when "--style"         then @css           = arg
         when "--template"      then @template      = arg
diff -Naur rdoc.old/rdoc.rb rdoc.new/rdoc.rb
--- rdoc.old/rdoc.rb	2006-05-27 12:25:21.000000000 +0200
+++ rdoc.new/rdoc.rb	2006-05-27 12:24:44.000000000 +0200
@@ -104,13 +104,13 @@
     # then we refuse to use it, as we may clobber some
     # manually generated documentation
     
-    def setup_output_dir(op_dir)
+    def setup_output_dir(op_dir, force = false )
       flag_file = File.join(op_dir, "created.rid")
       if File.exist?(op_dir)
         unless File.directory?(op_dir)
           error "'#{op_dir}' exists, and is not a directory" 
         end
-        unless File.file?(flag_file)
+        unless File.file?(flag_file) or force
           error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
             "isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
             "destroying any of your existing files, you'll need to\n" +
@@ -238,7 +238,7 @@
       options.parse(argv, GENERATORS)
     
       unless options.all_one_file
-        setup_output_dir(options.op_dir)
+        setup_output_dir(options.op_dir, options.force_dir_overwrite)
       end
 
       file_info = parse_files(options)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.