[前][次][番号順一覧][スレッド一覧]

ruby-changes:45739

From: stomar <ko1@a...>
Date: Thu, 9 Mar 2017 05:41:45 +0900 (JST)
Subject: [ruby-changes:45739] stomar:r57811 (trunk): docs for FileUtils.ln methods

stomar	2017-03-09 05:41:38 +0900 (Thu, 09 Mar 2017)

  New Revision: 57811

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57811

  Log:
    docs for FileUtils.ln methods
    
    * lib/fileutils.rb: [DOC] add clarifying call-seq's for FileUtil.ln,
      ln_s, and ln_sf, with better argument names for the created link and
      link target.  Reported by Mike Vastola. [ruby-core:62532] [Bug #9829]
    
    * lib/fileutils.rb: [DOC] further improve descriptions of FileUtils.ln
      and related methods; improve examples: relative links probably won't
      work in other dir, avoid `include', use more generic homedir name.

  Modified files:
    trunk/lib/fileutils.rb
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 57810)
+++ lib/fileutils.rb	(revision 57811)
@@ -24,11 +24,11 @@ https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L24
 #   FileUtils.mkdir_p(list, options)
 #   FileUtils.rmdir(dir, options)
 #   FileUtils.rmdir(list, options)
-#   FileUtils.ln(old, new, options)
-#   FileUtils.ln(list, destdir, options)
-#   FileUtils.ln_s(old, new, options)
-#   FileUtils.ln_s(list, destdir, options)
-#   FileUtils.ln_sf(src, dest, options)
+#   FileUtils.ln(target, link, options)
+#   FileUtils.ln(targets, dir, options)
+#   FileUtils.ln_s(target, link, options)
+#   FileUtils.ln_s(targets, dir, options)
+#   FileUtils.ln_sf(target, link, options)
 #   FileUtils.cp(src, dest, options)
 #   FileUtils.cp(list, dir, options)
 #   FileUtils.cp_r(src, dest, options)
@@ -260,23 +260,24 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L260
   module_function :rmdir
 
   #
-  # <b><tt>ln(old, new, **options)</tt></b>
+  # :call-seq:
+  #   FileUtils.ln(target, link, force: nil, noop: nil, verbose: nil)
+  #   FileUtils.ln(target,  dir, force: nil, noop: nil, verbose: nil)
+  #   FileUtils.ln(targets, dir, force: nil, noop: nil, verbose: nil)
+  #
+  # In the first form, creates a hard link +link+ which points to +target+.
+  # If +link+ already exists, raises Errno::EEXIST.
+  # But if the :force option is set, overwrites +link+.
   #
-  # Creates a hard link +new+ which points to +old+.
-  # If +new+ already exists and it is a directory, creates a link +new/old+.
-  # If +new+ already exists and it is not a directory, raises Errno::EEXIST.
-  # But if :force option is set, overwrite +new+.
-  #
-  #   FileUtils.ln 'gcc', 'cc', :verbose => true
+  #   FileUtils.ln 'gcc', 'cc', verbose: true
   #   FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
   #
-  # <b><tt>ln(list, destdir, **options)</tt></b>
-  #
-  # Creates several hard links in a directory, with each one pointing to the
-  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
+  # In the second form, creates a link +dir/target+ pointing to +target+.
+  # In the third form, creates several hard links in the directory +dir+,
+  # pointing to each item in +targets+.
+  # If +dir+ is not a directory, raises Errno::ENOTDIR.
   #
-  #   include FileUtils
-  #   cd '/sbin'
+  #   FileUtils.cd '/sbin'
   #   FileUtils.ln %w(cp mv mkdir), '/bin'   # Now /sbin/cp and /bin/cp are linked.
   #
   def ln(src, dest, force: nil, noop: nil, verbose: nil)
@@ -293,24 +294,24 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L294
   module_function :link
 
   #
-  # <b><tt>ln_s(old, new, **options)</tt></b>
-  #
-  # Creates a symbolic link +new+ which points to +old+.  If +new+ already
-  # exists and it is a directory, creates a symbolic link +new/old+.  If +new+
-  # already exists and it is not a directory, raises Errno::EEXIST.  But if
-  # :force option is set, overwrite +new+.
+  # :call-seq:
+  #   FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil)
+  #   FileUtils.ln_s(target,  dir, force: nil, noop: nil, verbose: nil)
+  #   FileUtils.ln_s(targets, dir, force: nil, noop: nil, verbose: nil)
+  #
+  # In the first form, creates a symbolic link +link+ which points to +target+.
+  # If +link+ already exists, raises Errno::EEXIST.
+  # But if the :force option is set, overwrites +link+.
   #
   #   FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
-  #   FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
+  #   FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
   #
-  # <b><tt>ln_s(list, destdir, **options)</tt></b>
+  # In the second form, creates a link +dir/target+ pointing to +target+.
+  # In the third form, creates several symbolic links in the directory +dir+,
+  # pointing to each item in +targets+.
+  # If +dir+ is not a directory, raises Errno::ENOTDIR.
   #
-  # Creates several symbolic links in a directory, with each one pointing to the
-  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
-  #
-  # If +destdir+ is not a directory, raises Errno::ENOTDIR.
-  #
-  #   FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
+  #   FileUtils.ln_s Dir.glob('/bin/*.rb'), '/home/foo/bin'
   #
   def ln_s(src, dest, force: nil, noop: nil, verbose: nil)
     fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
@@ -326,9 +327,12 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L327
   module_function :symlink
 
   #
+  # :call-seq:
+  #   FileUtils.ln_sf(*args)
+  #
   # Same as
   #
-  #   FileUtils.ln_s(src, dest, :force => true)
+  #   FileUtils.ln_s(*args, force: true)
   #
   def ln_sf(src, dest, noop: nil, verbose: nil)
     ln_s src, dest, force: true, noop: noop, verbose: verbose
@@ -371,7 +375,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L375
   #
   #   # Examples of copying several files to target directory.
   #   FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
-  #   FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
+  #   FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', :noop => true, :verbose => true
   #
   #   # If you want to copy all contents of a directory instead of the
   #   # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
@@ -445,7 +449,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L449
   #   FileUtils.mv 'badname.rb', 'goodname.rb'
   #   FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true  # no error
   #
-  #   FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
+  #   FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
   #   FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
   #
   def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]