Sha256: 5d83a1b05ab3f374af19520474245f3f2d2be004520a3f35f76cff048a43ff29

Contents?: true

Size: 1.57 KB

Versions: 9

Compression:

Stored size: 1.57 KB

Contents

require 'mattock/tasklib'

module Corundum
  class DocumentationTask < Mattock::TaskLib
    setting :title
    setting :browser
    setting :gemspec

    #TODO update to use new paths DSL
    setting :corundum_dir
    setting :docs_root

    setting :target_dir
    setting :sub_dir

    setting :entry_file, "index.html"

    #The path from the project root to the entry file
    #Resolves if unset to target_dir + entry_file
    setting :entry_path

    #The URL path from this documentation root
    #Resolves if unset to sub_dir + entry_file
    setting :entry_link


    def self.title(name)
      setting :title, name
    end

    def default_configuration(toolkit)
      super
      toolkit.copy_settings_to(self)
    end

    def resolve_configuration
      super
      if field_unset?(:docs_root)
        self.docs_root = File::join(corundum_dir, "docs")
      end

      if field_unset?(:target_dir)
        self.target_dir = File::join(docs_root, sub_dir)
      else
        self.sub_dir = target_dir.sub(/^#{docs_root}\//,"")
      end

      if field_unset?(:entry_path)
        self.entry_path = File::join(target_dir, entry_file)
      end

      if field_unset?(:entry_link)
        self.entry_link = File::join(sub_dir, entry_file)
      end
    end

    def entry_point(under = nil)
      File::join(under || target_dir, entry_file)
    end

    def define
      directory target_dir

      in_namespace do
        desc "Open up a browser to view your documentation"
        BrowserTask.define_task(self) do |t|
          t.index_html = entry_point
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
corundum-0.3.9 lib/corundum/documentation-task.rb
corundum-0.3.8 lib/corundum/documentation-task.rb
corundum-0.3.7 lib/corundum/documentation-task.rb
corundum-0.3.6 lib/corundum/documentation-task.rb
corundum-0.3.5 lib/corundum/documentation-task.rb
corundum-0.3.4 lib/corundum/documentation-task.rb
corundum-0.3.3 lib/corundum/documentation-task.rb
corundum-0.3.2 lib/corundum/documentation-task.rb
corundum-0.3.1 lib/corundum/documentation-task.rb