Simplify README generator

This commit is contained in:
Dave Syer
2014-10-14 13:05:01 +01:00
parent 0e6c7a63de
commit 3cd1e6784e
2 changed files with 15 additions and 58 deletions

View File

@@ -2,11 +2,11 @@
base_dir = File.join(File.dirname(__FILE__),'../../..')
src_dir = File.join(base_dir, "/src/main/asciidoc")
require File.join(File.dirname(__FILE__), 'readme.rb')
require 'asciidoctor'
require 'optparse'
options = {}
input = "#{src_dir}/README.adoc"
file = "#{src_dir}/README.adoc"
OptionParser.new do |o|
o.on('-o OUTPUT_FILE', 'Output file (default is stdout)') { |file| options[:to_file] = file unless file=='-' }
@@ -14,6 +14,17 @@ OptionParser.new do |o|
o.parse!
end
input = ARGV[0] if ARGV.length>0
file = ARGV[0] if ARGV.length>0
SpringCloud::Build.render_file(input, options)
srcDir = File.dirname(file)
out = "// Do not edit this file (e.g. go instead to src/main/asciidoc)\n\n"
doc = Asciidoctor.load_file file, safe: :safe, parse: false
out << doc.reader.read
unless options[:to_file]
puts out
else
File.open(options[:to_file],'w+') do |file|
file.write(out)
end
end