tasks/gh-pages.rake in alf-0.10.1 vs tasks/gh-pages.rake in alf-0.11.0

- old
+ new

@@ -1,5 +1,11 @@ +module Alf + def self.markdown(md) + Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(md) + end +end + task :"gh-pages" do require 'fileutils' require 'wlang' require 'wlang/ext/hash_methodize' require 'alf' @@ -8,13 +14,12 @@ indir = File.expand_path('../../doc/gh-pages', __FILE__) outdir = File.expand_path('../../doc/deploy-gh-pages', __FILE__) # Remove everything - Dir[File.join(outdir, '*')].each do |f| - FileUtils.rm_rf f - end + FileUtils.rm_rf outdir + FileUtils.mkdir_p outdir # copy assets FileUtils.cp_r File.join(indir, "no-analytics.html"), outdir FileUtils.cp_r File.join(indir, "index.html"), outdir FileUtils.cp_r File.join(indir, "css"), outdir @@ -24,20 +29,20 @@ html = File.join(indir, 'templates', "html.wtpl") context = { :version => Alf::VERSION, :outdir => outdir, - :main => Alf::Command::Main + :main => Alf::Shell::Main } static = lambda{|entry| FileUtils.mkdir File.join(outdir, entry) ctx = context.merge(:prefix => "..", :entry => entry.to_sym) Dir[File.join(indir, entry, '*.md')].each do |file| md = File.read(file) title = md.split("\n").first[3..-1].gsub("&mdash;", "-") - text = Redcarpet.new(md).to_html + text = Alf.markdown(md) target = File.join(outdir, entry, "#{File.basename(file, ".md")}.html") File.open(target, "w") do |io| ctx2 = ctx.merge(:text => text, :title => title) io << WLang.file_instantiate(html, ctx2) end @@ -47,10 +52,10 @@ ["overview", "shell", "ruby", "devel", "use-cases"].each do |f| static.call(f) end ["shell", "ruby"].each do |entry| - Alf::Command::Main.subcommands.each do |sub| + Alf::Shell::Main.subcommands.each do |sub| ctx = context.merge(:prefix => "..", :entry => entry.to_sym) target = File.join(outdir, entry, "#{sub.command_name}.html") File.open(target, "w") do |io| ctx2 = ctx.merge(:operator => sub, :title => "Alf in #{entry.capitalize}: #{sub.command_name}")