haml-edge 2.1.21 → 2.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/EDGE_GEM_VERSION +1 -1
  2. data/FAQ.md +142 -0
  3. data/{README.rdoc → README.md} +141 -141
  4. data/Rakefile +29 -17
  5. data/VERSION +1 -1
  6. data/lib/haml/buffer.rb +63 -27
  7. data/lib/haml/engine.rb +103 -80
  8. data/lib/haml/error.rb +7 -7
  9. data/lib/haml/exec.rb +80 -26
  10. data/lib/haml/filters.rb +106 -40
  11. data/lib/haml/helpers/action_view_extensions.rb +34 -39
  12. data/lib/haml/helpers/action_view_mods.rb +132 -139
  13. data/lib/haml/helpers.rb +207 -153
  14. data/lib/haml/html.rb +40 -21
  15. data/lib/haml/precompiler.rb +2 -0
  16. data/lib/haml/shared.rb +34 -3
  17. data/lib/haml/template/patch.rb +1 -1
  18. data/lib/haml/template/plugin.rb +0 -2
  19. data/lib/haml/template.rb +5 -0
  20. data/lib/haml/util.rb +136 -1
  21. data/lib/haml/version.rb +16 -4
  22. data/lib/haml.rb +502 -481
  23. data/lib/sass/css.rb +106 -68
  24. data/lib/sass/engine.rb +55 -22
  25. data/lib/sass/environment.rb +52 -21
  26. data/lib/sass/error.rb +23 -12
  27. data/lib/sass/files.rb +27 -0
  28. data/lib/sass/plugin/merb.rb +2 -2
  29. data/lib/sass/plugin/rails.rb +0 -2
  30. data/lib/sass/plugin.rb +32 -23
  31. data/lib/sass/repl.rb +7 -0
  32. data/lib/sass/script/bool.rb +9 -5
  33. data/lib/sass/script/color.rb +87 -1
  34. data/lib/sass/script/funcall.rb +23 -2
  35. data/lib/sass/script/functions.rb +93 -44
  36. data/lib/sass/script/lexer.rb +33 -3
  37. data/lib/sass/script/literal.rb +93 -1
  38. data/lib/sass/script/node.rb +14 -0
  39. data/lib/sass/script/number.rb +128 -4
  40. data/lib/sass/script/operation.rb +16 -1
  41. data/lib/sass/script/parser.rb +51 -21
  42. data/lib/sass/script/string.rb +7 -4
  43. data/lib/sass/script/unary_operation.rb +14 -1
  44. data/lib/sass/script/variable.rb +12 -1
  45. data/lib/sass/script.rb +26 -5
  46. data/lib/sass/tree/attr_node.rb +46 -9
  47. data/lib/sass/tree/comment_node.rb +41 -1
  48. data/lib/sass/tree/debug_node.rb +8 -0
  49. data/lib/sass/tree/directive_node.rb +20 -0
  50. data/lib/sass/tree/file_node.rb +12 -0
  51. data/lib/sass/tree/for_node.rb +15 -0
  52. data/lib/sass/tree/if_node.rb +22 -0
  53. data/lib/sass/tree/mixin_def_node.rb +12 -1
  54. data/lib/sass/tree/mixin_node.rb +13 -0
  55. data/lib/sass/tree/node.rb +136 -6
  56. data/lib/sass/tree/rule_node.rb +66 -7
  57. data/lib/sass/tree/variable_node.rb +10 -0
  58. data/lib/sass/tree/while_node.rb +11 -1
  59. data/lib/sass.rb +544 -534
  60. metadata +7 -6
  61. data/FAQ +0 -138
data/lib/sass/css.rb CHANGED
@@ -3,14 +3,18 @@ require 'sass/tree/node'
3
3
  require 'strscan'
4
4
 
5
5
  module Sass
6
- # :stopdoc:
7
6
  module Tree
8
7
  class Node
