diff --git a/doc-src/content/reference/blueprint.haml b/doc-src/content/reference/blueprint.haml index 72a89c10..1a1def6f 100644 --- a/doc-src/content/reference/blueprint.haml +++ b/doc-src/content/reference/blueprint.haml @@ -8,19 +8,4 @@ = render "partials/reference/imports" -%h2 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}); - }); \ No newline at end of file += render "partials/reference/mixins" \ No newline at end of file diff --git a/doc-src/layouts/dialog.haml b/doc-src/layouts/dialog.haml index fdb2f8b1..41c63d22 100644 --- a/doc-src/layouts/dialog.haml +++ b/doc-src/layouts/dialog.haml @@ -1 +1 @@ -.ui-dialog{:style => "display: none;", :id => @id, :title => @title}= yield +.ui-dialog{(@html || {}).merge(:style => "display: none;")}= yield diff --git a/doc-src/layouts/partials/reference/mixins.haml b/doc-src/layouts/partials/reference/mixins.haml new file mode 100644 index 00000000..221818a1 --- /dev/null +++ b/doc-src/layouts/partials/reference/mixins.haml @@ -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}); + }); diff --git a/doc-src/layouts/partials/reference/mixins.yaml b/doc-src/layouts/partials/reference/mixins.yaml new file mode 100644 index 00000000..2fbf0ffd --- /dev/null +++ b/doc-src/layouts/partials/reference/mixins.yaml @@ -0,0 +1 @@ +--- {} diff --git a/doc-src/lib/stylesheets.rb b/doc-src/lib/stylesheets.rb index 187c1beb..c9430155 100644 --- a/doc-src/lib/stylesheets.rb +++ b/doc-src/lib/stylesheets.rb @@ -48,10 +48,41 @@ def mixins(item) mixins 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) mixin.sass_signature(:include) 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) RDiscount.new(docstring).to_html end