Title / Description
Code From 08d1046812fda3e5073c56a15b695f55abaa3a07 Mon Sep 17 00:00:00 2001 From: Quintus <quintus@quintilianus.eu> Date: Mon, 16 Dec 2013 11:40:05 +0100 Subject: [PATCH] Add a Rake task for documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RDoc doesn’t like DLL_LOCAL currently, so remove it while generating the documentation. --- Rakefile | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 931b9c2..984a3ed 100644 --- a/Rakefile +++ b/Rakefile @@ -3,11 +3,19 @@ gem "rdoc" require "rake" require "rake/clean" require "rubygems/package_task" +require "rdoc/task" -require 'rake/extensiontask' rescue nil +begin + require 'rake/extensiontask' +rescue LoadError +end ENV["RDOCOPT"] = "" if ENV["RDOCOPT"] -CLOBBER.include("doc") +TMPSRCDIR = "tmpsrc" + +CLEAN.include(TMPSRCDIR) +CLOBBER.include("rdoc") + load "rwx.gemspec" @@ -39,4 +47,39 @@ else t.cross_compile = true # enable cross compilation (requires cross compile toolchain) t.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one end -end \ No newline at end of file +end + +RDoc::Task.new do |rdoc| + rdoc.title = "rwx RDocs" + rdoc.main = "README.rdoc" + rdoc.rdoc_files.include("*.rdoc", TMPSRCDIR) + rdoc.rdoc_dir = "rdoc" + + # We will have another 'rdoc' task that depends on this task + rdoc.name = :docs +end + +# This task removes the DLL_LOCAL statements temporarily to +# make RDoc work properly. The stripped sources are to be +# found in TMPSRCDIR afterwards. +task :prepare_sources do + rm_r "tmpsrc" if File.directory?(TMPSRCDIR) + + cp_r "ext", TMPSRCDIR + + Dir["#{TMPSRCDIR}/*.cpp", "#{TMPSRCDIR}/*.hpp"].each do |path| + puts "Removing DLL_LOCAL in #{path}" + + str = File.read(path) + str.gsub!(/DLL_LOCAL\s?/, "") + File.open(path, "w"){|file| file.write(str)} + end +end + +# Removes the temporary directory created by :prepare_sources. +task :clean_sources do + rm_r TMPSRCDIR +end + +desc "Generate the RDoc documentation." +task :rdoc => [:prepare_sources, :docs, :clean_sources] -- 1.8.5.1
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code