9
- def to_sass(opts = {})
8
+ # Converts a node to Sass code that will generate it.
9
+ #
10
+ # @param tabs [Fixnum] The amount of tabulation to use for the Sass code
11
+ # @param opts [Hash<Symbol, Object>] An options hash (see {Sass::CSS#initialize})
12
+ # @return [String] The Sass code corresponding to the node
13
+ def to_sass(tabs = 0, opts = {})
10
14
  result = ''
11
15
 
12
16
  children.each do |child|
13
- result << "#{child.to_sass(0, opts)}\n"
17
+ result << "#{' ' * tabs}#{child.to_sass(0, opts)}\n"
14
18
  end
15
19
 
16
20
  result
@@ -18,6 +22,7 @@ module Sass
18
22
  end
19
23
 
20
24
  class RuleNode
25
+ # @see Node#to_sass
21
26
  def to_sass(tabs, opts = {})
22
27
  str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? AttrNode } ? "\n" : ''}"
23
28
 
@@ -30,26 +35,33 @@ module Sass
30
35
  end
31
36
 
32
37
  class AttrNode
38
+ # @see Node#to_sass
33
39
  def to_sass(tabs, opts = {})
34
40
  "#{' ' * tabs}#{opts[:alternate] ? '' : ':'}#{name}#{opts[:alternate] ? ':' : ''} #{value}\n"
35
41
  end
36
42
  end
37
43
 
38
44
  class DirectiveNode
45
+ # @see Node#to_sass
39
46
  def to_sass(tabs, opts = {})
40
47
  "#{' ' * tabs}#{value}#{children.map {|c| c.to_sass(tabs + 1, opts)}}\n"
41
48
  end
42
49
  end
43
50
  end
44
51
 
45
- # :startdoc:
46
-
47
- # This class contains the functionality used in the +css2sass+ utility,
48
- # namely converting CSS documents to Sass templates.
52
+ # This class converts CSS documents into Sass templates.
53
+ # It works by parsing the CSS document into a {Sass::Tree} structure,
54
+ # and then applying various transformations to the structure
55
+ # to produce more concise and idiomatic Sass.
56
+ #
57
+ # Example usage:
58
+ #
59
+ # Sass::CSS.new("p { color: blue }").render #=> "p\n :color blue"
49
60
  class CSS
50
-
51
- # Creates a new instance of Sass::CSS that will compile the given document
52
- # to a Sass string when +render+ is called.
61
+ # @param template [String] The CSS code
62
+ # @option options :alternate [Boolean] (false)
63
+ # Whether or not to output alternate attribute syntax
64
+ # (`color: blue` as opposed to `:color blue`).
53
65
  def initialize(template, options = {})
54
66
  if template.is_a? IO
55
67
  template = template.read
@@ -59,11 +71,12 @@ module Sass
59
71
  @template = StringScanner.new(template)
60
72
  end
61
73
 
62
- # Processes the document and returns the result as a string
63
- # containing the CSS template.
74
+ # Converts the CSS template into Sass code.
75
+ #
76
+ # @return [String] The resulting Sass code
64
77
  def render
65
78
  begin
66
- build_tree.to_sass(@options).strip + "\n"
79
+ build_tree.to_sass(0, @options).strip + "\n"
67
80
  rescue Exception => err
68
81
  line = @template.string[0...@template.pos].split("\n").size
69
82
 
@@ -74,6 +87,9 @@ module Sass
74
87
 
75
88
  private
76
89
 
90
+ # Parses the CSS template and applies various transformations
91
+ #
92
+ # @return [Tree::Node] The root node of the parsed tree
77
93
  def build_tree
78
94
  root = Tree::Node.new
79
95
  whitespace
@@ -86,6 +102,9 @@ module Sass
86
102
  root
87
103
  end
88
104
 
105
+ # Parses a set of CSS rules.
106
+ #
107
+ # @param root [Tree::Node] The parent node of the rules
89
108
  def rules(root)
90
109
  while r = rule
91
110
  root << r
@@ -93,6 +112,9 @@ module Sass
93
112
  end
94
113
  end
95
114
 
