27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/spacedocs.rb', line 27
def doc(file_path, output_dir)
tilt_path = File.dirname(__FILE__)
json = `#{File.join tilt_path, 'node_modules/dox/bin/dox'} < #{file_path}`
doc_json = JSON.parse json
processed_data = process_data doc_json
template = Tilt.new(File.join tilt_path, "class.html.haml")
index_template = Tilt.new(File.join tilt_path, "index.html.haml")
files = {}
class_data = processed_data[:docs_data]
class_data.each_key do |namespace|
files[namespace] = true
end
FileUtils.rm_rf output_dir
FileUtils.mkdir_p output_dir
File.open(File.join(output_dir, "index.html"), 'w') do |f|
f.write(index_template.render self, {
class_names: files.keys,
})
end
files.each_key do |file_name|
methods = class_data[file_name]['methods']
File.open(File.join(output_dir, "#{file_name}.html"), 'w') do |f|
f.write(template.render self, {
class_name: file_name,
method_list: methods.keys,
methods: methods,
class_names: files.keys,
class_summary: class_data[file_name]['summary'],
})
end
end
end
|