Skip to content

Commit

Permalink
Merge with docrails. Also add a rake task to generate guides in your …
Browse files Browse the repository at this point in the history
…rails application :

  rake doc:guides

The rake task will generate guides inside doc/guides directory of your application. Open index.html to browse.
  • Loading branch information
lifo committed Oct 21, 2008
1 parent 18542c9 commit a03e2b3
Show file tree
Hide file tree
Showing 130 changed files with 20,664 additions and 661 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ activerecord/doc
actionpack/doc
actionmailer/doc
activesupport/doc
railties/doc
activeresource/pkg
activerecord/pkg
actionpack/pkg
actionmailer/pkg
activesupport/pkg
railties/pkg
railties/test/500.html
railties/doc/guides/html/images
railties/doc/guides/html/stylesheets
*.rbc
12 changes: 6 additions & 6 deletions actionpack/lib/action_view/helpers/date_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,15 @@ def select_minute(datetime, options = {}, html_options = {})
# ==== Examples
# my_time = Time.now + 6.hours
#
# # Generates a select field for minutes that defaults to the minutes for the time in my_time
# select_minute(my_time)
# # Generates a select field for hours that defaults to the hour for the time in my_time
# select_hour(my_time)
#
# # Generates a select field for minutes that defaults to the number given
# select_minute(14)
# # Generates a select field for hours that defaults to the number given
# select_hour(13)
#
# # Generates a select field for minutes that defaults to the minutes for the time in my_time
# # Generates a select field for hours that defaults to the minutes for the time in my_time
# # that is named 'stride' rather than 'second'
# select_minute(my_time, :field_name => 'stride')
# select_hour(my_time, :field_name => 'stride')
#
def select_hour(datetime, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_hour
Expand Down
3 changes: 2 additions & 1 deletion activerecord/lib/active_record/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ module ClassMethods
# Adds one or more objects to the collection by setting their foreign keys to the collection's primary key.
# [collection.delete(object, ...)]
# Removes one or more objects from the collection by setting their foreign keys to +NULL+.
# This will also destroy the objects if they're declared as +belongs_to+ and dependent on this model.
# Objects will be in addition destroyed if they're associated with <tt>:dependent => :destroy</tt>,
# and deleted if they're associated with <tt>:dependent => :delete_all</tt>.
# [collection=objects]
# Replaces the collections content by deleting and adding objects as appropriate.
# [collection_singular_ids]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ def count(*args)
end


# Remove +records+ from this association. Does not destroy +records+.
# Removes +records+ from this association calling +before_remove+ and
# +after_remove+ callbacks.
#
# This method is abstract in the sense that +delete_records+ has to be
# provided by descendants. Note this method does not imply the records
# are actually removed from the database, that depends precisely on
# +delete_records+. They are in any case removed from the collection.
def delete(*records)
records = flatten_deeper(records)
records.each { |record| raise_on_type_mismatch(record) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def insert_record(record)
record.save
end

# Deletes the records according to the <tt>:dependent</tt> option.
def delete_records(records)
case @reflection.options[:dependent]
when :destroy
Expand Down
4 changes: 2 additions & 2 deletions activesupport/lib/active_support/multibyte/chars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def reverse
# character.
#
# Example:
# 'こにちわ'.mb_chars.slice(2..3).to_s #=> "ちわ"
# 'こんにちは'.mb_chars.slice(2..3).to_s #=> "にち"
def slice(*args)
if args.size > 2
raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" # Do as if we were native
Expand Down Expand Up @@ -676,4 +676,4 @@ def chars(string) #:nodoc:
end
end
end
end
end
89 changes: 41 additions & 48 deletions railties/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,57 +272,50 @@ Rake::RDocTask.new { |rdoc|
rdoc.rdoc_files.include('lib/commands/**/*.rb')
}

# In this array, one defines the guides for which HTML output should be
# generated. Specify the folder names of the guides. If the .txt filename
# doesn't equal its folder name, then specify a hash: { 'folder_name' => 'basename' }
guides = [
'getting_started_with_rails',
# 'testing_rails_applications',
'creating_plugins',
'actioncontroller',
'migrations',
{ 'securing_rails_applications' => 'security' },
{ 'routing' => 'routing_outside_in' },
{ 'forms' =>'form_helpers' },
{ 'activerecord' => 'association_basics' },
{ 'activerecord' => 'finders' },
{ 'debugging' => 'debugging_rails_applications' },
{ 'caching' => 'caching_with_rails' },
{ 'benchmarking_and_profiling' => 'preamble' },
{ 'actionview' => 'layouts_and_rendering' }
]

guides_html_files = [] # autogenerated from the 'guides' variable.
guides.each do |entry|
if entry.is_a?(Hash)
guide_folder = entry.keys.first
guide_name = entry.values.first
else
guide_folder = entry
guide_name = entry
end
input = "doc/guides/#{guide_folder}/#{guide_name}.txt"
output = "doc/guides/#{guide_folder}/#{guide_name}.html"
guides_html_files << output
task output => Dir["doc/guides/#{guide_folder}/*.txt"] do
ENV['MANUALSONRAILS_INDEX_URL'] = '../index.html'
ENV.delete('MANUALSONRAILS_TOC')
sh "mizuho", input, "--template", "manualsonrails", "--icons-dir", "../icons"
end
end
desc "Generate guides for the framework"
task :guides do
require 'mizuho/generator'

source = "doc/guides/source/"
html = "doc/guides/html/"
FileUtils.rm_r(html) if File.directory?(html)
FileUtils.mkdir(html)

template = File.expand_path("doc/guides/source/templates/guides.html.erb")
icons = File.expand_path("doc/guides/source/icons")

ignore = ['icons', 'images', 'templates', 'stylesheets']
ignore << 'active_record_basics.txt'

indexless = ['index.txt', 'authors.txt']

['index', 'authors'].each do |guide|
task "doc/guides/#{guide}.html" => "doc/guides/#{guide}.txt" do
ENV.delete('MANUALSONRAILS_INDEX_URL')
ENV['MANUALSONRAILS_TOC'] = 'no'
sh "mizuho", "doc/guides/#{guide}.txt", "--template", "manualsonrails", "--icons-dir", "icons"
Dir.entries(source)[2..-1].each do |entry|
next if ignore.include?(entry)

if File.directory?(File.join(source, entry))
input = File.join(source, entry, 'index.txt')
output = File.join(html, entry)
else
input = File.join(source, entry)
output = File.join(html, entry).sub(/\.txt$/, '')
end

begin
puts "GENERATING => #{output}"
ENV['MANUALSONRAILS_TOC'] = 'no' if indexless.include?(entry)
Mizuho::Generator.new(input, output, template, false, icons).start
rescue Mizuho::GenerationError
STDERR.puts "*** ERROR"
exit 2
ensure
ENV.delete('MANUALSONRAILS_TOC')
end
end
end

desc "Generate HTML output for the guides"
task :generate_guides => guides_html_files
task :generate_guides => 'doc/guides/index.html'
task :generate_guides => 'doc/guides/authors.html'
# Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
FileUtils.cp_r File.join(source, 'images'), File.join(html, 'images')
FileUtils.cp_r File.join(source, 'stylesheets'), File.join(html, 'stylesheets')
end

# Generate GEM ----------------------------------------------------------------------------

Expand Down
91 changes: 0 additions & 91 deletions railties/doc/guides/actionview/helpers.markdown

This file was deleted.

90 changes: 0 additions & 90 deletions railties/doc/guides/actionview/partials.markdown

This file was deleted.

Loading

0 comments on commit a03e2b3

Please sign in to comment.