115
+ # Parses a single CSS rule.
116
+ #
117
+ # @return [Tree::Node] The parsed rule
96
118
  def rule
97
119
  return unless rule = @template.scan(/[^\{\};]+/)
98
120
  rule.strip!
@@ -115,6 +137,9 @@ module Sass
115
137
  return node
116
138
  end
117
139
 
140
+ # Parses a set of CSS attributes within a rule.
141
+ #
142
+ # @param rule [Tree::RuleNode] The parent node of the attributes
118
143
  def attributes(rule)
119
144
  while @template.scan(/[^:\}\s]+/)
120
145
  name = @template[0]
@@ -134,6 +159,9 @@ module Sass
134
159
  assert_match /\}/
135
160
  end
136
161
 
162
+ # Moves the scanner over a section of whitespace or comments.
163
+ #
164
+ # @return [String] The ignored whitespace
137
165
  def whitespace
138
166
  space = @template.scan(/\s*/) || ''
139
167
 
@@ -146,6 +174,10 @@ module Sass
146
174
  return space
147
175
  end
148
176
 
177
+ # Moves the scanner over a regular expression,
178
+ # raising an exception if it doesn't match.
179
+ #
180
+ # @param re [Regexp] The regular expression to assert
149
181
  def assert_match(re)
150
182
  if !@template.scan(re)
151
183
  line = @template.string[0..@template.pos].count "\n"
@@ -158,20 +190,19 @@ module Sass
158
190
 
159
191
  # Transform
160
192
  #
161
- # foo, bar, baz
162
- # color: blue
193
+ # foo, bar, baz
194
+ # color: blue
163
195
  #
164
196
  # into
165
197
  #
166
- # foo
167
- # color: blue
168
- # bar
169
- # color: blue
170
- # baz
171
- # color: blue
198
+ # foo
199
+ # color: blue
200
+ # bar
201
+ # color: blue
202
+ # baz
203
+ # color: blue
172
204
  #
173
- # Yes, this expands the amount of code,
174
- # but it's necessary to get nesting to work properly.
205
+ # @param root [Tree::Node] The parent node
175
206
  def expand_commas(root)
176
207
  root.children.map! do |child|
177
208
  next child unless Tree::RuleNode === child && child.rules.first.include?(',')
@@ -186,37 +217,38 @@ module Sass
186
217
 
187
218
  # Make rules use parent refs so that
188
219
  #
189
- # foo
190
- # color: green
191
- # foo.bar
192
- # color: blue
220
+ # foo
221
+ # color: green
222
+ # foo.bar
223
+ # color: blue
193
224
  #
194
225
  # becomes
195
226
  #
196
- # foo
197
- # color: green
198
- # &.bar
199
- # color: blue
227
+ # foo
228
+ # color: green
229
+ # &.bar
230
+ # color: blue
200
231
  #
201
232
  # This has the side effect of nesting rules,
202
233
  # so that
203
234
  #
204
- # foo
205
- # color: green
206
- # foo bar
207
- # color: red
208
- # foo baz
209
- # color: blue
235
+ # foo
236
+ # color: green
237
+ # foo bar
238
+ # color: red
239
+ # foo baz
240
+ # color: blue
210
241
  #
211
242
  # becomes
212
243
  #
213
- # foo
214
- # color: green
215
- # & bar
216
- # color: red
217
- # & baz
218
- # color: blue
244
+ # foo
245
+ # color: green
246
+ # & bar
247
+ # color: red
248
+ # & baz
249
+ # color: blue
219
250
  #
251
+ # @param root [Tree::Node] The parent node
220
252
  def parent_ref_rules(root)
221
253
  current_rule = nil
222
254
  root.children.select { |c| Tree::RuleNode === c }.each do |child|
@@ -241,16 +273,17 @@ module Sass
241
273
 
242
274
  # Remove useless parent refs so that
243
275
  #
244
- # foo
245
- # & bar
246
- # color: blue
276
+ # foo
277
+ # & bar
278
+ # color: blue
247
279
  #
248
280
  # becomes
249
281
  #
