lib/jazzy/docset_builder.rb in jazzy-0.0.20 vs lib/jazzy/docset_builder.rb in jazzy-0.1.0

- old
+ new

@@ -6,24 +6,28 @@ # Follows the instructions found at http://kapeli.com/docsets#dashDocset. class DocsetBuilder include Config::Mixin attr_reader :output_dir + attr_reader :generated_docs_dir attr_reader :source_module attr_reader :docset_dir attr_reader :documents_dir - def initialize(output_dir, source_module) - @output_dir = output_dir + 'docsets' + def initialize(generated_docs_dir, source_module) @source_module = source_module - @docset_dir = @output_dir + "#{source_module.name}.docset" + @docset_dir = generated_docs_dir + + (config.docset_path || "docsets/#{source_module.name}.docset") + @generated_docs_dir = generated_docs_dir + @output_dir = docset_dir.parent @documents_dir = docset_dir + 'Contents/Resources/Documents/' end def build! docset_dir.rmtree if docset_dir.exist? copy_docs + copy_icon if config.docset_icon write_plist create_index create_archive create_xml if config.version && config.root_url end @@ -52,13 +56,18 @@ } system('tar', "--exclude='.DS_Store'", '-cvzf', target, source, options) end def copy_docs - files_to_copy = Dir.glob(output_dir + '../**/*') + files_to_copy = Pathname.glob(generated_docs_dir + '**/*') - + [docset_dir, output_dir] FileUtils.mkdir_p documents_dir FileUtils.cp_r files_to_copy, documents_dir + end + + def copy_icon + FileUtils.cp config.docset_icon, @docset_dir + 'icon.png' end def create_index search_index_path = docset_dir + 'Contents/Resources/docSet.dsidx' SQLite3::Database.new(search_index_path.to_s) do |db|