Extract a mixin partial.
This commit is contained in:
parent
c05807ce31
commit
769e9c0c8e
@ -8,19 +8,4 @@
|
|||||||
|
|
||||||
= render "partials/reference/imports"
|
= render "partials/reference/imports"
|
||||||
|
|
||||||
%h2 Mixins
|
= render "partials/reference/mixins"
|
||||||
|
|
||||||
- mixins(@item).each do |mixin|
|
|
||||||
%a.view-source{:href=>"#", :onclick => "$('#mixin-source-#{mixin.name}').dialog('open'); return false;"} View Source
|
|
||||||
%h3.mixin{:id=>"mixin-#{mixin.name}"}
|
|
||||||
%a.permalink{:href => "#mixin-#{mixin.name}"}= mixin_signature mixin
|
|
||||||
|
|
||||||
.source-documentation= format_doc(mixin.comment)
|
|
||||||
- render 'dialog', :title => "Source for +#{mixin.name}", :id => "mixin-source-#{mixin.name}" do
|
|
||||||
%pre.source-code.sass= mixin.to_sass
|
|
||||||
|
|
||||||
- content_for :footer do
|
|
||||||
:javascript
|
|
||||||
$(function(){
|
|
||||||
$('.ui-dialog').dialog({hide: true, modal: true, autoOpen: false, width: 400});
|
|
||||||
});
|
|
@ -1 +1 @@
|
|||||||
.ui-dialog{:style => "display: none;", :id => @id, :title => @title}= yield
|
.ui-dialog{(@html || {}).merge(:style => "display: none;")}= yield
|
||||||
|
16
doc-src/layouts/partials/reference/mixins.haml
Normal file
16
doc-src/layouts/partials/reference/mixins.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
- if (mixin_defs = mixins(@item)).any?
|
||||||
|
%h2 Mixins
|
||||||
|
|
||||||
|
- mixin_defs.each do |mixin|
|
||||||
|
%a.view-source{:href=>"#", :onclick => "$('#mixin-source-#{mixin.name}').dialog('open'); return false;"} View Source
|
||||||
|
%h3.mixin{:id=>"mixin-#{mixin.name}"}
|
||||||
|
%a.permalink{:href => "#mixin-#{mixin.name}"}= mixin_signature mixin
|
||||||
|
|
||||||
|
.source-documentation= format_doc(mixin.comment)
|
||||||
|
= mixin_source_dialog(mixin) do
|
||||||
|
%pre.source-code.sass= mixin.to_sass
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(function(){
|
||||||
|
$('.ui-dialog.mixin').dialog({hide: true, modal: true, autoOpen: false, width: 400});
|
||||||
|
});
|
1
doc-src/layouts/partials/reference/mixins.yaml
Normal file
1
doc-src/layouts/partials/reference/mixins.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
--- {}
|
@ -48,10 +48,41 @@ def mixins(item)
|
|||||||
mixins
|
mixins
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def constants(item)
|
||||||
|
sass_tree = tree(item)
|
||||||
|
constants = []
|
||||||
|
comment = nil
|
||||||
|
sass_tree.children.each do |child|
|
||||||
|
if child.is_a?(Sass::Tree::VariableNode)
|
||||||
|
child.comment = comment
|
||||||
|
comment = nil
|
||||||
|
constants << child
|
||||||
|
elsif child.is_a?(Sass::Tree::CommentNode)
|
||||||
|
comment ||= ""
|
||||||
|
comment << "\n" unless comment.empty?
|
||||||
|
comment << child.docstring
|
||||||
|
else
|
||||||
|
comment = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
constants
|
||||||
|
end
|
||||||
|
|
||||||
def mixin_signature(mixin)
|
def mixin_signature(mixin)
|
||||||
mixin.sass_signature(:include)
|
mixin.sass_signature(:include)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mixin_source_dialog(mixin, &block)
|
||||||
|
vars = {
|
||||||
|
:html => {
|
||||||
|
:id => "mixin-source-#{mixin.name}",
|
||||||
|
:class => "mixin",
|
||||||
|
:title => "Source for +#{mixin.name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render 'dialog', vars, &block
|
||||||
|
end
|
||||||
|
|
||||||
def format_doc(docstring)
|
def format_doc(docstring)
|
||||||
RDiscount.new(docstring).to_html
|
RDiscount.new(docstring).to_html
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user