lib/inochi/tasks/3-man.rake in inochi-4.0.1 vs lib/inochi/tasks/3-man.rake in inochi-5.0.0
- old
+ new
@@ -1,72 +1,74 @@
-@man_src = FileList['MANUAL', '[A-Z]*[A-Z]']
+@man_asciidoc_src = FileList['MANUAL', '[A-Z]*[A-Z]']
+@man_asciidoc_dst = 'man.txt'
+
@man_html_dst = 'man.html'
-@man_ronn_dst = 'man.ronn'
-@man_roff_dst_glob = 'man/man*/*.?{,.gz}'
+@man_roff_dst = "man/man1/#{@project_package_name}.1"
desc 'Build the help manual.'
-task :man => @man_html_dst
+task :man => [@man_html_dst, @man_roff_dst]
-file @man_html_dst => @man_src do
- Rake::Task[:@man_doc].invoke
+#-----------------------------------------------------------------------------
- # write ronn version
+# Run manual through Ember to produce a single input file for AsciiDoc.
+file @man_asciidoc_dst => @man_asciidoc_src do
- # write roff version
- roff_file = "man/man#{@man_doc.section}/#{@man_doc.basename}"
- mkdir_p File.dirname(roff_file)
+ input = [
+ ":revdate: #{@project_module::RELDATE}",
+ ":revnumber: #{@project_module::VERSION}",
+ "= #{@project_package_name}(1)",
+ '== NAME',
+ "#{@project_package_name} - #{@project_module::TAGLINE}",
+ "%+ #{@man_asciidoc_src.first.inspect}",
+ ].join("\n\n")
- require 'zlib'
- Zlib::GzipWriter.open(roff_file + '.gz') do |gz|
- gz.write @man_doc.to_roff
- end
+ options = {
+ :shorthand => true,
+ :unindent => true,
+ :infer_end => true
+ }
- # write html version
- File.write @man_html_dst, @man_doc.to_html
+ require 'ember'
+ output = Ember::Template.new(input, options).render
+
+ File.write @man_asciidoc_dst, output
end
-CLOBBER.include @man_html_dst, @man_ronn_dst, @man_roff_dst_glob
+CLEAN.include @man_asciidoc_dst
-# loads the manual as a Ronn document
-task :@man_doc => @man_src do
- unless @man_doc
- Rake::Task[:@project].invoke
+#-----------------------------------------------------------------------------
- # render eRuby template
- ember_input =
- "# #{@project_package_name}(1) - #{@project_module::TAGLINE}\n\n"\
- "%+ #{@man_src.first.inspect}"
+build_asciidoc_args = lambda do
+ [('-v' if Rake.application.options.trace), @man_asciidoc_dst].compact
+end
- ember_opts = {
- :source_file => :@man_doc,
- :shorthand => true,
- :unindent => true,
- :infer_end => true,
- }
+file @man_html_dst => @man_asciidoc_dst do
+ atts = %W[data-uri toc stylesheet=#{__FILE__}.css] +
+ Array(@project_config[:man_asciidoc_attributes])
- require 'ember'
- ronn_input = Ember::Template.new(ember_input, ember_opts).render
- File.write @man_ronn_dst, ronn_input # for debugging / sanity check
+ opts = atts.map {|a| ['-a', a] }.flatten
+ args = opts + build_asciidoc_args.call
- # build Ronn document
- require 'date'
- ronn_opts = {
- :date => Date.parse(@project_module::RELDATE),
- :manual => "Version #{@project_module::VERSION}",
- :styles => %w[ man toc 80c ]
- }
- ronn_file = "#{@project_package_name}.1.ronn"
+ sh 'asciidoc', '-o', @man_html_dst, *args
+end
- require 'ronn'
- @man_doc = Ronn::Document.new(ronn_file, ronn_opts) { ronn_input }
- end
+CLOBBER.include @man_html_dst
+
+file @man_roff_dst => @man_asciidoc_dst do
+ args = build_asciidoc_args.call
+ mkdir_p dir = File.dirname(@man_roff_dst)
+ sh 'a2x', '-f', 'manpage', '-D', dir, *args
end
+CLOBBER.include @man_roff_dst
+
+#-----------------------------------------------------------------------------
+
task :@man_html do
unless @man_html
- Rake::Task[:@man_doc].invoke
- @man_html = @man_doc.to_html
+ Rake::Task[@man_html_dst].invoke
+ @man_html = File.read(@man_html_dst)
end
end
task :@man_html_dom do
unless @man_html_dom
@@ -74,6 +76,5 @@
require 'nokogiri'
@man_html_dom = Nokogiri::HTML(@man_html)
end
end
-