250
- # foo
251
- # bar
252
- # color: blue
282
+ # foo
283
+ # bar
284
+ # color: blue
253
285
  #
286
+ # @param root [Tree::Node] The parent node
254
287
  def remove_parent_refs(root)
255
288
  root.children.each do |child|
256
289
  if child.is_a?(Tree::RuleNode)
@@ -262,31 +295,35 @@ module Sass
262
295
 
263
296
  # Flatten rules so that
264
297
  #
265
- # foo
266
- # bar
267
- # baz
268
- # color: red
298
+ # foo
299
+ # bar
300
+ # :color red
269
301
  #
270
302
  # becomes
271
303
  #
272
- # foo bar baz
273
- # color: red
304
+ # foo bar
305
+ # :color red
274
306
  #
275
307
  # and
276
308
  #
277
- # foo
278
- # &.bar
279
- # color: blue
309
+ # foo
310
+ # &.bar
311
+ # color: blue
280
312
  #
281
313
  # becomes
282
314
  #
283
- # foo.bar
284
- # color: blue
315
+ # foo.bar
316
+ # color: blue
285
317
  #
318
+ # @param root [Tree::Node] The parent node
286
319
  def flatten_rules(root)
287
320
  root.children.each { |child| flatten_rule(child) if child.is_a?(Tree::RuleNode) }
288
321
  end
289
322
 
323
+ # Flattens a single rule
324
+ #
325
+ # @param rule [Tree::RuleNode] The candidate for flattening
326
+ # @see #flatten_rules
290
327
  def flatten_rule(rule)
291
328
  while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
292
329
  child = rule.children.first
@@ -305,18 +342,19 @@ module Sass
305
342
 
306
343
  # Transform
307
344
  #
308
- # foo
309
- # bar
310
- # color: blue
311
- # baz
312
- # color: blue
345
+ # foo
346
+ # bar
347
+ # color: blue
348
+ # baz
349
+ # color: blue
313
350
  #
314
351
  # into
315
352
  #
316
- # foo
317
- # bar, baz
318
- # color: blue
353
+ # foo
354
+ # bar, baz
355
+ # color: blue
319
356
  #
357
+ # @param rule [Tree::RuleNode] The candidate for flattening
320
358
  def fold_commas(root)
321
359
  prev_rule = nil
322
360
  root.children.map! do |child|
data/lib/sass/engine.rb CHANGED
@@ -20,20 +20,55 @@ require 'sass/files'
20
20
  require 'haml/shared'
21
21
 
22
22
  module Sass
23
- # :stopdoc:
23
+ # A Sass mixin.
24
+ #
25
+ # `name`: [{String}]
26
+ # : The name of the mixin.
27
+ #
28
+ # `args`: [{Array}<({String}, {Script::Node})>]
29
+ # : The arguments for the mixin.
30
+ # Each element is a tuple containing the name of the argument
31
+ # and the parse tree for the default value of the argument.
32
+ #
33
+ # `environment`: [{Sass::Environment}]
34
+ # : The environment in which the mixin was defined.
35
+ # This is captured so that the mixin can have access
36
+ # to local variables defined in its scope.
37
+ #
38
+ # `tree`: [{Sass::Tree::Node}]
39
+ # : The parse tree for the mixin.
24
40
  Mixin = Struct.new(:name, :args, :environment, :tree)
25
- # :startdoc:
26
41
 
27
- # This is the class where all the parsing and processing of the Sass
28
- # template is done. It can be directly used by the user by creating a
29
- # new instance and calling <tt>render</tt> to render the template. For example:
42
+ # This class handles the parsing and compilation of the Sass template.
43
+ # Example usage:
30
44
  #
31
- # template = File.load('stylesheets/sassy.sass')
32
- # sass_engine = Sass::Engine.new(template)
33
- # output = sass_engine.render
34
- # puts output
45
+ # template = File.load('stylesheets/sassy.sass')
46
+ # sass_engine = Sass::Engine.new(template)
47
+ # output = sass_engine.render
48
+ # puts output
35
49
  class Engine
