[issue-1275] add rake task to generate docs, similar to sinatra-contrib

This commit is contained in:
Yuva 2017-04-09 12:30:24 +05:30
parent 8fdd35c731
commit 54276c2b14
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,4 @@
# please add general patterns to your global ignore list
# see https://github.com/github/gitignore#readme
Gemfile.lock
doc/

View File

@ -11,6 +11,25 @@ end
desc "run specs"
task(:spec) { ruby '-S rspec spec' }
namespace :doc do
task :readmes do
Dir.glob 'lib/rack/protection/*.rb' do |file|
excluded_files = %w[lib/rack/protection/base.rb lib/rack/protection/version.rb]
next if excluded_files.include?(file)
doc = File.read(file)[/^ module Protection(\n)+( #[^\n]*\n)*/m].scan(/^ *#(?!#) ?(.*)\n/).join("\n")
file = "doc/#{file[4..-4].tr("/_", "-")}.rdoc"
Dir.mkdir "doc" unless File.directory? "doc"
puts "writing #{file}"
File.open(file, "w") { |f| f << doc }
end
end
task :all => [:readmes]
end
desc "generate documentation"
task :doc => 'doc:all'
desc "generate gemspec"
task 'rack-protection.gemspec' do
require 'rack/protection/version'