Better index structure for vars, mixins, and functions.
This commit is contained in:
parent
8a995fe903
commit
faf769cd39
@ -6,11 +6,12 @@ body_id: home
|
|||||||
%article
|
%article
|
||||||
%h1#logo Sass Based Functions
|
%h1#logo Sass Based Functions
|
||||||
|
|
||||||
- all_functions.sort_by{|i| i.first.identifier}.each do |item, functions|
|
- all_functions.sorted_and_grouped_by_name{|f| f.last.name }.each do |(group, functions)|
|
||||||
%h3= link_to item[:title], item
|
%h3= group
|
||||||
%ul
|
%ul
|
||||||
- functions.sort_by{|f| f.name}.each do |f|
|
- functions.each do |(i, f)|
|
||||||
%li= f.sass_signature(:html)
|
%li
|
||||||
|
%a{:href=>"#{i.path}#function-#{f.name}"}= f.sass_signature(:html)
|
||||||
|
|
||||||
%h1#logo All Ruby Based Functions
|
%h1#logo All Ruby Based Functions
|
||||||
%ul
|
%ul
|
||||||
|
@ -6,9 +6,9 @@ body_id: home
|
|||||||
%article
|
%article
|
||||||
%h1#logo Compass Mixins
|
%h1#logo Compass Mixins
|
||||||
|
|
||||||
- all_mixins.sort_by{|i| i.first.identifier}.each do |item, mixins|
|
- all_mixins.sorted_and_grouped_by_name{|m| m.last.name }.each do |(group, mixins)|
|
||||||
%h3= link_to item[:title], item
|
%h3= group
|
||||||
%ul
|
%ul
|
||||||
- mixins.sort_by{|m| m.name}.each do |m|
|
- mixins.each do |(i, m)|
|
||||||
%li= m.sass_signature(:none, :html)
|
%li
|
||||||
|
%a{:href=>"#{i.path}#mixin-#{m.name}"}= m.sass_signature(:none, :html)
|
||||||
|
@ -6,10 +6,10 @@ body_id: home
|
|||||||
%article
|
%article
|
||||||
%h1#logo Compass Variables
|
%h1#logo Compass Variables
|
||||||
|
|
||||||
- all_constants.sort_by{|i| i.first.identifier}.each do |item, constants|
|
- all_constants.sorted_and_grouped_by_name{|v| v.last.name }.each do |(group, variables)|
|
||||||
%h3= link_to item[:title], item
|
%h3= group
|
||||||
%ul
|
%ul
|
||||||
- constants.sort_by{|c| c.name}.each do |c|
|
- variables.each do |(i, v)|
|
||||||
%li $#{c.name}
|
%li
|
||||||
|
%a{:href=>"#{i.path}#const-#{v.name}"}= "$" + v.name
|
||||||
|
|
@ -28,6 +28,12 @@ def body_attributes(item)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Enumerable
|
||||||
|
def sorted_and_grouped_by_name
|
||||||
|
sort_by{|i| yield(i)}.group_by{|i| yield(i).sub(/^[^\w]/,"")[0..0].upcase}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Recycler
|
class Recycler
|
||||||
attr_accessor :values
|
attr_accessor :values
|
||||||
attr_accessor :index
|
attr_accessor :index
|
||||||
|
@ -160,42 +160,28 @@ def constants(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def all_constants
|
def all_constants
|
||||||
variables = []
|
@items.inject([]) do |variables, item|
|
||||||
@items.each do |item|
|
next variables unless item.identifier =~ %r{/reference}
|
||||||
next unless item.identifier =~ %r{/reference}
|
next variables unless item[:stylesheet]
|
||||||
next unless item[:stylesheet]
|
variables += constants(item).map{|v| [item, v] }
|
||||||
vars = constants(item)
|
|
||||||
if vars.any?
|
|
||||||
variables << [item, vars]
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
variables
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_mixins
|
def all_mixins
|
||||||
all_mixins = []
|
@items.inject([]) do |all_mixins, item|
|
||||||
@items.each do |item|
|
next all_mixins unless item.identifier =~ %r{/reference}
|
||||||
next unless item.identifier =~ %r{/reference}
|
next all_mixins unless item[:stylesheet]
|
||||||
next unless item[:stylesheet]
|
all_mixins += mixins(item).map{|m| [item, m] }
|
||||||
ms = mixins(item)
|
|
||||||
if ms.any?
|
|
||||||
all_mixins << [item, ms]
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
all_mixins
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_functions
|
def all_functions
|
||||||
all_functions = []
|
rv = @items.inject([]) do |all_functions, item|
|
||||||
@items.each do |item|
|
next all_functions unless item.identifier =~ %r{/reference}
|
||||||
next unless item.identifier =~ %r{/reference}
|
next all_functions unless item[:stylesheet]
|
||||||
next unless item[:stylesheet]
|
all_functions += functions(item).map{|f| [item, f] }
|
||||||
fns = functions(item)
|
|
||||||
if fns.any?
|
|
||||||
all_functions << [item, fns]
|
|
||||||
end
|
end
|
||||||
end
|
rv
|
||||||
all_functions
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_items
|
def example_items
|
||||||
|
Loading…
Reference in New Issue
Block a user