36
50
  include Haml::Util
51
+
52
+ # A line of Sass code.
53
+ #
54
+ # `text`: [{String}]
55
+ # : The text in the line, without any whitespace at the beginning or end.
56
+ #
57
+ # `tabs`: [{Fixnum}]
58
+ # : The level of indentation of the line.
59
+ #
60
+ # `index`: [{Fixnum}]
61
+ # : The line number in the original document.
62
+ #
63
+ # `offset`: [{Fixnum}]
64
+ # : The number of bytes in on the line that the text begins.
65
+ # This ends up being the number of bytes of leading whitespace.
66
+ #
67
+ # `filename`: [{String}]
68
+ # : The name of the file in which this line appeared.
69
+ #
70
+ # `children`: [{Array}<{Line}>]
71
+ # : The lines nested below this one.
37
72
  Line = Struct.new(:text, :tabs, :index, :offset, :filename, :children)
38
73
 
39
74
  # The character that begins a CSS attribute.
@@ -86,30 +121,28 @@ module Sass
86
121
  :cache_location => './.sass-cache',
87
122
  }.freeze
88
123
 
89
- # Creates a new instace of Sass::Engine that will compile the given
90
- # template string when <tt>render</tt> is called.
91
- # See README.rdoc for available options.
92
- #
93
- #--
94
- #
95
- # TODO: Add current options to REFRENCE. Remember :filename!
96
- #
97
- # When adding options, remember to add information about them
98
- # to README.rdoc!
99
- #++
100
- #
124
+ # @param template [String] The Sass template.
125
+ # @param options [Hash<Symbol, Object>] An options hash;
126
+ # see [the Sass options documentation](../Sass.html#sass_options)
101
127
  def initialize(template, options={})
102
128
  @options = DEFAULT_OPTIONS.merge(options)
103
129
  @template = template
104
130
  end
105
131
 
106
- # Processes the template and returns the result as a string.
132
+ # Render the template to CSS.
133
+ #
134
+ # @return [String] The CSS
135
+ # @raise [Sass::SyntaxError] if there's an error in the document
107
136
  def render
108
137
  to_tree.render
109
138
  end
110
139
 
111
140
  alias_method :to_css, :render
112
141
 
142
+ # Parses the document into its parse tree.
143
+ #
144
+ # @return [Sass::Tree::Node] The root of the parse tree.
145
+ # @raise [Sass::SyntaxError] if there's an error in the document
113
146
  def to_tree
114
147
  root = Tree::Node.new
115
148
  append_children(root, tree(tabulate(@template)).first, true)
@@ -1,8 +1,24 @@
1
1
  module Sass
2
+ # The lexical environment for SassScript.
3
+ # This keeps track of variable and mixin definitions.
4
+ #
5
+ # A new environment is created for each level of Sass nesting.
6
+ # This allows variables to be lexically scoped.
7
+ # The new environment refers to the environment in the upper scope,
8
+ # so it has access to variables defined in enclosing scopes,
9
+ # but new variables are defined locally.
10
+ #
11
+ # Environment also keeps track of the {Engine} options
12
+ # so that they can be made available to {Sass::Script::Functions}.
2
13
  class Environment
14
+ # The enclosing environment,
15
+ # or nil if this is the global environment.
16
+ #
17
+ # @return [Environment]
3
18
  attr_reader :parent
4
19
  attr_writer :options
5
20
 
21
+ # @param parent [Environment] See \{#parent}
6
22
  def initialize(parent = nil)
7
23
  @vars = {}
8
24
  @mixins = {}
@@ -11,38 +27,53 @@ module Sass
11
27
  set_var("important", Script::String.new("!important")) unless @parent
12
28
  end
13
29
 
30
+ # The options hash.
31
+ # See [the Sass options documentation](../Sass.html#sass_options).
32
+ #
33
+ # @return [Hash<Symbol, Object>]
14
34
  def options
15
35
  @options || (parent && parent.options) || {}
16
36
  end
17
37
 
