Better display of mixin signatures.

This commit is contained in:
Chris Eppstein 2010-03-28 23:06:56 -07:00
parent c2b1588e21
commit 32a5ae26a8
4 changed files with 27 additions and 11 deletions

View File

@ -68,6 +68,12 @@ body.reference
a.permalink a.permalink
+hover-link +hover-link
+link-colors("inherit", "inherit") +link-colors("inherit", "inherit")
.arg[data-default-value]
color: #666
&:before
content: "["
&:after
content: "]"
.source-documentation .source-documentation
background-color: #eee background-color: #eee
border: 1px solid #aaa border: 1px solid #aaa

View File

@ -25,5 +25,9 @@
e = $(e); e = $(e);
e.after('<span class="swatch" style="background-color:'+e.text()+';"></span>'); e.after('<span class="swatch" style="background-color:'+e.text()+';"></span>');
}); });
$('span.arg[data-default-value]').each(function(i,e){
e = $(e);
e.attr("title", "Defaults to: " + e.attr("data-default-value"))
})
}); });
= render "partials/analytics" = render "partials/analytics"

View File

@ -135,8 +135,8 @@ def constants(item)
constants constants
end end
def mixin_signature(mixin) def mixin_signature(mixin, format = :html)
mixin.sass_signature(:include) mixin.sass_signature(:include, format)
end end
def example_items def example_items

View File

@ -118,31 +118,37 @@ module Sass
"#{sass_signature}\n #{children_to_sass}\n" "#{sass_signature}\n #{children_to_sass}\n"
end end
def sass_signature(mode = :definition) def sass_signature(mode = :definition, format = :text)
prefix = case mode prefix = case mode
when :definition when :definition
"=" "="
when :include when :include
"+" "+"
end end
"#{prefix}#{name}#{arglist_to_sass}" "#{prefix}#{name}#{arglist_to_sass(format)}"
end end
private private
def arglist_to_sass def arglist_to_sass(format = :text)
if args && args.any? if args && args.any?
"(#{args.map{|a| arg_to_sass(a)}.join(", ")})" "(#{args.map{|a| arg_to_sass(a, format)}.join(", ")})"
else else
"" ""
end end
end end
def arg_to_sass(arg) def arg_to_sass(arg, format = :text)
name, default_value = arg name, default_value = arg
sass_str = ""
if format == :html
ddv = %Q{ data-default-value="#{h(default_value.to_sass)}"} if default_value
sass_str = %Q{<span class="arg"#{ddv}>#{name.inspect}</span>}
else
sass_str = "#{name.inspect}" sass_str = "#{name.inspect}"
if default_value if default_value
sass_str << " = " sass_str << " = "
sass_str << default_value.to_sass sass_str << default_value.to_sass
end end
end
sass_str sass_str
end end
end end