From 44287477cc90ad122fec43f2ea6a4df89bda7e6d Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Mon, 12 Jan 2009 09:00:42 -0600 Subject: [PATCH] Updated Rakefile to check for presence of PDoc before running 'doc' task. --- Rakefile | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Rakefile b/Rakefile index cceaaa3..cbaee1d 100755 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,7 @@ require 'rake/packagetask' PROTOTYPE_ROOT = File.expand_path(File.dirname(__FILE__)) PROTOTYPE_SRC_DIR = File.join(PROTOTYPE_ROOT, 'src') PROTOTYPE_DIST_DIR = File.join(PROTOTYPE_ROOT, 'dist') +PROTOTYPE_DOC_DIR = File.join(PROTOTYPE_ROOT, 'doc') PROTOTYPE_PKG_DIR = File.join(PROTOTYPE_ROOT, 'pkg') PROTOTYPE_TEST_DIR = File.join(PROTOTYPE_ROOT, 'test') PROTOTYPE_TEST_UNIT_DIR = File.join(PROTOTYPE_TEST_DIR, 'unit') @@ -24,21 +25,35 @@ task :dist do end end -desc "Builds the documentation." -task :doc do - require 'protodoc' - require 'pdoc' - require 'tempfile' +namespace :doc do + desc "Builds the documentation." + task :build => [:require] do + require 'protodoc' + require 'tempfile' - Tempfile.open("prototype-doc") do |temp| - source = File.join(PROTOTYPE_SRC_DIR, 'prototype.js') - temp << Protodoc::Preprocessor.new(source, :strip_documentation => false) - temp.flush - rm_rf PROTOTYPE_DOC_DIR - PDoc::Runner.new(temp.path, :output => PROTOTYPE_DOC_DIR).run + Tempfile.open("prototype-doc") do |temp| + source = File.join(PROTOTYPE_SRC_DIR, 'prototype.js') + temp << Protodoc::Preprocessor.new(source, :strip_documentation => false) + temp.flush + rm_rf PROTOTYPE_DOC_DIR + PDoc::Runner.new(temp.path, :output => PROTOTYPE_DOC_DIR).run + end + end + + task :require do + lib = 'vendor/pdoc/lib/pdoc' + unless File.exists?(lib) + puts "\nYou'll need PDoc to generate the documentation. Just run:\n\n" + puts " $ git submodule init" + puts " $ git submodule update" + puts "\nand you should be all set.\n\n" + end + require lib end end +task :doc => ['doc:build'] + desc "Builds the updating helper." task :dist_helper do require 'protodoc'