From: Joel VanderWerf on
Here's another version:

task "tasks" do
Rake::Task.tasks.each do | tsk |
next if tsk.name =~ /:/ or not tsk.full_comment
printf "rake %-19s# %s\n", tsk.name, tsk.full_comment
end
end

namespace "tasks" do
rule /.*/ do |t|
pats = t.name.split(":")[1..-1].map {|pat| Regexp.new("\\A#{pat}\\z")}
Rake::Task.tasks.each do | tsk |
next unless tsk.full_comment
parts = tsk.name.split(":")
next unless parts.size <= pats.size + 1
next unless pats.zip(parts).all? {|pat, part| pat === part}
printf "rake %-19s# %s\n", tsk.name, tsk.full_comment
end
end
end

Use it like this:

$ rake tasks # show all top level tasks
$ rake tasks:internals # show all tasks in "internals" namespace
$ rake tasks:internals:'build.*' # show all tasks in "internals"
namespace whose name begins with build

It probably still needs some tinkering...