Class: RspecApiDocumentation::Writers::GeneralMarkupWriter

Inherits:
Writer
  • Object
show all
Defined in:
lib/rspec_api_documentation/writers/general_markup_writer.rb

Overview

Base class for writers that write HTML

Direct Known Subclasses

HtmlWriter, MarkdownWriter, TextileWriter

Constant Summary collapse

INDEX_FILE_NAME =
'index'

Instance Attribute Summary

Attributes inherited from Writer

#configuration, #index

Instance Method Summary collapse

Methods inherited from Writer

clear_docs, #initialize, write

Constructor Details

This class inherits a constructor from RspecApiDocumentation::Writers::Writer

Instance Method Details

#extensionObject



27
28
29
# File 'lib/rspec_api_documentation/writers/general_markup_writer.rb', line 27

def extension
  raise 'Parent class. This method should not be called.'
end

#index_file_nameObject



23
24
25
# File 'lib/rspec_api_documentation/writers/general_markup_writer.rb', line 23

def index_file_name
  INDEX_FILE_NAME
end

#writeObject

Write out the generated documentation



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rspec_api_documentation/writers/general_markup_writer.rb', line 8

def write
  File.open(configuration.docs_dir.join(index_file_name + '.' + extension), "w+") do |f|
    f.write markup_index_class.new(index, configuration).render
  end

  index.examples.each do |example|
    markup_example = markup_example_class.new(example, configuration)
    FileUtils.mkdir_p(configuration.docs_dir.join(markup_example.dirname))

    File.open(configuration.docs_dir.join(markup_example.dirname, markup_example.filename), "w+") do |f|
      f.write markup_example.render
    end
  end
end