lib/jazzy/docset_builder.rb in jazzy-0.0.16 vs lib/jazzy/docset_builder.rb in jazzy-0.0.17

- old
+ new

@@ -11,22 +11,23 @@ attr_reader :source_module attr_reader :docset_dir attr_reader :documents_dir def initialize(output_dir, source_module) - @output_dir = output_dir + @output_dir = output_dir + 'docsets' @source_module = source_module - @docset_dir = output_dir + "#{source_module.name}.docset" + @docset_dir = @output_dir + "#{source_module.name}.docset" @documents_dir = docset_dir + 'Contents/Resources/Documents/' end def build! docset_dir.rmtree if docset_dir.exist? copy_docs write_plist create_index create_archive + create_xml if config.version && config.root_url end private def write_plist @@ -51,11 +52,11 @@ } system('tar', "--exclude='.DS_Store'", '-cvzf', target, source, options) end def copy_docs - files_to_copy = Dir.glob(output_dir + '**/*') + files_to_copy = Dir.glob(output_dir + '../**/*') FileUtils.mkdir_p documents_dir FileUtils.cp_r files_to_copy, documents_dir end @@ -68,9 +69,17 @@ 'searchIndex (name, type, path);') source_module.all_declarations.select(&:type).each do |doc| db.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) ' \ 'VALUES (?, ?, ?);', [doc.name, doc.type.dash_type, doc.url]) end + end + end + + def create_xml + (output_dir + "#{source_module.name}.xml").open('w') do |xml| + url = URI.join(config.root_url, "docsets/#{source_module.name}.tgz") + xml << "<entry><version>#{config.version}</version><url>#{url}" \ + "</url></entry>\n" end end end end end