Class: Corundum::DocumentationAssembly

Inherits:
DocumentationTask show all
Defined in:
lib/corundum/documentation/assembly.rb

Instance Method Summary collapse

Methods inherited from DocumentationTask

#entry_point, title

Instance Method Details

#default_configuration(toolkit, *documenters) ⇒ Object



34
35
36
37
38
39
# File 'lib/corundum/documentation/assembly.rb', line 34

def default_configuration(toolkit, *documenters)
  super(toolkit)
  self.documenters = documenters

  self.compass_config.http_stylesheets_path = css_dir #XXX
end

#defineObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/corundum/documentation/assembly.rb', line 80

def define
  in_namespace do
    subdir_regex = %r{^#{File::expand_path(target_dir)}}

    documenters.each_pair do |subdir, doccer|
      file subdir => [target_dir, doccer.entry_point] do
        if subdir_regex =~ File::expand_path(doccer.target_dir)
          fail "Documentation being rendered to #{doccer.target_dir}, inside of #{target_dir}"
        end

        FileUtils.rm_rf(subdir)
        FileUtils.mv(doccer.target_dir, subdir)
      end
    end

    #XXX Collision of doc groups
    task :collect => documenters.keys

    file stylesheet.abspath => [target.abspath] do |task|
      template = templates.find(root_stylesheet.abspath).contents
      File::open(task.name, "w") do |file|
        file.write(template.render(nil, nil))
      end
    end

    file entry_point => [stylesheet.abspath, target.abspath, :collect] do |task|
      template = templates.find(index_source.abspath).contents
      File::open(task.name, "w") do |file|
        file.write(template.render(self, {}))
      end
    end
  end
  super
end

#resolve_configurationObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/corundum/documentation/assembly.rb', line 41

def resolve_configuration
  super
  assembly_sub.absolute_path = assembly_sub.relative_path
  target.absolute_path = target_dir

  resolve_paths

  if field_unset?(:templates)
    self.templates = Corundum::configuration_store.valise.templates do |mapping|
      case mapping
      when "sass", "scss"
        valise = Corundum::configuration_store.valise
        options =
          if Compass.respond_to? :sass_engine_options
            Compass.sass_engine_options
          else
            require 'compass/core'
            { :load_paths => [Compass::Core.base_directory("stylesheets")] }
          end
        options[:load_paths] = valise.sub_set("templates").map(&:to_s) + options[:load_paths]
        { :template_options => options }
      else
        nil
      end
    end
  end

  self.compass_config.project_path = templates.find("doc_assembly/theme").full_path

  self.documenters = documenters.each_with_object({}) do |doccer, hash|
    hash[File::join(target_dir, doccer.sub_dir)] = doccer
  end
  if field_unset?(:stylesheet)
    self.stylesheet = File::join(target_dir, "stylesheet.css")
  end

end