]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rake: yarn doc task
authorMatthias H <apoc@sixserv.org>
Mon, 9 Mar 2015 04:00:59 +0000 (05:00 +0100)
committerMatthias H <apoc@sixserv.org>
Mon, 9 Mar 2015 04:00:59 +0000 (05:00 +0100)
Rakefile
docgen [deleted file]
tasks/doc.rake [new file with mode: 0644]

index 7bf643e3e8b7a6c13d8d8731774b05a69d5de7b0..1bd782eab2fe61a751779bea05815ccf3526cc2f 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,5 @@
 require 'rake'
-require 'rake/gempackagetask'
+require 'rubygems/package_task'
 
 task :default => [:buildext]
 
@@ -15,7 +15,7 @@ SPECFILE = 'rbot.gemspec'
 # we must (and can) skip defining the gem packaging tasks.
 if File.exist? SPECFILE
   spec = eval(File.read(SPECFILE), nil, SPECFILE)
-  Rake::GemPackageTask.new(spec) do |pkg|
+  Gem::PackageTask.new(spec) do |pkg|
     pkg.need_zip = true
     pkg.need_tar = true
   end
diff --git a/docgen b/docgen
deleted file mode 100755 (executable)
index 5bb8ae2..0000000
--- a/docgen
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-rm -rf doc
-rdoc -a -i 'lib' --exclude 'post-install.rb' --main README.rdoc --title "rbot - The Ruby IRC bot" -o doc lib bin/rbot README.rdoc
-
diff --git a/tasks/doc.rake b/tasks/doc.rake
new file mode 100644 (file)
index 0000000..b39f8c6
--- /dev/null
@@ -0,0 +1,31 @@
+desc "Generate RDoc"
+task :doc => ['doc:generate']
+
+namespace :doc do
+  project_root = File.expand_path(File.join(File.dirname(__FILE__), '.'))
+  doc_destination = File.join(project_root, 'doc')
+
+  begin
+    require 'yard'
+    require 'yard/rake/yardoc_task'
+
+    YARD::Rake::YardocTask.new(:generate) do |yt|
+      yt.files   = Dir.glob(File.join(project_root, 'lib', '**', '*.rb'))
+# + 
+#                   [ File.join(project_root, 'README.md') ]
+      yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
+    end
+  rescue LoadError
+    desc "Generate YARD Documentation"
+    task :generate do
+      abort "Please install the YARD gem to generate rdoc."
+    end
+  end
+
+  desc "Remove generated documenation"
+  task :clean do
+    rm_r doc_dir if File.exists?(doc_destination)
+  end
+
+end
+