class Kramdown::Man::Task

Defines a `man` rake task that generates man-pages within the `man/` directory from `.md` files.

Constants

FILES

Markdown file glob pattern

Attributes

options[R]

Additional options

@return [Hash]

Public Class Methods

new(options={}) click to toggle source

Initializes the tasks.

@param [Hash] options

Additional options.
# File lib/kramdown/man/task.rb, line 28
def initialize(options={})
  @options   = options
  @markdown  = FileList[FILES]
  @man_pages = @markdown.pathmap('%X')

  define
end

Protected Instance Methods

define() click to toggle source

Defines the `man` tasks.

# File lib/kramdown/man/task.rb, line 41
def define
  desc 'Build UNIX manual pages from Markdown files in man/'
  task 'man' => @man_pages

  @markdown.zip(@man_pages).each do |markdown,man_page|
    file(man_page => markdown) do
      render(markdown,man_page)
    end
  end
end
render(markdown,man_page) click to toggle source

Renders a man_page from a markdown file.

@param [String] markdown

The path to the input markdown file.

@param [String] man_page

The path to the output man_page file.
# File lib/kramdown/man/task.rb, line 61
def render(markdown,man_page)
  doc = Kramdown::Document.new(File.read(markdown),@options)

  File.open(man_page,'w') do |output|
    output.write doc.to_man
  end
end