18
- def self.inherited_hash(name)
19
- class_eval <<RUBY, __FILE__, __LINE__ + 1
20
- def #{name}(name)
21
- @#{name}s[name] || @parent && @parent.#{name}(name)
22
- end
38
+ class << self
39
+ private
23
40
 
24
- def set_#{name}(name, value)
25
- @#{name}s[name] = value unless try_set_#{name}(name, value)
26
- end
41
+ # Note: when updating this,
42
+ # update haml/yard/inherited_hash.rb as well.
43
+ def inherited_hash(name)
44
+ class_eval <<RUBY, __FILE__, __LINE__ + 1
45
+ def #{name}(name)
46
+ @#{name}s[name] || @parent && @parent.#{name}(name)
47
+ end
27
48
 
28
- def try_set_#{name}(name, value)
29
- if @#{name}s.include?(name)
30
- @#{name}s[name] = value
31
- true
32
- elsif @parent
33
- @parent.try_set_#{name}(name, value)
34
- else
35
- false
49
+ def set_#{name}(name, value)
50
+ @#{name}s[name] = value unless try_set_#{name}(name, value)
51
+ end
52
+
53
+ def try_set_#{name}(name, value)
54
+ if @#{name}s.include?(name)
55
+ @#{name}s[name] = value
56
+ true
57
+ elsif @parent
58
+ @parent.try_set_#{name}(name, value)
59
+ else
60
+ false
61
+ end
36
62
  end
37
- end
38
- protected :try_set_#{name}
63
+ protected :try_set_#{name}
39
64
 
40
- def set_local_#{name}(name, value)
41
- @#{name}s[name] = value
42
- end
65
+ def set_local_#{name}(name, value)
66
+ @#{name}s[name] = value
67
+ end
43
68
  RUBY
69
+ end
44
70
  end
71
+
72
+ # variable
73
+ # Script::Literal
45
74
  inherited_hash :var
75
+ # mixin
76
+ # Engine::Mixin
46
77
  inherited_hash :mixin
47
78
  end
48
79
  end
data/lib/sass/error.rb CHANGED
@@ -1,25 +1,34 @@
1
1
  module Sass
2
- # Sass::SyntaxError encapsulates information about the exception,
3
- # such as the line of the Sass template it was raised on
2
+ # An exception class that keeps track of
3
+ # the line of the Sass template it was raised on
4
4
  # and the Sass file that was being parsed (if applicable).
5
- # It also provides a handy way to rescue only exceptions raised
6
- # because of a faulty template.
5
+ #
6
+ # All Sass errors are raised as {Sass::SyntaxError}s.
7
7
  class SyntaxError < StandardError
8
- # The line of the Sass template on which the exception was thrown.
8
+ # The line of the Sass template on which the error occurred.
9
+ #
10
+ # @return [Fixnum]
9
11
  attr_accessor :sass_line
10
12
 
11
13
  # The name of the file that was being parsed when the exception was raised.
12
- # This will be nil unless Sass is being used as an ActionView plugin.
14
+ # This could be `nil` if no filename is available.
15
+ #
16
+ # @return [String]
13
17
  attr_reader :sass_filename
14
18
 
15
- # Creates a new SyntaxError.
16
- # +lineno+ should be the line of the Sass template on which the error occurred.
19
+ # @param msg [String] The error message
20
+ # @param lineno [Fixnum] See \{#sass\_line}
17
21
  def initialize(msg, lineno = nil)
18
22
  @message = msg
19
23
  @sass_line = lineno
20
24
  end
21
25
 
22
- # Add information about the filename and line on which the error was raised.
26
+ # Add information about the filename and line on which the error was raised,
27
+ # and re-raises the exception.
28
+ #
29
+ # @param filename [String] See \{#sass\_filename}
30
+ # @param line [Fixnum] See \{#sass\_line}
31
+ # @raise [Sass::SyntaxError] self
23
32
  def add_metadata(filename, line)
24
33
  self.sass_line ||= line
25
34
  add_backtrace_entry(filename) unless sass_filename
