Examples can now be targeted generally at a stylesheet instead of at
only mixins.
This commit is contained in:
parent
41183a2f85
commit
72b084ccbe
@ -84,7 +84,7 @@ Example Metadata is used to associate the example to a mixin in the reference do
|
||||
mixin: awesome
|
||||
---
|
||||
|
||||
After adding the example and adjusting the metadata, go to the reference page and you can verify that a link to the example has appeared.
|
||||
After adding the example and adjusting the metadata, go to the reference page and you can verify that a link to the example has appeared. If the mixin property is omitted, then the example will be a general example for the stylesheet.
|
||||
|
||||
### How to Add New Reference Documentation
|
||||
|
||||
|
7
doc-src/layouts/partials/reference/examples.haml
Normal file
7
doc-src/layouts/partials/reference/examples.haml
Normal file
@ -0,0 +1,7 @@
|
||||
- if (examples = examples(@item)).any?
|
||||
%h2 Examples
|
||||
%dl.examples
|
||||
- examples.each do |example|
|
||||
%dt= link_to example.item[:title], example, :target => "_blank"
|
||||
- if example.item[:description]
|
||||
%dd= example.item[:description]
|
@ -8,7 +8,7 @@
|
||||
|
||||
.source-documentation
|
||||
= format_doc(mixin.comment)
|
||||
- if (examples = mixin_examples(@item, mixin)).any?
|
||||
- if (examples = examples(@item, mixin)).any?
|
||||
%dl.examples
|
||||
- examples.each do |example|
|
||||
%dt= link_to example.item[:title], example, :target => "_blank"
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
= yield
|
||||
|
||||
= render "partials/reference/examples"
|
||||
|
||||
= render "partials/reference/imports"
|
||||
|
||||
= render "partials/reference/constants"
|
||||
|
@ -140,10 +140,14 @@ def examples_for_item(item)
|
||||
end
|
||||
end
|
||||
|
||||
def mixin_examples(item, mixin)
|
||||
examples_for_item(item).select do |i|
|
||||
i[:mixin] == mixin.name
|
||||
end.map{|i| i.reps.find{|r| r.name == :default}}
|
||||
def examples(item, mixin = nil)
|
||||
examples = examples_for_item(item)
|
||||
if mixin
|
||||
examples = examples.select {|i| i[:mixin] == mixin.name }
|
||||
else
|
||||
examples = examples.reject {|i| i[:mixin] }
|
||||
end
|
||||
examples.map{|i| i.reps.find{|r| r.name == :default}}
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user