Permalink
Browse files

Added a rake task to generate docs/ from class documentation.

  • Loading branch information...
1 parent d14fb1f commit 97f2f90f0274383cbeae9d59f5995b23240a306d @gregbell gregbell committed Jul 7, 2011
View
@@ -22,6 +22,8 @@ group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'rake', '0.8.7', :require => false
gem 'haml', '~> 3.1.1', :require => false
+ gem 'yard'
+ gem 'rdiscount' # For yard
end
group :test do
View
@@ -11,37 +11,8 @@ end
require File.expand_path('../spec/support/detect_rails_version', __FILE__)
-namespace :test do
-
- desc "Run against the important versions of rails"
- task :major_rails_versions do
- current_version = detect_rails_version
- ["3.0.7", "3.1.0.rc4"].each do |version|
- puts
- puts
- puts "== Using Rails #{version}"
- cmd "./script/use_rails #{version}"
- cmd "bundle exec rspec spec"
- cmd "bundle exec cucumber features"
- end
- cmd "./script/use_rails #{current_version}"
- end
-
-end
-
-desc "Creates a test rails app for the specs to run against"
-task :setup do
- require 'rails/version'
- system("mkdir spec/rails") unless File.exists?("spec/rails")
- system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb"
-end
-
-require "rspec/core/rake_task"
-RSpec::Core::RakeTask.new(:spec)
-
-RSpec::Core::RakeTask.new(:rcov) do |spec|
- spec.rcov = true
-end
+# Import all our rake tasks
+FileList['tasks/**/*.rake'].each { |task| import task }
# Run the specs & cukes
task :default do
@@ -54,39 +25,3 @@ task :default do
cmd("export RAILS=3.0.5 && export RAILS_ENV=cucumber && bundle exec cucumber features"),
].uniq == [true]
end
-
-namespace :spec do
- desc "Run specs for all versions of rails"
- task :all do
- (0..6).to_a.each do |v|
- puts "Running for Rails 3.0.#{v}"
- cmd "rm Gemfile.lock" if File.exists?("Gemfile.lock")
- cmd "/usr/bin/env RAILS=3.0.#{v} bundle install"
- cmd "/usr/bin/env RAILS=3.0.#{v} rake spec"
- end
- end
-end
-
-require 'cucumber/rake/task'
-
-namespace :cucumber do
- Cucumber::Rake::Task.new(:all) do |t|
- t.profile = 'default'
- end
-
- Cucumber::Rake::Task.new(:wip) do |t|
- t.profile = 'wip'
- end
-end
-
-task :cucumber => "cucumber:all"
-
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "active_admin #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
View
@@ -6,123 +6,14 @@ you to build a compelling interface into your data for the admin staff.
Built in, Active Admin has the following index renderers:
-* *Table*: A table drawn with each row being a resource
-* *Grid*: A set of rows and columns each cell being a resource
-* *Blocks*: A set of rows (not tabular) each row being a resource
-* *Blog*: A title and body content, similar to a blog index
+* *Table*: A table drawn with each row being a resource ([View Table Docs](3-index-pages/index-as-table.md))
+* *Grid*: A set of rows and columns each cell being a resource ([View Grid Docs](3-index-pages/index-as-grid.md))
+* *Blocks*: A set of rows (not tabular) each row being a resource ([View Blocks Docs](3-index-pages/index-as-blocks.md))
+* *Blog*: A title and body content, similar to a blog index ([View Blog Docs](3-index-pages/index-as-blog.md))
All index pages also support scopes, filters, pagination, action items, and
sidebar sections.
-## Index as a Table
-
-By default, the index page is a table with each of the models content columns and links to
-show, edit and delete the object. There are many ways to customize what gets
-displayed.
-
-### Defining Columns
-
-To display an attribute or a method on a resource, simply pass a symbol into the
-column method:
-
- index do
- column :title
- end
-
-If the default title does not work for you, pass it as the first argument:
-
- index do
- column "My Custom Title", :title
- end
-
-Sometimes calling methods just isn't enough and you need to write some view
-specific code. For example, say we wanted a colum called Title which holds a
-link to the posts admin screen.
-
-The column method accepts a block as an argument which will then be rendered
-within the context of the view for each of the objects in the collection.
-
- index do
- column "Title" do |post|
- link_to post.title, admin_post_path(post)
- end
- end
-
-The block gets called once for each resource in the collection. The resource gets passed into
-the block as an argument.
-
-
-### Sorting
-
-When a column is generated from an Active Record attribute, the table is
-sortable by default. If you are creating a custom column, you may need to give
-Active Admin a hint for how to sort the table.
-
-If a column is defined using a block, you must pass the key to turn on sorting. The key
-is the attribute which gets used to sort objects using Active Record.
-
- index do
- column "Title", :sortable => :title do |post|
- link_to post.title, admin_post_path(post)
- end
- end
-
-You can turn off sorting on any column by passing false:
-
- index do
- column :title, :sortable => false
- end
-
-### Showing and Hiding Columns
-
-The entire index block is rendered within the context of the view, so you can
-easily do things that show or hide columns based on the current context.
-
-For example, if you were using CanCan:
-
- index do
- column :title, :sortable => false
- if can? :manage, Post
- column :some_secret_data
- end
- end
-
-## Index as a Grid
-
-Sometimes you want to display the index screen for a set of resources as a grid
-(possibly a grid of thumbnail images). To do so, use the :grid option for the
-index block.
-
- index :as => :grid do |product|
- link_to(image_tag(product.image_path), admin_products_path(product))
- end
-
-The block is rendered within a cell in the grid once for each resource in the
-collection. The resource is passed into the block for you to use in the view.
-
-You can customize the number of colums that are rendered using the columns
-option:
-
- index :as => :grid, :columns => 5 do |product|
- link_to(image_tag(product.image_path), admin_products_path(product))
- end
-
-
-## Index as a Block
-
-If you want to fully customize the display of your resources on the index
-screen, Index as a Block allows you to render a block of content for each
-resource.
-
- index :as => :block do |product|
- div :for => product do
- h2 auto_link(product.title)
- div do
- simple_format product.description
- end
- end
- end
-
## Index Filters
By default the index screen includes a "Filters" sidebar on the right hand side
@@ -0,0 +1,12 @@
+<!-- Please don't edit this file. It will be clobbered. -->
+
+Simplest rendering possible. Calls the block for each element in the collection.
+
+Example:
+
+ ActiveAdmin.register Post do
+ index :as => :block do |post|
+ # render the post partial (app/views/admin/posts/_post)
+ render 'post', :post => post
+ end
+ end
@@ -0,0 +1,2 @@
+<!-- Please don't edit this file. It will be clobbered. -->
+
@@ -0,0 +1,2 @@
+<!-- Please don't edit this file. It will be clobbered. -->
+
@@ -0,0 +1,74 @@
+<!-- Please don't edit this file. It will be clobbered. -->
+
+# Index as a Table
+
+By default, the index page is a table with each of the models content columns and links to
+show, edit and delete the object. There are many ways to customize what gets
+displayed.
+
+## Defining Columns
+
+To display an attribute or a method on a resource, simply pass a symbol into the
+column method:
+
+ index do
+ column :title
+ end
+
+If the default title does not work for you, pass it as the first argument:
+
+ index do
+ column "My Custom Title", :title
+ end
+
+Sometimes calling methods just isn't enough and you need to write some view
+specific code. For example, say we wanted a colum called Title which holds a
+link to the posts admin screen.
+
+The column method accepts a block as an argument which will then be rendered
+within the context of the view for each of the objects in the collection.
+
+ index do
+ column "Title" do |post|
+ link_to post.title, admin_post_path(post)
+ end
+ end
+
+The block gets called once for each resource in the collection. The resource gets passed into
+the block as an argument.
+
+
+## Sorting
+
+When a column is generated from an Active Record attribute, the table is
+sortable by default. If you are creating a custom column, you may need to give
+Active Admin a hint for how to sort the table.
+
+If a column is defined using a block, you must pass the key to turn on sorting. The key
+is the attribute which gets used to sort objects using Active Record.
+
+ index do
+ column "Title", :sortable => :title do |post|
+ link_to post.title, admin_post_path(post)
+ end
+ end
+
+You can turn off sorting on any column by passing false:
+
+ index do
+ column :title, :sortable => false
+ end
+
+## Showing and Hiding Columns
+
+The entire index block is rendered within the context of the view, so you can
+easily do things that show or hide columns based on the current context.
+
+For example, if you were using CanCan:
+
+ index do
+ column :title, :sortable => false
+ if can? :manage, Post
+ column :some_secret_data
+ end
+ end
@@ -1,16 +1,21 @@
module ActiveAdmin
module Views
- # Simplest rendering possible. Calls the block for each element in the collection.
+ # = Index as a Block
#
- # Example:
+ # If you want to fully customize the display of your resources on the index
+ # screen, Index as a Block allows you to render a block of content for each
+ # resource.
#
- # ActiveAdmin.register Post do
- # index :as => :block do |post|
- # # render the post partial (app/views/admin/posts/_post)
- # render 'post', :post => post
+ # index :as => :block do |product|
+ # div :for => product do
+ # h2 auto_link(product.title)
+ # div do
+ # simple_format product.description
+ # end
+ # end
# end
- # end
+ #
class IndexAsBlock < ActiveAdmin::Component
def build(page_config, collection)
@@ -1,6 +1,27 @@
module ActiveAdmin
module Views
- class IndexAsGrid < ActiveAdmin::Component
+
+ # = Index as a Grid
+ #
+ # Sometimes you want to display the index screen for a set of resources as a grid
+ # (possibly a grid of thumbnail images). To do so, use the :grid option for the
+ # index block.
+ #
+ # index :as => :grid do |product|
+ # link_to(image_tag(product.image_path), admin_products_path(product))
+ # end
+ #
+ # The block is rendered within a cell in the grid once for each resource in the
+ # collection. The resource is passed into the block for you to use in the view.
+ #
+ # You can customize the number of colums that are rendered using the columns
+ # option:
+ #
+ # index :as => :grid, :columns => 5 do |product|
+ # link_to(image_tag(product.image_path), admin_products_path(product))
+ # end
+ #
+ class IndexAsGrid < ActiveAdmin::Component
def build(page_config, collection)
@page_config = page_config
Oops, something went wrong.

0 comments on commit 97f2f90

Please sign in to comment.