我有一个 Rakefile 用于从 markdown 生成 HTML(并做一些与问题无关的其他事情。
我正在从我的源文件 .feature 文件(在 FileList 中)生成文件作为 HTMLDOCUMENTS
到我的输出目录中。OUTPUT
我有一种htmlfile
方法来组装和编写我的 HTML 文件。
我在这里尝试两种替代方案:
文件任务:
DOCUMENTS.each do |doc|
file doc.pathmap("#{OUTPUT}/%X.html") => doc do |t|
htmlfile t.name, RDiscount.new(F.read doc).to_html, t.name.pathmap('%n')
end
end
具有规则的合成文件任务:
rule '.html' => proc {|html| html.pathmap("%{#{OUTPUT}/,}X.feature")} do |t|
htmlfile t.name, RDiscount.new(F.read t.source).to_html, t.name.pathmap('%n')
end
我的理解是后一个选项会合成文件任务,并具有相同的净效果。但是我发现,如果我选择它,它就不能处理增量构建,而第一个选项可以。
如果我构建,然后修改一个文件,然后运行 rake --trace 我得到以下信息:
使用合成任务:
** Invoke output/Module/Feature.html (first_time, not_needed)
** Invoke output/Module (not_needed)
并使用显式文件任务:
** Invoke output/Module/Feature.html (first_time)
** Invoke output/Module (not_needed)
** Invoke Module/Feature.feature (first_time, not_needed)
** Execute output/Module/Feature.html
这个选项显然是在检查源文件。我认为链接输出和源代码正是什么规则