@@ -27,15 +36,17 @@ module Sass
27
36
  end
28
37
 
29
38
  # Adds a properly formatted entry to the exception's backtrace.
30
- # +filename+ should be the file in which the error occurred,
31
- # if applicable (defaults to "(sass)").
39
+ #
40
+ # @param filename [String] The file in which the error occurred,
41
+ # if applicable (defaults to "(sass)")
32
42
  def add_backtrace_entry(filename) # :nodoc:
33
43
  @sass_filename ||= filename
34
44
  self.backtrace ||= []
35
45
  self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}"
36
46
  end
37
47
 
38
- def to_s # :nodoc:
48
+ # @return [String] The error message
49
+ def to_s
39
50
  @message
40
51
  end
41
52
  end
data/lib/sass/files.rb CHANGED
@@ -7,6 +7,13 @@ module Sass
7
7
  module Files
8
8
  extend self
9
9
 
10
+ # Returns the {Sass::Tree} for the given file,
11
+ # reading it from the Sass cache if possible.
12
+ #
13
+ # @param filename [String] The path to the Sass file
14
+ # @param options [Hash<Symbol, Object>] The options hash.
15
+ # Only the [`:cache_location`](../Sass.html#cache-option) option is used
16
+ # @raise [Sass::SyntaxError] if there's an error in the document
10
17
  def tree_for(filename, options)
11
18
  options = Sass::Engine::DEFAULT_OPTIONS.merge(options)
12
19
  text = File.read(filename)
@@ -35,6 +42,26 @@ module Sass
35
42
  root
36
43
  end
37
44
 
45
+ # Find the full filename of a Sass or CSS file to import.
46
+ # This follows Sass's import rules:
47
+ # if the filename given ends in `".sass"` or `".css"`,
48
+ # it will try to find that type of file;
49
+ # otherwise, it will try to find the corresponding Sass file
50
+ # and fall back on CSS if it's not available.
51
+ #
52
+ # Any Sass filename returned will correspond to
53
+ # an actual Sass file on the filesystem.
54
+ # CSS filenames, however, may not;
55
+ # they're expected to be put through directly to the stylesheet
56
+ # as CSS `@import` statements.
57
+ #
58
+ # @param filename [String] The filename to search for
59
+ # @param load_paths [Array<String>] The set of filesystem paths
60
+ # to search for Sass files.
61
+ # @return [String] The filename of the imported file.
62
+ # This is an absolute path if the file is a `".sass"` file.
63
+ # @raise [Sass::SyntaxError] if `filename` ends in ``".sass"``
64
+ # and no corresponding Sass file could be found.
38
65
  def find_file_to_import(filename, load_paths)
39
66
  was_sass = false
40
67
  original_filename = filename
@@ -25,7 +25,7 @@ unless defined?(Sass::MERB_LOADED)
25
25
 
26
26
  if version[0] > 0 || version[1] >= 9
27
27
 
28
- class Merb::Rack::Application # :nodoc:
28
+ class Merb::Rack::Application
29
29
  def call_with_sass(env)
30
30
  if !Sass::Plugin.checked_for_updates ||
31
31
  Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
@@ -40,7 +40,7 @@ unless defined?(Sass::MERB_LOADED)
40
40
 
41
41
  else
42
42
 
43
- class MerbHandler # :nodoc:
43
+ class MerbHandler
44
44
  def process_with_sass(request, response)
45
45
  if !Sass::Plugin.checked_for_updates ||
46
46
  Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
@@ -7,7 +7,6 @@ unless defined?(Sass::RAILS_LOADED)
7
7
  :always_check => RAILS_ENV != "production",
8
8
  :full_exception => RAILS_ENV != "production")
9
9
 
10
- # :stopdoc:
11
10
  module ActionController
12
11
  class Base
13
12
  alias_method :sass_old_process, :process
@@ -21,5 +20,4 @@ unless defined?(Sass::RAILS_LOADED)
21
20
  end
22
21
  end
23
22
  end
24
- # :startdoc:
25
23
  end