doc/Rakefile in ruby-vpi-11.1.0 vs doc/Rakefile in ruby-vpi-11.1.1

- old
+ new

@@ -16,23 +16,48 @@ You should have received a copy of the GNU General Public License along with Ruby-VPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =end +$: << File.join(File.dirname(__FILE__), 'lib') + require 'rake/clean' +require 'doc_proxy' -FORMATS = { - # format => xsltproc flag - 'html' => 'xhtml', - 'text' => 'txt', -} +FileList['*.erb'].each do |src| + prefix = File.basename(src, '.erb') + helper = prefix + '.rb' + dst = prefix + '.html' -task :default => FORMATS.keys + desc "Process file #{src.inspect}." + file dst => [src, 'common.tpl'] do |t| + content = DocProxy.new.instance_eval do + # default output configuration + table_of_contents = true + page_title = nil -FORMATS.each_pair do |fmt, flag| - desc "Generate documentation in #{fmt} format." - task fmt => ['src/manual.xml', 'src/manual.xsl'] do |t| - sh %{xmlto #{flag} -m #{t.prerequisites[1]} #{t.prerequisites[0]}} + # load the documentation's helper + if File.exist? helper + instance_eval File.read(helper) + end + + # evaluate the documentation file + template = ERB.new(File.read(src)) + content = template.result(binding) + 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 + + puts "wrote #{dst.inspect}" end + + task :default => dst end -CLOBBER.include '*.html', '*.txt' +CLOBBER.include '*.html'