@@ -110,7 +110,11 @@ def self.private_module_function(name) #:nodoc:
110110 end
111111
112112 #
113- # Returns the name of the current directory.
113+ # Returns a string containing the path to the current directory:
114+ #
115+ # FileUtils.pwd # => "/rdoc/fileutils"
116+ #
117+ # FileUtils.getwd is an alias for FileUtils.pwd.
114118 #
115119 def pwd
116120 Dir . pwd
@@ -121,18 +125,36 @@ def pwd
121125 module_function :getwd
122126
123127 #
124- # Changes the current directory to the directory +dir+.
128+ # With no block given,
129+ # changes the current directory to the directory
130+ # at the path given by +dir+; returns zero:
131+ #
132+ # FileUtils.pwd # => "/rdoc/fileutils"
133+ # FileUtils.cd('..')
134+ # FileUtils.pwd # => "/rdoc"
135+ # FileUtils.cd('fileutils')
136+ #
137+ # With a block given, changes the current directory to the directory
138+ # at the path given by +dir+, calls the block with argument +dir+,
139+ # and restores the original current directory; returns the block's value:
125140 #
126- # If this method is called with block, resumes to the previous
127- # working directory after the block execution has finished.
141+ # FileUtils.pwd # => "/rdoc/fileutils"
142+ # FileUtils.cd('..') { |arg| [arg, FileUtils.pwd] } # => ["..", "/rdoc"]
143+ # FileUtils.pwd # => "/rdoc/fileutils"
128144 #
129- # FileUtils.cd('/') # change directory
145+ # Keyword arguments:
130146 #
131- # FileUtils.cd('/', verbose: true) # change directory and report it
147+ # - <tt> verbose: true</tt> - prints an equivalent command:
132148 #
133- # FileUtils.cd('/') do # change directory
134- # # ... # do something
135- # end # return to original directory
149+ # FileUtils.cd('..')
150+ # FileUtils.cd('fileutils')
151+ #
152+ # Output:
153+ #
154+ # cd ..
155+ # cd fileutils
156+ #
157+ # FileUtils.chdir is an alias for FileUtils.cd.
136158 #
137159 def cd ( dir , verbose : nil , &block ) # :yield: dir
138160 fu_output_message "cd #{ dir } " if verbose
@@ -146,11 +168,14 @@ def cd(dir, verbose: nil, &block) # :yield: dir
146168 module_function :chdir
147169
148170 #
149- # Returns true if +new+ is newer than all +old_list+.
150- # Non-existent files are older than any file.
171+ # Returns +true+ if the file at path +new+
172+ # is newer than all the files at paths in array +old_list+;
173+ # +false+ otherwise:
174+ #
175+ # FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true
176+ # FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false
151177 #
152- # FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
153- # system 'make hello.o'
178+ # A non-existent file is considered to be infinitely old.
154179 #
155180 def uptodate? ( new , old_list )
156181 return false unless File . exist? ( new )
@@ -170,12 +195,34 @@ def remove_trailing_slash(dir) #:nodoc:
170195 private_module_function :remove_trailing_slash
171196
172197 #
173- # Creates one or more directories.
198+ # Creates directories at the paths in the given +list+
199+ # (an array of strings or a single string);
200+ # returns +list+.
201+ #
202+ # With no keyword arguments, creates a directory at each +path+ in +list+
203+ # by calling: <tt>Dir.mkdir(path, mode)</tt>;
204+ # see {Dir.mkdir}[https://docs.ruby-lang.org/en/master/Dir.html#method-c-mkdir]:
205+ #
206+ # FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
207+ # FileUtils.mkdir('tmp4') # => ["tmp4"]
208+ #
209+ # Keyword arguments:
210+ #
211+ # - <tt>mode: <i>integer</i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
212+ # see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
213+ # - <tt>noop: true</tt> - does not create directories.
214+ # - <tt>verbose: true</tt> - prints an equivalent command:
215+ #
216+ # FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
217+ # FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
218+ #
219+ # Output:
220+ #
221+ # mkdir tmp0 tmp1
222+ # mkdir -m 700 tmp2 tmp3
174223 #
175- # FileUtils.mkdir 'test'
176- # FileUtils.mkdir %w(tmp data)
177- # FileUtils.mkdir 'notexist', noop: true # Does not really create.
178- # FileUtils.mkdir 'tmp', mode: 0700
224+ # Raises an exception if any path in +list+ points to an existing
225+ # file or directory, or if for any reason a directory cannot be created.
179226 #
180227 def mkdir ( list , mode : nil , noop : nil , verbose : nil )
181228 list = fu_list ( list )
0 commit comments