Better display of mixin signatures.
This commit is contained in:
parent
c2b1588e21
commit
32a5ae26a8
@ -68,6 +68,12 @@ body.reference
|
||||
a.permalink
|
||||
+hover-link
|
||||
+link-colors("inherit", "inherit")
|
||||
.arg[data-default-value]
|
||||
color: #666
|
||||
&:before
|
||||
content: "["
|
||||
&:after
|
||||
content: "]"
|
||||
.source-documentation
|
||||
background-color: #eee
|
||||
border: 1px solid #aaa
|
||||
|
@ -25,5 +25,9 @@
|
||||
e = $(e);
|
||||
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"
|
||||
|
@ -135,8 +135,8 @@ def constants(item)
|
||||
constants
|
||||
end
|
||||
|
||||
def mixin_signature(mixin)
|
||||
mixin.sass_signature(:include)
|
||||
def mixin_signature(mixin, format = :html)
|
||||
mixin.sass_signature(:include, format)
|
||||
end
|
||||
|
||||
def example_items
|
||||
|
@ -118,30 +118,36 @@ module Sass
|
||||
"#{sass_signature}\n #{children_to_sass}\n"
|
||||
end
|
||||
|
||||
def sass_signature(mode = :definition)
|
||||
def sass_signature(mode = :definition, format = :text)
|
||||
prefix = case mode
|
||||
when :definition
|
||||
"="
|
||||
when :include
|
||||
"+"
|
||||
end
|
||||
"#{prefix}#{name}#{arglist_to_sass}"
|
||||
"#{prefix}#{name}#{arglist_to_sass(format)}"
|
||||
end
|
||||
|
||||
private
|
||||
def arglist_to_sass
|
||||
def arglist_to_sass(format = :text)
|
||||
if args && args.any?
|
||||
"(#{args.map{|a| arg_to_sass(a)}.join(", ")})"
|
||||
"(#{args.map{|a| arg_to_sass(a, format)}.join(", ")})"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def arg_to_sass(arg)
|
||||
def arg_to_sass(arg, format = :text)
|
||||
name, default_value = arg
|
||||
sass_str = "#{name.inspect}"
|
||||
if default_value
|
||||
sass_str << " = "
|
||||
sass_str << default_value.to_sass
|
||||
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}"
|
||||
if default_value
|
||||
sass_str << " = "
|
||||
sass_str << default_value.to_sass
|
||||
end
|
||||
end
|
||||
sass_str
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user