Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit e217054f9de2eaa25992ebfdf0a35dca4faddd6c @lsegal committed Dec 30, 2010
Showing with 173 additions and 0 deletions.
  1. +74 −0 example/Rakefile
  2. +70 −0 lib/yard-rake.rb
  3. +17 −0 templates/default/layout/html/rake_tasks.erb
  4. +12 −0 templates/default/layout/html/setup.rb
@@ -0,0 +1,74 @@
+$:.unshift(File.dirname(__FILE__))
+$:.unshift(File.dirname(__FILE__) + '/lib')
+$:.unshift(File.dirname(__FILE__) + '/yard/lib')
+require 'yard'
+
+task :default => 'gems:update'
+
+namespace :server do
+ desc 'Start the server'
+ task :start do
+ sh "unicorn -E production -D -c unicorn.conf.rb"
+ end
+
+ desc 'Restart the server'
+ task :restart do
+ sh "kill -USR2 `cat tmp/pids/unicorn.pid`"
+ end
+
+ desc 'Shut down the server'
+ task :stop do
+ sh "kill -QUIT `cat tmp/pids/unicorn.pid`"
+ end
+end
+
+namespace :gems do
+ desc 'Update gem list from Rubygems.org'
+ task 'update' do
+ puts ">> Updating Remote Gems file (local cache)"
+ load('scripts/update_remote_gems.rb')
+ end
+end
+
+namespace :docs do
+ desc 'Clean up old docs to conserve space'
+ task :clean do
+ puts ">> Removing outdated doc directories"
+ load('scripts/clean_docs.rb')
+ end
+
+ desc 'Reset docs'
+ task :reset => :clean do
+ stuff_here
+ end
+end
+
+namespace :repos do
+ desc 'Cleana up the cached gem sources and repositories'
+ task :clean do
+ puts ">> Removing cached gem sources and repositories"
+ load('scripts/clean_repos.rb')
+ end
+end
+
+namespace :cache do
+ desc 'Clean index cache pages (github, gems, featured)'
+ task :clean_index do
+ puts '>> Removing index cache pages'
+ load('scripts/clean_index_cache.rb')
+ end
+end
+
+namespace :stdlib do
+ namespace :foo do
+ desc "Do stuff"
+ task :do_stuff do
+ end
+ end
+
+ desc 'Installs a standard library PATH=pathtolib VERSION=targetversion'
+ task :install do
+ require 'stdlib_installer'
+ StdlibInstaller.new(ENV['PATH'], ENV['VERSION']).install
+ end
+end
@@ -0,0 +1,70 @@
+module YARD
+ Tags::Library.define_tag "Task Dependencies", :task_deps
+ Tags::Library.visible_tags << :task_deps
+ Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
+
+ module CodeObjects
+ module Rake
+ class NamespaceObject < CodeObjects::NamespaceObject
+ PREFIX = "!rake:"
+ alias tasks children
+ def path; parent == Registry.root ? "#{PREFIX}#{name}" : super end
+ def full_path; path.sub(/^#{PREFIX}/, '') end
+ def type; :rake_namespace end
+ def sep; ':' end
+ end
+
+ class TaskObject < CodeObjects::Base
+ def type; :rake_task end
+ def full_path; path.sub(/^#{NamespaceObject::PREFIX}/, '') end
+ def sep; ':' end
+ end
+ end
+ end
+
+ module Handlers
+ class Processor; attr_accessor :desc_comments end
+
+ module Rake
+ class Base < Ruby::Base; namespace_only; in_file "Rakefile" end
+
+ class NamespaceHandler < Base
+ handles method_call(:namespace)
+
+ process do
+ name = statement.parameters[0].jump(:ident, :tstring_content).source
+ obj = CodeObjects::Rake::NamespaceObject.new(namespace, name)
+ register(obj)
+ parse_block(statement.last.last, namespace: obj)
+ end
+ end
+
+ class DescHandler < Base
+ handles method_call(:desc)
+
+ process do
+ parser.desc_comments =
+ statement.parameters[0].jump(:tstring_content).source
+ end
+ end
+
+ class TaskHandler < Base
+ handles method_call(:task)
+
+ process do
+ arg = statement.parameters[0][0]
+ name = arg.jump(:ident, :tstring_content).source
+ deps = arg.type == :assoc ? arg[1].source : nil
+ obj = CodeObjects::Rake::TaskObject.new(namespace, name)
+ register(obj)
+
+ if parser.desc_comments && obj.docstring.blank?
+ obj.docstring += parser.desc_comments
+ end
+ obj.docstring.add_tag Tags::Tag.new(:task_deps, deps) if deps
+ parser.desc_comments = nil
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,17 @@
+<h2>Rake Tasks</h2>
+<style>
+.rake_tasks { width: 800px; }
+.rake_tasks th, .take_tasks td { text-align: left; }
+</style>
+<table class="rake_tasks">
+ <% @tasks.each do |task| %>
+ <tr>
+ <th><tt><%= task.full_path %></tt></th>
+ <% if task.full_path == 'default' %>
+ <th><%= task.tag(:task_deps).text %></th>
+ <% else %>
+ <td><%= task.docstring %></td>
+ <% end %>
+ </tr>
+ <% end %>
+</table>
@@ -0,0 +1,12 @@
+def init
+ super
+ p sections
+ sections.place(:rake_tasks).after_any(:alpha)
+end
+
+def rake_tasks
+ @tasks = Registry.all(:rake_task)
+ return if @tasks.empty?
+ @tasks = @tasks.sort_by {|t| t.full_path == 'default' ? '_' : t.full_path }
+ erb(:rake_tasks)
+end

0 comments on commit e217054

Please sign in to comment.