Sha256: 64c7b51eb09e6058d32da1ea6bd38a0e40890af8e3154cd3c2b7c37f9720e43e

Contents?: true

Size: 696 Bytes

Versions: 1

Compression:

Stored size: 696 Bytes

Contents

class GhostWriter::DocumentIndex
  attr_reader :output, :documents

  def initialize(output, documents)
    extend(GhostWriter::Format::Markdown)
    @output = output
    @documents = documents
  end

  def write_file
    if GhostWriter.github_base_url
      base_url = GhostWriter.github_base_url + "/"
    else
      base_url = ""
    end

    document_list = documents.flat_map do |output, docs|
      docs.map do |d|
        list(
          link(d.description, base_url + "#{d.relative_path}")
        )
      end
    end

    index_file = File.open(output, "w")
    index_file.write paragraph(<<EOP)
#{headword("API Examples")}
#{document_list.join("\n")}
EOP
    index_file.close
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_writer-0.2.0 lib/ghost_writer/document_index.rb