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
|
||||
%h1#logo Sass Based Functions
|
||||
|
||||
- all_functions.sort_by{|i| i.first.identifier}.each do |item, functions|
|
||||
%h3= link_to item[:title], item
|
||||
- all_functions.sorted_and_grouped_by_name{|f| f.last.name }.each do |(group, functions)|
|
||||
%h3= group
|
||||
%ul
|
||||
- functions.sort_by{|f| f.name}.each do |f|
|
||||
%li= f.sass_signature(:html)
|
||||
- functions.each do |(i, f)|
|
||||
%li
|
||||
%a{:href=>"#{i.path}#function-#{f.name}"}= f.sass_signature(:html)
|
||||
|
||||
%h1#logo All Ruby Based Functions
|
||||
%ul
|
||||
|
@ -6,9 +6,9 @@ body_id: home
|
||||
%article
|
||||
%h1#logo Compass Mixins
|
||||
|
||||
- all_mixins.sort_by{|i| i.first.identifier}.each do |item, mixins|
|
||||
%h3= link_to item[:title], item
|
||||
- all_mixins.sorted_and_grouped_by_name{|m| m.last.name }.each do |(group, mixins)|
|
||||
%h3= group
|
||||
%ul
|
||||
- mixins.sort_by{|m| m.name}.each do |m|
|
||||
%li= m.sass_signature(:none, :html)
|
||||
|
||||
- mixins.each do |(i, m)|
|
||||
%li
|
||||
%a{:href=>"#{i.path}#mixin-#{m.name}"}= m.sass_signature(:none, :html)
|
||||
|
@ -6,10 +6,10 @@ body_id: home
|
||||
%article
|
||||
%h1#logo Compass Variables
|
||||
|
||||
- all_constants.sort_by{|i| i.first.identifier}.each do |item, constants|
|
||||
%h3= link_to item[:title], item
|
||||
- all_constants.sorted_and_grouped_by_name{|v| v.last.name }.each do |(group, variables)|
|
||||
%h3= group
|
||||
%ul
|
||||
- constants.sort_by{|c| c.name}.each do |c|
|
||||
%li $#{c.name}
|
||||
|
||||
- variables.each do |(i, v)|
|
||||
%li
|
||||
%a{:href=>"#{i.path}#const-#{v.name}"}= "$" + v.name
|
||||
|
@ -28,6 +28,12 @@ def body_attributes(item)
|
||||
}
|
||||
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
|
||||
attr_accessor :values
|
||||
attr_accessor :index
|
||||
|
@ -160,42 +160,28 @@ def constants(item)
|
||||
end
|
||||
|
||||
def all_constants
|
||||
variables = []
|
||||
@items.each do |item|
|
||||
next unless item.identifier =~ %r{/reference}
|
||||
next unless item[:stylesheet]
|
||||
vars = constants(item)
|
||||
if vars.any?
|
||||
variables << [item, vars]
|
||||
end
|
||||
@items.inject([]) do |variables, item|
|
||||
next variables unless item.identifier =~ %r{/reference}
|
||||
next variables unless item[:stylesheet]
|
||||
variables += constants(item).map{|v| [item, v] }
|
||||
end
|
||||
variables
|
||||
end
|
||||
|
||||
def all_mixins
|
||||
all_mixins = []
|
||||
@items.each do |item|
|
||||
next unless item.identifier =~ %r{/reference}
|
||||
next unless item[:stylesheet]
|
||||
ms = mixins(item)
|
||||
if ms.any?
|
||||
all_mixins << [item, ms]
|
||||
end
|
||||
@items.inject([]) do |all_mixins, item|
|
||||
next all_mixins unless item.identifier =~ %r{/reference}
|
||||
next all_mixins unless item[:stylesheet]
|
||||
all_mixins += mixins(item).map{|m| [item, m] }
|
||||
end
|
||||
all_mixins
|
||||
end
|
||||
|
||||
def all_functions
|
||||
all_functions = []
|
||||
@items.each do |item|
|
||||
next unless item.identifier =~ %r{/reference}
|
||||
next unless item[:stylesheet]
|
||||
fns = functions(item)
|
||||
if fns.any?
|
||||
all_functions << [item, fns]
|
||||
end
|
||||
rv = @items.inject([]) do |all_functions, item|
|
||||
next all_functions unless item.identifier =~ %r{/reference}
|
||||
next all_functions unless item[:stylesheet]
|
||||
all_functions += functions(item).map{|f| [item, f] }
|
||||
end
|
||||
all_functions
|
||||
rv
|
||||
end
|
||||
|
||||
def example_items
|
||||
|
Loading…
Reference in New Issue
Block a user