lib/rapidoc/templates_generator.rb in rapidoc-0.0.6 vs lib/rapidoc/templates_generator.rb in rapidoc-0.0.7
- old
+ new
@@ -6,11 +6,10 @@
module TemplatesGenerator
def generate_index_template( resources_doc )
template = get_index_template
result = template.call( :info => rapidoc_config, :resources => resources_doc )
-
File.open( target_dir("index.html"), 'w' ) { |file| file.write result }
end
def get_index_template
template = IO.read( gem_templates_dir('index.html.hbs') )
@@ -51,10 +50,17 @@
end
end
def create_action_template( template, action_doc )
result = template.call( :info => rapidoc_config, :action => action_doc )
- File.open( actions_dir("#{action_doc.file}.html"), 'w' ) { |file| file.write result }
+ resource = action_doc.resource.split('/').last
+ action = action_doc.action
+ dir_name = File.dirname(actions_dir("#{resource}"))
+ dir_name += "/#{resource}"
+ unless File.directory?(dir_name)
+ FileUtils.mkdir_p(dir_name)
+ end
+ File.open( actions_dir("#{resource}/#{action}.html"), 'w' ) { |file| file.write result }
end
def get_action_template
template = IO.read( gem_templates_dir('action.html.hbs') )
handlebars = Handlebars::Context.new