diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2016-07-04 23:37:26 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2016-07-11 15:50:27 +0200 |
commit | 9e99649e7e525b6ee1d4901c89711c0b0693fe4f (patch) | |
tree | 501f8b4173c46a5e4333df177bccd3cd8e5f0df7 /railties/lib | |
parent | 1c7cbe8da62b3adef03328cea13bb25a2ff68643 (diff) | |
download | rails-9e99649e7e525b6ee1d4901c89711c0b0693fe4f.tar.gz rails-9e99649e7e525b6ee1d4901c89711c0b0693fe4f.tar.bz2 rails-9e99649e7e525b6ee1d4901c89711c0b0693fe4f.zip |
Speed up RDoc generation when it's already been done once
Only include files that contain changes since the last generation
of the API documentation.
Thus, only modified files are re-generated instead of the whole API.
The `created.rid` file won't contain the whole list of files anymore
if we generate several times the API but we don't really care about it,
only the generation date and time is important.
It is possible to fall back to the previous behavior by defining the ALL
environment variable running the `rake rdoc` task.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/api/task.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/lib/rails/api/task.rb b/railties/lib/rails/api/task.rb index d478bbf9e8..5bcc33faeb 100644 --- a/railties/lib/rails/api/task.rb +++ b/railties/lib/rails/api/task.rb @@ -121,6 +121,19 @@ module Rails rdoc_files.exclude("#{cdr}/#{pattern}") end end + + # Only generate documentation for files that have been + # changed since the API was generated. + if Dir.exist?('doc/rdoc') && !ENV['ALL'] + last_generation = DateTime.rfc2822(File.open('doc/rdoc/created.rid', &:readline)) + + rdoc_files.keep_if do |file| + File.mtime(file).to_datetime > last_generation + end + + # Nothing to do + exit(0) if rdoc_files.empty? + end end def setup_horo_variables |