2010-01-23 02:16:25 +00:00
|
|
|
require 'rdiscount'
|
2010-01-21 19:54:47 +00:00
|
|
|
|
|
|
|
def stylesheets_dir(framework)
|
|
|
|
Compass::Frameworks[framework].stylesheets_directory
|
|
|
|
end
|
|
|
|
|
|
|
|
def stylesheet_key(item)
|
|
|
|
[item[:framework], item[:stylesheet]].join("/")
|
|
|
|
end
|
|
|
|
|
|
|
|
def tree(item)
|
|
|
|
@stylesheets ||= {}
|
|
|
|
@stylesheets[stylesheet_key(item)] ||= begin
|
|
|
|
file = File.join(stylesheets_dir(item[:framework]), item[:stylesheet])
|
|
|
|
contents = File.read(file)
|
|
|
|
Sass::Engine.new(contents).send :to_tree
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def imports(item)
|
|
|
|
sass_tree = tree(item)
|
|
|
|
imports = []
|
|
|
|
sass_tree.children.each do |child|
|
|
|
|
if child.is_a?(Sass::Tree::ImportNode)
|
|
|
|
imports << child.imported_filename
|
|
|
|
end
|
|
|
|
end
|
|
|
|
imports
|
|
|
|
end
|
2010-01-22 19:40:56 +00:00
|
|
|
|
|
|
|
def mixins(item)
|
|
|
|
sass_tree = tree(item)
|
|
|
|
mixins = []
|
|
|
|
comment = nil
|
|
|
|
sass_tree.children.each do |child|
|
|
|
|
if child.is_a?(Sass::Tree::MixinDefNode)
|
|
|
|
child.comment = comment
|
|
|
|
comment = nil
|
|
|
|
mixins << child
|
|
|
|
elsif child.is_a?(Sass::Tree::CommentNode)
|
|
|
|
comment ||= ""
|
|
|
|
comment << "\n" unless comment.empty?
|
|
|
|
comment << child.docstring
|
|
|
|
else
|
|
|
|
comment = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mixins
|
|
|
|
end
|
|
|
|
|
|
|
|
def mixin_signature(mixin)
|
2010-01-23 09:06:54 +00:00
|
|
|
mixin.sass_signature(:include)
|
2010-01-22 19:40:56 +00:00
|
|
|
end
|
|
|
|
|
2010-01-23 02:16:25 +00:00
|
|
|
def format_doc(docstring)
|
|
|
|
RDiscount.new(docstring).to_html
|
|
|
|
end
|
|
|
|
|