20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/sassdoc.rb', line 20
def self.init(read, options)
pwd = FileUtils.pwd()
json = self.parse(ARGV[0] || '.').to_json
if options[:stdout]
puts json
else
Dir.chdir(pwd)
@json_filename = 'sassdoc.json'
dir = options[:destination]
FileUtils.mkdir_p dir
json_file = File.join(dir, @json_filename)
FileUtils.touch json_file
File.open(json_file, "w") {|file| file.puts json}
if options[:viewer]
FileUtils.cp_r(File.join(File.dirname(__FILE__), '..', 'viewer', '.'), dir)
settings = {}
settings[:viewer] = options[:scm] if options[:scm]
settings[:docs] = @json_filename
settings = settings.to_json
%w(index.html tmpl/view.tmpl).each do |src|
src = File.join(dir, src)
text = File.read(src)
File.open(src, "w") {|file| file.puts text.gsub(/\{SASSDOC_TITLE\}/, options[:name]).gsub(/\{SASSDOC_SETTINGS\}/, settings)}
end
end
end
end
|