Sha256: 5c6ff3ede6a3fd2817c494af4d6bec7d6a88156d84430bd347759d1ee1b521c7

Contents?: true

Size: 1.93 KB

Versions: 4

Compression:

Stored size: 1.93 KB

Contents

# Generates the documentation in HTML format.
#--
# Copyright 2006 Suraj N. Kurapati
# See the file named LICENSE for details.

require 'rake/clean'


$: << File.join(File.dirname(__FILE__), '..', 'lib')
require 'ruby-vpi'
include RubyVPI

HISTORY_URL = WEBSITE_URL + "/history.html"
RSS_URL = WEBSITE_URL + '/rss.xml'
RSS_INFO = "RSS feed for this project."

require 'ruby-vpi/erb'
include ERB::Util


$: << File.join(File.dirname(__FILE__), 'lib')
require 'doc_proxy'


def resolve_includes aFilePath
  input = File.read(aFilePath)

  input.gsub! %r{<doc_proxy_include *(.*?)>} do
    resolve_includes($1)
  end

  input
end


FileList['*.doc'].each do |src|
  prefix = File.basename(src, File.extname(src))
  helper = prefix + '.rb'
  dst = prefix + '.html'
  deps = FileList[prefix + '*'].exclude(src, dst)

  desc "Process file #{src.inspect}."
  file dst => [src, 'common.tpl', *deps] do |t|
    puts src

    content = DocProxy.new.instance_eval do
      # default output configuration
      insert_toc = true
      page_title = nil

      # load the documentation's helper
        if File.exist? helper
          instance_eval File.read(helper)
        end

      # evaluate the documentation file
        input = resolve_includes(src)
        File.open('input', 'w') {|f| f << input} if $DEBUG

        template = ERB.new(input)
        content = template.result(binding)
        toc, content = post_process(content)


      # fit result into common HTML format
        template = ERB.new(File.read(t.prerequisites[1]))
        template.result(binding)
    end

    File.open(dst, 'w') do |f|
      f << content
    end
  end

  task :default => dst
  CLOBBER.include dst
end


desc "Generate RSS feed."
file 'rss.xml' => FileList['rss.erb', 'history*'] do |t|
  template = ERB.new(File.read(t.prerequisites[0]))
  content = template.result

  File.open(t.name, 'w') do |f|
    f << content
    puts f.path
  end
end

task :default => 'rss.xml'
CLOBBER.include 'rss.xml'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-vpi-17.0.0 doc/Rakefile
ruby-vpi-18.0.0 doc/Rakefile
ruby-vpi-18.0.2 doc/Rakefile
ruby-vpi-18.0.1 doc/Rakefile