sass 3.2.9 → 3.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
1
+ Copyright (c) 2006-2013 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.9
1
+ 3.2.10
@@ -1 +1 @@
1
- 10 May 2013 23:56:29 UTC
1
+ 27 July 2013 01:11:34 UTC
@@ -637,7 +637,6 @@ WARNING
637
637
  value = [line.text]
638
638
  else
639
639
  value = self.class.parse_interp(line.text, line.index, line.offset, :filename => @filename)
640
- value[0].slice!(2) if loud # get rid of the "!"
641
640
  end
642
641
  value = with_extracted_values(value) do |str|
643
642
  str = str.gsub(/^#{line.comment_tab_str}/m, '')[2..-1] # get rid of // or /*
@@ -165,9 +165,9 @@ module Sass
165
165
 
166
166
  <<END
167
167
  /*
168
- #{header}
168
+ #{header.gsub("*/", "*\\/")}
169
169
 
170
- Backtrace:\n#{e.backtrace.join("\n")}
170
+ Backtrace:\n#{e.backtrace.join("\n").gsub("*/", "*\\/")}
171
171
  */
172
172
  body:before {
173
173
  white-space: pre;
@@ -157,7 +157,7 @@ module Sass
157
157
 
158
158
  def write_output(text, destination)
159
159
  if destination.is_a?(String)
160
- File.open(destination, 'w') {|file| file.write(text)}
160
+ open_file(destination, 'w') {|file| file.write(text)}
161
161
  else
162
162
  destination.write(text)
163
163
  end
@@ -168,7 +168,10 @@ module Sass
168
168
  def open_file(filename, flag = 'r')
169
169
  return if filename.nil?
170
170
  flag = 'wb' if @options[:unix_newlines] && flag == 'w'
171
- File.open(filename, flag)
171
+ file = File.open(filename, flag)
172
+ return file unless block_given?
173
+ yield file
174
+ file.close
172
175
  end
173
176
 
174
177
  def handle_load_error(err)
@@ -683,7 +686,7 @@ END
683
686
  end
684
687
  end
685
688
 
686
- output = File.open(input.path, 'w') if @options[:in_place]
689
+ output = input.path if @options[:in_place]
687
690
  write_output(out, output)
688
691
  rescue ::Sass::SyntaxError => e
689
692
  raise e if @options[:trace]
@@ -2,7 +2,7 @@ module Sass::Script
2
2
  # Methods in this module are accessible from the SassScript context.
3
3
  # For example, you can write
4
4
  #
5
- # $color = hsl(120deg, 100%, 50%)
5
+ # $color: hsl(120deg, 100%, 50%)
6
6
  #
7
7
  # and it will call {Sass::Script::Functions#hsl}.
8
8
  #
@@ -13,13 +13,10 @@ module Sass::Script
13
13
  # ## RGB Functions
14
14
  #
15
15
  # \{#rgb rgb($red, $green, $blue)}
16
- # : Converts an `rgb(red, green, blue)` triplet into a color.
16
+ # : Creates a {Color} from red, green, and blue values.
17
17
  #
18
18
  # \{#rgba rgba($red, $green, $blue, $alpha)}
19
- # : Converts an `rgba(red, green, blue, alpha)` quadruplet into a color.
20
- #
21
- # \{#rgba rgba($color, $alpha)}
22
- # : Adds an alpha layer to any color value.
19
+ # : Creates a {Color} from red, green, blue, and alpha values.
23
20
  #
24
21
  # \{#red red($color)}
25
22
  # : Gets the red component of a color.
@@ -36,10 +33,11 @@ module Sass::Script
36
33
  # ## HSL Functions
37
34
  #
38
35
  # \{#hsl hsl($hue, $saturation, $lightness)}
39
- # : Converts an `hsl(hue, saturation, lightness)` triplet into a color.
36
+ # : Creates a {Color} from hue, saturation, and lightness values.
40
37
  #
41
38
  # \{#hsla hsla($hue, $saturation, $lightness, $alpha)}
42
- # : Converts an `hsla(hue, saturation, lightness, alpha)` quadruplet into a color.
39
+ # : Creates a {Color} from hue, saturation, lightness, lightness, and alpha
40
+ # values.
43
41
  #
44
42
  # \{#hue hue($color)}
45
43
  # : Gets the hue component of a color.
@@ -80,7 +78,7 @@ module Sass::Script
80
78
  # : Gets the alpha component (opacity) of a color.
81
79
  #
82
80
  # \{#rgba rgba($color, $alpha)}
83
- # : Add or change an alpha layer for any color value.
81
+ # : Changes the alpha component for a color.
84
82
  #
85
83
  # \{#opacify opacify($color, $amount)} / \{#fade_in fade-in($color, $amount)}
86
84
  # : Makes a color more opaque.
@@ -91,10 +89,10 @@ module Sass::Script
91
89
  # ## Other Color Functions
92
90
  #
93
91
  # \{#adjust_color adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\])}
94
- # : Increase or decrease any of the components of a color.
92
+ # : Increases or decreases one or more components of a color.
95
93
  #
96
94
  # \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$saturation\], \[$lightness\], \[$alpha\])}
97
- # : Fluidly scale one or more components of a color.
95
+ # : Fluidly scales one or more properties of a color.
98
96
  #
99
97
  # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\])}
100
98
  # : Changes one or more properties of a color.
@@ -105,7 +103,7 @@ module Sass::Script
105
103
  # ## String Functions
106
104
  #
107
105
  # \{#unquote unquote($string)}
108
- # : Removes the quotes from a string.
106
+ # : Removes quotes from a string.
109
107
  #
110
108
  # \{#quote quote($string)}
111
109
  # : Adds quotes to a string.
@@ -119,19 +117,19 @@ module Sass::Script
119
117
  # : Rounds a number to the nearest whole number.
120
118
  #
121
119
  # \{#ceil ceil($value)}
122
- # : Rounds a number up to the nearest whole number.
120
+ # : Rounds a number up to the next whole number.
123
121
  #
124
122
  # \{#floor floor($value)}
125
- # : Rounds a number down to the nearest whole number.
123
+ # : Rounds a number down to the previous whole number.
126
124
  #
127
125
  # \{#abs abs($value)}
128
126
  # : Returns the absolute value of a number.
129
127
  #
130
- # \{#min min($x1, $x2, ...)\}
131
- # : Finds the minimum of several values.
128
+ # \{#min min($numbers...)\}
129
+ # : Finds the minimum of several numbers.
132
130
  #
133
- # \{#max max($x1, $x2, ...)\}
134
- # : Finds the maximum of several values.
131
+ # \{#max max($numbers...)\}
132
+ # : Finds the maximum of several numbers.
135
133
  #
136
134
  # ## List Functions {#list-functions}
137
135
  #
@@ -147,11 +145,11 @@ module Sass::Script
147
145
  # \{#append append($list1, $val, \[$separator\])}
148
146
  # : Appends a single value onto the end of a list.
149
147
  #
150
- # \{#zip zip($list1, $list2, ...)}
148
+ # \{#zip zip($lists...)}
151
149
  # : Combines several lists into a single multidimensional list.
152
150
  #
153
151
  # \{#index index($list, $value)}
154
- # : Returns the position of a value within a list, or false.
152
+ # : Returns the position of a value within a list.
155
153
  #
156
154
  # ## Introspection Functions
157
155
  #
@@ -159,18 +157,19 @@ module Sass::Script
159
157
  # : Returns the type of a value.
160
158
  #
161
159
  # \{#unit unit($number)}
162
- # : Returns the units associated with a number.
160
+ # : Returns the unit(s) associated with a number.
163
161
  #
164
162
  # \{#unitless unitless($number)}
165
- # : Returns whether a number has units or not.
163
+ # : Returns whether a number has units.
166
164
  #
167
165
  # \{#comparable comparable($number-1, $number-2)}
168
- # : Returns whether two numbers can be added or compared.
166
+ # : Returns whether two numbers can be added, subtracted, or compared.
169
167
  #
170
168
  # ## Miscellaneous Functions
171
169
  #
172
170
  # \{#if if($condition, $if-true, $if-false)}
173
- # : Returns one of two values, depending on whether or not a condition is true.
171
+ # : Returns one of two values, depending on whether or not `$condition` is
172
+ # true.
174
173
  #
175
174
  # ## Adding Custom Functions
176
175
  #
@@ -246,6 +245,12 @@ module Sass::Script
246
245
  # but none of them but the first will be used
247
246
  # unless the user uses keyword arguments.
248
247
  #
248
+ # @example
249
+ # declare :rgba, [:hex, :alpha]
250
+ # declare :rgba, [:red, :green, :blue, :alpha]
251
+ # declare :accepts_anything, [], :var_args => true, :var_kwargs => true
252
+ # declare :some_func, [:foo, :bar, :baz], :var_kwargs => true
253
+ #
249
254
  # @param method_name [Symbol] The name of the method
250
255
  # whose signature is being declared.
251
256
  # @param args [Array<Symbol>] The names of the arguments for the function signature.
@@ -259,12 +264,6 @@ module Sass::Script
259
264
  # to {Sass::Script::Literal}s as the last argument.
260
265
  # In addition, if this is true and `:var_args` is not,
261
266
  # Sass will ensure that the last argument passed is a hash.
262
- #
263
- # @example
264
- # declare :rgba, [:hex, :alpha]
265
- # declare :rgba, [:red, :green, :blue, :alpha]
266
- # declare :accepts_anything, [], :var_args => true, :var_kwargs => true
267
- # declare :some_func, [:foo, :bar, :baz], :var_kwargs => true
268
267
  def self.declare(method_name, args, options = {})
269
268
  @signatures[method_name] ||= []
270
269
  @signatures[method_name] << Signature.new(
@@ -337,11 +336,11 @@ module Sass::Script
337
336
  # assert_type value, :Number
338
337
  # @param value [Sass::Script::Literal] A SassScript value
339
338
  # @param type [Symbol] The name of the type the value is expected to be
340
- # @param name [String, nil] The name of the argument.
339
+ # @param name [String, Symbol, nil] The name of the argument.
341
340
  def assert_type(value, type, name = nil)
342
341
  return if value.is_a?(Sass::Script.const_get(type))
343
342
  err = "#{value.inspect} is not a #{type.to_s.downcase}"
344
- err = "$#{name}: " + err if name
343
+ err = "$#{name.to_s.gsub('_', '-')}: " + err if name
345
344
  raise ArgumentError.new(err)
346
345
  end
347
346
  end
@@ -365,67 +364,69 @@ module Sass::Script
365
364
 
366
365
  # Creates a {Color} object from red, green, and blue values.
367
366
  #
368
- # @param red [Number]
369
- # A number between 0 and 255 inclusive,
370
- # or between 0% and 100% inclusive
371
- # @param green [Number]
372
- # A number between 0 and 255 inclusive,
373
- # or between 0% and 100% inclusive
374
- # @param blue [Number]
375
- # A number between 0 and 255 inclusive,
376
- # or between 0% and 100% inclusive
377
367
  # @see #rgba
368
+ # @overload rgb($red, $green, $blue)
369
+ # @param $red [Number] The amount of red in the color. Must be between 0 and
370
+ # 255 inclusive, or between `0%` and `100%` inclusive
371
+ # @param $green [Number] The amount of green in the color. Must be between 0
372
+ # and 255 inclusive, or between `0%` and `100%` inclusive
373
+ # @param $blue [Number] The amount of blue in the color. Must be between 0
374
+ # and 255 inclusive, or between `0%` and `100%` inclusive
378
375
  # @return [Color]
376
+ # @raise [ArgumentError] if any parameter is the wrong type or out of bounds
379
377
  def rgb(red, green, blue)
380
- assert_type red, :Number
381
- assert_type green, :Number
382
- assert_type blue, :Number
378
+ assert_type red, :Number, :red
379
+ assert_type green, :Number, :green
380
+ assert_type blue, :Number, :blue
383
381
 
384
- Color.new([red, green, blue].map do |c|
382
+ Color.new([[red, :red], [green, :green], [blue, :blue]].map do |(c, name)|
385
383
  v = c.value
386
384
  if c.numerator_units == ["%"] && c.denominator_units.empty?
387
- v = Sass::Util.check_range("Color value", 0..100, c, '%')
385
+ v = Sass::Util.check_range("$#{name}: Color value", 0..100, c, '%')
388
386
  v * 255 / 100.0
389
387
  else
390
- Sass::Util.check_range("Color value", 0..255, c)
388
+ Sass::Util.check_range("$#{name}: Color value", 0..255, c)
391
389
  end
392
390
  end)
393
391
  end
394
392
  declare :rgb, [:red, :green, :blue]
395
393
 
394
+ # Creates a {Color} from red, green, blue, and alpha values.
396
395
  # @see #rgb
397
- # @overload rgba(red, green, blue, alpha)
398
- # Creates a {Color} object from red, green, and blue values,
399
- # as well as an alpha channel indicating opacity.
400
- #
401
- # @param red [Number]
402
- # A number between 0 and 255 inclusive
403
- # @param green [Number]
404
- # A number between 0 and 255 inclusive
405
- # @param blue [Number]
406
- # A number between 0 and 255 inclusive
407
- # @param alpha [Number]
408
- # A number between 0 and 1
396
+ #
397
+ # @overload rgba($red, $green, $blue, $alpha)
398
+ # @param $red [Number] The amount of red in the color. Must be between 0
399
+ # and 255 inclusive
400
+ # @param $green [Number] The amount of green in the color. Must be between
401
+ # 0 and 255 inclusive
402
+ # @param $blue [Number] The amount of blue in the color. Must be between 0
403
+ # and 255 inclusive
404
+ # @param $alpha [Number] The opacity of the color. Must be between 0 and 1
405
+ # inclusive
409
406
  # @return [Color]
407
+ # @raise [ArgumentError] if any parameter is the wrong type or out of
408
+ # bounds
410
409
  #
411
- # @overload rgba(color, alpha)
412
- # Sets the opacity of a color.
410
+ # @overload rgba($color, $alpha)
411
+ # Sets the opacity of an existing color.
413
412
  #
414
413
  # @example
415
414
  # rgba(#102030, 0.5) => rgba(16, 32, 48, 0.5)
416
415
  # rgba(blue, 0.2) => rgba(0, 0, 255, 0.2)
417
416
  #
418
- # @param color [Color]
419
- # @param alpha [Number]
420
- # A number between 0 and 1
417
+ # @param $color [Color] The color whose opacity will be changed.
418
+ # @param $alpha [Number] The new opacity of the color. Must be between 0
419
+ # and 1 inclusive
421
420
  # @return [Color]
421
+ # @raise [ArgumentError] if `$alpha` is out of bounds or either parameter
422
+ # is the wrong type
422
423
  def rgba(*args)
423
424
  case args.size
424
425
  when 2
425
426
  color, alpha = args
426
427
 
427
- assert_type color, :Color
428
- assert_type alpha, :Number
428
+ assert_type color, :Color, :color
429
+ assert_type alpha, :Number, :alpha
429
430
 
430
431
  Sass::Util.check_range('Alpha channel', 0..1, alpha)
431
432
  color.with(:alpha => alpha.value)
@@ -439,43 +440,50 @@ module Sass::Script
439
440
  declare :rgba, [:red, :green, :blue, :alpha]
440
441
  declare :rgba, [:color, :alpha]
441
442
 
442
- # Creates a {Color} object from hue, saturation, and lightness.
443
- # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
443
+ # Creates a {Color} from hue, saturation, and lightness values. Uses the
444
+ # algorithm from the [CSS3 spec][].
445
+ #
446
+ # [CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
444
447
  #
445
- # @param hue [Number] The hue of the color.
446
- # Should be between 0 and 360 degrees, inclusive
447
- # @param saturation [Number] The saturation of the color.
448
- # Must be between `0%` and `100%`, inclusive
449
- # @param lightness [Number] The lightness of the color.
450
- # Must be between `0%` and `100%`, inclusive
451
- # @return [Color] The resulting color
452
448
  # @see #hsla
453
- # @raise [ArgumentError] if `saturation` or `lightness` are out of bounds
449
+ # @overload hsl($hue, $saturation, $lightness)
450
+ # @param $hue [Number] The hue of the color. Should be between 0 and 360
451
+ # degrees, inclusive
452
+ # @param $saturation [Number] The saturation of the color. Must be between
453
+ # `0%` and `100%`, inclusive
454
+ # @param $lightness [Number] The lightness of the color. Must be between
455
+ # `0%` and `100%`, inclusive
456
+ # @return [Color]
457
+ # @raise [ArgumentError] if `$saturation` or `$lightness` are out of bounds
458
+ # or any parameter is the wrong type
454
459
  def hsl(hue, saturation, lightness)
455
460
  hsla(hue, saturation, lightness, Number.new(1))
456
461
  end
457
462
  declare :hsl, [:hue, :saturation, :lightness]
458
463
 
459
- # Creates a {Color} object from hue, saturation, and lightness,
460
- # as well as an alpha channel indicating opacity.
461
- # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
462
- #
463
- # @param hue [Number] The hue of the color.
464
- # Should be between 0 and 360 degrees, inclusive
465
- # @param saturation [Number] The saturation of the color.
466
- # Must be between `0%` and `100%`, inclusive
467
- # @param lightness [Number] The lightness of the color.
468
- # Must be between `0%` and `100%`, inclusive
469
- # @param alpha [Number] The opacity of the color.
470
- # Must be between 0 and 1, inclusive
471
- # @return [Color] The resulting color
464
+ # Creates a {Color} from hue, saturation, lightness, lightness, and alpha
465
+ # values. Uses the algorithm from the [CSS3 spec][].
466
+ #
467
+ # [CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
468
+ #
472
469
  # @see #hsl
473
- # @raise [ArgumentError] if `saturation`, `lightness`, or `alpha` are out of bounds
470
+ # @overload hsla($hue, $saturation, $lightness, $alpha)
471
+ # @param $hue [Number] The hue of the color. Should be between 0 and 360
472
+ # degrees, inclusive
473
+ # @param $saturation [Number] The saturation of the color. Must be between
474
+ # `0%` and `100%`, inclusive
475
+ # @param $lightness [Number] The lightness of the color. Must be between
476
+ # `0%` and `100%`, inclusive
477
+ # @param $alpha [Number] The opacity of the color. Must be between 0 and 1,
478
+ # inclusive
479
+ # @return [Color]
480
+ # @raise [ArgumentError] if `$saturation`, `$lightness`, or `$alpha` are out
481
+ # of bounds or any parameter is the wrong type
474
482
  def hsla(hue, saturation, lightness, alpha)
475
- assert_type hue, :Number
476
- assert_type saturation, :Number
477
- assert_type lightness, :Number
478
- assert_type alpha, :Number
483
+ assert_type hue, :Number, :hue
484
+ assert_type saturation, :Number, :saturation
485
+ assert_type lightness, :Number, :lightness
486
+ assert_type alpha, :Number, :alpha
479
487
 
480
488
  Sass::Util.check_range('Alpha channel', 0..1, alpha)
481
489
 
@@ -487,101 +495,112 @@ module Sass::Script
487
495
  end
488
496
  declare :hsla, [:hue, :saturation, :lightness, :alpha]
489
497
 
490
- # Returns the red component of a color.
498
+ # Gets the red component of a color. Calculated from HSL where necessary via
499
+ # [this algorithm][hsl-to-rgb].
491
500
  #
492
- # @param color [Color]
493
- # @return [Number]
494
- # @raise [ArgumentError] If `color` isn't a color
501
+ # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
502
+ #
503
+ # @overload red($color)
504
+ # @param $color [Color]
505
+ # @return [Number] The red component, between 0 and 255 inclusive
506
+ # @raise [ArgumentError] if `$color` isn't a color
495
507
  def red(color)
496
- assert_type color, :Color
508
+ assert_type color, :Color, :color
497
509
  Sass::Script::Number.new(color.red)
498
510
  end
499
511
  declare :red, [:color]
500
512
 
501
- # Returns the green component of a color.
513
+ # Gets the green component of a color. Calculated from HSL where necessary
514
+ # via [this algorithm][hsl-to-rgb].
502
515
  #
503
- # @param color [Color]
504
- # @return [Number]
505
- # @raise [ArgumentError] If `color` isn't a color
516
+ # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
517
+ #
518
+ # @overload green($color)
519
+ # @param $color [Color]
520
+ # @return [Number] The green component, between 0 and 255 inclusive
521
+ # @raise [ArgumentError] if `$color` isn't a color
506
522
  def green(color)
507
- assert_type color, :Color
523
+ assert_type color, :Color, :color
508
524
  Sass::Script::Number.new(color.green)
509
525
  end
510
526
  declare :green, [:color]
511
527
 
512
- # Returns the blue component of a color.
528
+ # Gets the blue component of a color. Calculated from HSL where necessary
529
+ # via [this algorithm][hsl-to-rgb].
513
530
  #
514
- # @param color [Color]
515
- # @return [Number]
516
- # @raise [ArgumentError] If `color` isn't a color
531
+ # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
532
+ #
533
+ # @overload blue($color)
534
+ # @param $color [Color]
535
+ # @return [Number] The blue component, between 0 and 255 inclusive
536
+ # @raise [ArgumentError] if `$color` isn't a color
517
537
  def blue(color)
518
- assert_type color, :Color
538
+ assert_type color, :Color, :color
519
539
  Sass::Script::Number.new(color.blue)
520
540
  end
521
541
  declare :blue, [:color]
522
542
 
523
- # Returns the hue component of a color.
524
- #
525
- # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
543
+ # Returns the hue component of a color. See [the CSS3 HSL
544
+ # specification][hsl]. Calculated from RGB where necessary via [this
545
+ # algorithm][rgb-to-hsl].
526
546
  #
527
- # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
547
+ # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
548
+ # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
528
549
  #
529
- # @param color [Color]
530
- # @return [Number] between 0deg and 360deg
531
- # @see #adjust_hue
532
- # @raise [ArgumentError] if `color` isn't a color
550
+ # @overload hue($color)
551
+ # @param $color [Color]
552
+ # @return [Number] The hue component, between 0deg and 360deg
553
+ # @raise [ArgumentError] if `$color` isn't a color
533
554
  def hue(color)
534
- assert_type color, :Color
555
+ assert_type color, :Color, :color
535
556
  Sass::Script::Number.new(color.hue, ["deg"])
536
557
  end
537
558
  declare :hue, [:color]
538
559
 
539
- # Returns the saturation component of a color.
560
+ # Returns the saturation component of a color. See [the CSS3 HSL
561
+ # specification][hsl]. Calculated from RGB where necessary via [this
562
+ # algorithm][rgb-to-hsl].
540
563
  #
541
- # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
564
+ # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
565
+ # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
542
566
  #
543
- # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
544
- #
545
- # @param color [Color]
546
- # @return [Number] between 0% and 100%
547
- # @see #saturate
548
- # @see #desaturate
549
- # @raise [ArgumentError] if `color` isn't a color
567
+ # @overload saturation($color)
568
+ # @param $color [Color]
569
+ # @return [Number] The saturation component, between 0% and 100%
570
+ # @raise [ArgumentError] if `$color` isn't a color
550
571
  def saturation(color)
551
- assert_type color, :Color
572
+ assert_type color, :Color, :color
552
573
  Sass::Script::Number.new(color.saturation, ["%"])
553
574
  end
554
575
  declare :saturation, [:color]
555
576
 
556
- # Returns the hue component of a color.
557
- #
558
- # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
577
+ # Returns the lightness component of a color. See [the CSS3 HSL
578
+ # specification][hsl]. Calculated from RGB where necessary via [this
579
+ # algorithm][rgb-to-hsl].
559
580
  #
560
- # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
581
+ # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
582
+ # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
561
583
  #
562
- # @param color [Color]
563
- # @return [Number] between 0% and 100%
564
- # @see #lighten
565
- # @see #darken
566
- # @raise [ArgumentError] if `color` isn't a color
584
+ # @overload lightness($color)
585
+ # @param $color [Color]
586
+ # @return [Number] The lightness component, between 0% and 100%
587
+ # @raise [ArgumentError] if `$color` isn't a color
567
588
  def lightness(color)
568
- assert_type color, :Color
589
+ assert_type color, :Color, :color
569
590
  Sass::Script::Number.new(color.lightness, ["%"])
570
591
  end
571
592
  declare :lightness, [:color]
572
593
 
573
- # Returns the alpha component (opacity) of a color.
574
- # This is 1 unless otherwise specified.
594
+ # Returns the alpha component (opacity) of a color. This is 1 unless
595
+ # otherwise specified.
575
596
  #
576
- # This function also supports the proprietary Microsoft
577
- # `alpha(opacity=20)` syntax.
597
+ # This function also supports the proprietary Microsoft `alpha(opacity=20)`
598
+ # syntax as a special case.
578
599
  #
579
- # @overload def alpha(color)
580
- # @param color [Color]
581
- # @return [Number]
582
- # @see #opacify
583
- # @see #transparentize
584
- # @raise [ArgumentError] If `color` isn't a color
600
+ # @overload alpha($color)
601
+ # @param $color [Color]
602
+ # @return [Number] The alpha component, between 0 and 1
603
+ # @raise [ArgumentError] if `$color` isn't a color
585
604
  def alpha(*args)
586
605
  if args.all? do |a|
587
606
  a.is_a?(Sass::Script::String) && a.type == :identifier &&
@@ -593,39 +612,39 @@ module Sass::Script
593
612
 
594
613
  raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)") if args.size != 1
595
614
 
596
- assert_type args.first, :Color
615
+ assert_type args.first, :Color, :color
597
616
  Sass::Script::Number.new(args.first.alpha)
598
617
  end
599
618
  declare :alpha, [:color]
600
619
 
601
- # Returns the alpha component (opacity) of a color.
602
- # This is 1 unless otherwise specified.
620
+ # Returns the alpha component (opacity) of a color. This is 1 unless
621
+ # otherwise specified.
603
622
  #
604
- # @param color [Color]
605
- # @return [Number]
606
- # @see #opacify
607
- # @see #transparentize
608
- # @raise [ArgumentError] If `color` isn't a color
623
+ # @overload opacity($color)
624
+ # @param $color [Color]
625
+ # @return [Number] The alpha component, between 0 and 1
626
+ # @raise [ArgumentError] if `$color` isn't a color
609
627
  def opacity(color)
610
628
  return Sass::Script::String.new("opacity(#{color})") if color.is_a?(Sass::Script::Number)
611
- assert_type color, :Color
629
+ assert_type color, :Color, :color
612
630
  Sass::Script::Number.new(color.alpha)
613
631
  end
614
632
  declare :opacity, [:color]
615
633
 
616
- # Makes a color more opaque.
617
- # Takes a color and an amount between 0 and 1,
618
- # and returns a color with the opacity increased by that value.
634
+ # Makes a color more opaque. Takes a color and a number between 0 and 1, and
635
+ # returns a color with the opacity increased by that amount.
619
636
  #
637
+ # @see #transparentize
620
638
  # @example
621
639
  # opacify(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.6)
622
640
  # opacify(rgba(0, 0, 17, 0.8), 0.2) => #001
623
- # @param color [Color]
624
- # @param amount [Number]
641
+ # @overload opacify($color, $amount)
642
+ # @param $color [Color]
643
+ # @param $amount [Number] The amount to increase the opacity by, between 0
644
+ # and 1
625
645
  # @return [Color]
626
- # @see #transparentize
627
- # @raise [ArgumentError] If `color` isn't a color,
628
- # or `number` isn't a number between 0 and 1
646
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
647
+ # is the wrong type
629
648
  def opacify(color, amount)
630
649
  _adjust(color, amount, :alpha, 0..1, :+)
631
650
  end
@@ -634,19 +653,20 @@ module Sass::Script
634
653
  alias_method :fade_in, :opacify
635
654
  declare :fade_in, [:color, :amount]
636
655
 
637
- # Makes a color more transparent.
638
- # Takes a color and an amount between 0 and 1,
639
- # and returns a color with the opacity decreased by that value.
656
+ # Makes a color more transparent. Takes a color and a number between 0 and
657
+ # 1, and returns a color with the opacity decreased by that amount.
640
658
  #
659
+ # @see #opacify
641
660
  # @example
642
661
  # transparentize(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.4)
643
662
  # transparentize(rgba(0, 0, 0, 0.8), 0.2) => rgba(0, 0, 0, 0.6)
644
- # @param color [Color]
645
- # @param amount [Number]
663
+ # @overload transparentize($color, $amount)
664
+ # @param $color [Color]
665
+ # @param $amount [Number] The amount to decrease the opacity by, between 0
666
+ # and 1
646
667
  # @return [Color]
647
- # @see #opacify
648
- # @raise [ArgumentError] If `color` isn't a color,
649
- # or `number` isn't a number between 0 and 1
668
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
669
+ # is the wrong type
650
670
  def transparentize(color, amount)
651
671
  _adjust(color, amount, :alpha, 0..1, :-)
652
672
  end
@@ -655,56 +675,58 @@ module Sass::Script
655
675
  alias_method :fade_out, :transparentize
656
676
  declare :fade_out, [:color, :amount]
657
677
 
658
- # Makes a color lighter.
659
- # Takes a color and an amount between 0% and 100%,
660
- # and returns a color with the lightness increased by that value.
678
+ # Makes a color lighter. Takes a color and a number between `0%` and `100%`,
679
+ # and returns a color with the lightness increased by that amount.
661
680
  #
681
+ # @see #darken
662
682
  # @example
663
683
  # lighten(hsl(0, 0%, 0%), 30%) => hsl(0, 0, 30)
664
684
  # lighten(#800, 20%) => #e00
665
- # @param color [Color]
666
- # @param amount [Number]
685
+ # @overload lighten($color, $amount)
686
+ # @param $color [Color]
687
+ # @param $amount [Number] The amount to increase the lightness by, between
688
+ # `0%` and `100%`
667
689
  # @return [Color]
668
- # @see #darken
669
- # @raise [ArgumentError] If `color` isn't a color,
670
- # or `number` isn't a number between 0% and 100%
690
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
691
+ # is the wrong type
671
692
  def lighten(color, amount)
672
693
  _adjust(color, amount, :lightness, 0..100, :+, "%")
673
694
  end
674
695
  declare :lighten, [:color, :amount]
675
696
 
676
- # Makes a color darker.
677
- # Takes a color and an amount between 0% and 100%,
678
- # and returns a color with the lightness decreased by that value.
697
+ # Makes a color darker. Takes a color and a number between 0% and 100%, and
698
+ # returns a color with the lightness decreased by that amount.
679
699
  #
700
+ # @see #lighten
680
701
  # @example
681
702
  # darken(hsl(25, 100%, 80%), 30%) => hsl(25, 100%, 50%)
682
703
  # darken(#800, 20%) => #200
683
- # @param color [Color]
684
- # @param amount [Number]
704
+ # @overload darken($color, $amount)
705
+ # @param $color [Color]
706
+ # @param $amount [Number] The amount to dencrease the lightness by, between
707
+ # `0%` and `100%`
685
708
  # @return [Color]
686
- # @see #lighten
687
- # @raise [ArgumentError] If `color` isn't a color,
688
- # or `number` isn't a number between 0% and 100%
709
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
710
+ # is the wrong type
689
711
  def darken(color, amount)
690
712
  _adjust(color, amount, :lightness, 0..100, :-, "%")
691
713
  end
692
714
  declare :darken, [:color, :amount]
693
715
 
694
- # Makes a color more saturated.
695
- # Takes a color and an amount between 0% and 100%,
696
- # and returns a color with the saturation increased by that value.
716
+ # Makes a color more saturated. Takes a color and a number between 0% and
717
+ # 100%, and returns a color with the saturation increased by that amount.
697
718
  #
719
+ # @see #desaturate
698
720
  # @example
699
721
  # saturate(hsl(120, 30%, 90%), 20%) => hsl(120, 50%, 90%)
700
722
  # saturate(#855, 20%) => #9e3f3f
701
- # @overload saturate(color, amount)
702
- # @param color [Color]
703
- # @param amount [Number]
704
- # @return [Color]
705
- # @see #desaturate
706
- # @raise [ArgumentError] If `color` isn't a color,
707
- # or `number` isn't a number between 0% and 100%
723
+ # @overload saturate($color, $amount)
724
+ # @param $color [Color]
725
+ # @param $amount [Number] The amount to increase the saturation by, between
726
+ # `0%` and `100%`
727
+ # @return [Color]
728
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
729
+ # is the wrong type
708
730
  def saturate(color, amount = nil)
709
731
  # Support the filter effects definition of saturate.
710
732
  # https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html
@@ -714,93 +736,97 @@ module Sass::Script
714
736
  declare :saturate, [:color, :amount]
715
737
  declare :saturate, [:amount]
716
738
 
717
- # Makes a color less saturated.
718
- # Takes a color and an amount between 0% and 100%,
719
- # and returns a color with the saturation decreased by that value.
739
+ # Makes a color less saturated. Takes a color and a number between 0% and
740
+ # 100%, and returns a color with the saturation decreased by that value.
720
741
  #
742
+ # @see #saturate
721
743
  # @example
722
744
  # desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)
723
745
  # desaturate(#855, 20%) => #726b6b
724
- # @param color [Color]
725
- # @param amount [Number]
746
+ # @overload desaturate($color, $amount)
747
+ # @param $color [Color]
748
+ # @param $amount [Number] The amount to decrease the saturation by, between
749
+ # `0%` and `100%`
726
750
  # @return [Color]
727
- # @see #saturate
728
- # @raise [ArgumentError] If `color` isn't a color,
729
- # or `number` isn't a number between 0% and 100%
751
+ # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
752
+ # is the wrong type
730
753
  def desaturate(color, amount)
731
754
  _adjust(color, amount, :saturation, 0..100, :-, "%")
732
755
  end
733
756
  declare :desaturate, [:color, :amount]
734
757
 
735
- # Changes the hue of a color while retaining the lightness and saturation.
736
- # Takes a color and a number of degrees (usually between -360deg and 360deg),
737
- # and returns a color with the hue rotated by that value.
758
+ # Changes the hue of a color. Takes a color and a number of degrees (usually
759
+ # between `-360deg` and `360deg`), and returns a color with the hue rotated
760
+ # along the color wheel by that amount.
738
761
  #
739
762
  # @example
740
763
  # adjust-hue(hsl(120, 30%, 90%), 60deg) => hsl(180, 30%, 90%)
741
764
  # adjust-hue(hsl(120, 30%, 90%), 060deg) => hsl(60, 30%, 90%)
742
765
  # adjust-hue(#811, 45deg) => #886a11
743
- # @param color [Color]
744
- # @param amount [Number]
766
+ # @overload adjust_hue($color, $degrees)
767
+ # @param $color [Color]
768
+ # @param $degrees [Number] The number of degrees to rotate the hue
745
769
  # @return [Color]
746
- # @raise [ArgumentError] If `color` isn't a color, or `number` isn't a number
770
+ # @raise [ArgumentError] if either parameter is the wrong type
747
771
  def adjust_hue(color, degrees)
748
- assert_type color, :Color
749
- assert_type degrees, :Number
772
+ assert_type color, :Color, :color
773
+ assert_type degrees, :Number, :degrees
750
774
  color.with(:hue => color.hue + degrees.value)
751
775
  end
752
776
  declare :adjust_hue, [:color, :degrees]
753
777
 
754
- # Returns an IE hex string for a color with an alpha channel
755
- # suitable for passing to IE filters.
778
+ # Converts a color into the format understood by IE filters.
756
779
  #
757
780
  # @example
758
781
  # ie-hex-str(#abc) => #FFAABBCC
759
782
  # ie-hex-str(#3322BB) => #FF3322BB
760
783
  # ie-hex-str(rgba(0, 255, 0, 0.5)) => #8000FF00
761
- # @param color [Color]
762
- # @return [String]
763
- # @raise [ArgumentError] If `color` isn't a color
784
+ # @overload ie_hex_str($color)
785
+ # @param $color [Color]
786
+ # @return [String] The IE-formatted string representation of the color
787
+ # @raise [ArgumentError] if `$color` isn't a color
764
788
  def ie_hex_str(color)
765
- assert_type color, :Color
789
+ assert_type color, :Color, :color
766
790
  alpha = (color.alpha * 255).round.to_s(16).rjust(2, '0')
767
791
  Sass::Script::String.new("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
768
792
  end
769
793
  declare :ie_hex_str, [:color]
770
794
 
771
- # Adjusts one or more properties of a color.
772
- # This can change the red, green, blue, hue, saturation, value, and alpha properties.
773
- # The properties are specified as keyword arguments,
774
- # and are added to or subtracted from the color's current value for that property.
795
+ # Increases or decreases one or more properties of a color. This can change
796
+ # the red, green, blue, hue, saturation, value, and alpha properties. The
797
+ # properties are specified as keyword arguments, and are added to or
798
+ # subtracted from the color's current value for that property.
775
799
  #
776
- # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
777
- # `$saturation` and `$lightness` should be between 0% and 100%.
778
- # `$alpha` should be between 0 and 1.
779
- #
780
- # All properties are optional.
781
- # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
782
- # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
800
+ # All properties are optional. You can't specify both RGB properties
801
+ # (`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
802
+ # `$value`) at the same time.
783
803
  #
784
804
  # @example
785
805
  # adjust-color(#102030, $blue: 5) => #102035
786
806
  # adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
787
807
  # adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
788
- # @param color [Color]
789
- # @param red [Number]
790
- # @param green [Number]
791
- # @param blue [Number]
792
- # @param hue [Number]
793
- # @param saturation [Number]
794
- # @param lightness [Number]
795
- # @param alpha [Number]
808
+ # @overload adjust_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
809
+ # @param $color [Color]
810
+ # @param $red [Number] The adjustment to make on the red component, between
811
+ # -255 and 255 inclusive
812
+ # @param $green [Number] The adjustment to make on the green component,
813
+ # between -255 and 255 inclusive
814
+ # @param $blue [Number] The adjustment to make on the blue component, between
815
+ # -255 and 255 inclusive
816
+ # @param $hue [Number] The adjustment to make on the hue component, in
817
+ # degrees
818
+ # @param $saturation [Number] The adjustment to make on the saturation
819
+ # component, between `-100%` and `100%` inclusive
820
+ # @param $lightness [Number] The adjustment to make on the lightness
821
+ # component, between `-100%` and `100%` inclusive
822
+ # @param $alpha [Number] The adjustment to make on the alpha component,
823
+ # between -1 and 1 inclusive
796
824
  # @return [Color]
797
- # @raise [ArgumentError] if `color` is not a color,
798
- # if any keyword argument is not a number,
799
- # if any keyword argument is not in the legal range,
800
- # if an unexpected keyword argument is given,
801
- # or if both HSL and RGB properties are given.
825
+ # @raise [ArgumentError] if any parameter is the wrong type or out-of
826
+ # bounds, or if RGB properties and HSL properties are adjusted at the
827
+ # same time
802
828
  def adjust_color(color, kwargs)
803
- assert_type color, :Color
829
+ assert_type color, :Color, :color
804
830
  with = Sass::Util.map_hash({
805
831
  "red" => [-255..255, ""],
806
832
  "green" => [-255..255, ""],
@@ -828,47 +854,47 @@ module Sass::Script
828
854
  end
829
855
  declare :adjust_color, [:color], :var_kwargs => true
830
856
 
831
- # Scales one or more properties of a color by a percentage value.
832
- # Unlike \{#adjust_color adjust-color}, which changes a color's properties by fixed amounts,
833
- # \{#scale_color scale-color} fluidly changes them based on how high or low they already are.
834
- # That means that lightening an already-light color with \{#scale_color scale-color}
835
- # won't change the lightness much,
836
- # but lightening a dark color by the same amount will change it more dramatically.
837
- # This has the benefit of making `scale-color($color, ...)` have a similar effect
838
- # regardless of what `$color` is.
839
- #
840
- # For example, the lightness of a color can be anywhere between 0 and 100.
841
- # If `scale-color($color, $lightness: 40%)` is called, the resulting color's lightness
842
- # will be 40% of the way between its original lightness and 100.
843
- # If `scale-color($color, $lightness: -40%)` is called instead,
844
- # the lightness will be 40% of the way between the original and 0.
845
- #
846
- # This can change the red, green, blue, saturation, value, and alpha properties.
847
- # The properties are specified as keyword arguments.
848
- # All arguments should be percentages between 0% and 100%.
849
- #
850
- # All properties are optional.
851
- # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
852
- # and HSL properties (`$saturation`, `$value`) at the same time.
857
+ # Fluidly scales one or more properties of a color. Unlike
858
+ # \{#adjust_color adjust-color}, which changes a color's properties by fixed
859
+ # amounts, \{#scale_color scale-color} fluidly changes them based on how
860
+ # high or low they already are. That means that lightening an already-light
861
+ # color with \{#scale_color scale-color} won't change the lightness much,
862
+ # but lightening a dark color by the same amount will change it more
863
+ # dramatically. This has the benefit of making `scale-color($color, ...)`
864
+ # have a similar effect regardless of what `$color` is.
865
+ #
866
+ # For example, the lightness of a color can be anywhere between `0%` and
867
+ # `100%`. If `scale-color($color, $lightness: 40%)` is called, the resulting
868
+ # color's lightness will be 40% of the way between its original lightness
869
+ # and 100. If `scale-color($color, $lightness: -40%)` is called instead, the
870
+ # lightness will be 40% of the way between the original and 0.
871
+ #
872
+ # This can change the red, green, blue, saturation, value, and alpha
873
+ # properties. The properties are specified as keyword arguments. All
874
+ # arguments should be percentages between `0%` and `100%`.
875
+ #
876
+ # All properties are optional. You can't specify both RGB properties
877
+ # (`$red`, `$green`, `$blue`) and HSL properties (`$saturation`, `$value`)
878
+ # at the same time.
853
879
  #
854
880
  # @example
855
- # scale-color(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
856
- # scale-color(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
857
- # scale-color(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
858
- # @param color [Color]
859
- # @param red [Number]
860
- # @param green [Number]
861
- # @param blue [Number]
862
- # @param saturation [Number]
863
- # @param lightness [Number]
864
- # @param alpha [Number]
881
+ # scale-color(hsl(120, 70%, 80%), $lightness: 50%) => hsl(120, 70%, 90%)
882
+ # scale-color(rgb(200, 150%, 170%), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
883
+ # scale-color(hsl(200, 70%, 80%), $saturation: -90%, $alpha: -30%) => hsla(200, 7%, 80%, 0.7)
884
+ # @overload scale_color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])
885
+ # @param $color [Color]
886
+ # @param $red [Number]
887
+ # @param $green [Number]
888
+ # @param $blue [Number]
889
+ # @param $saturation [Number]
890
+ # @param $lightness [Number]
891
+ # @param $alpha [Number]
865
892
  # @return [Color]
866
- # @raise [ArgumentError] if `color` is not a color,
867
- # if any keyword argument is not a percentage between 0% and 100%,
868
- # if an unexpected keyword argument is given,
869
- # or if both HSL and RGB properties are given.
893
+ # @raise [ArgumentError] if any parameter is the wrong type or out-of
894
+ # bounds, or if RGB properties and HSL properties are adjusted at the
895
+ # same time
870
896
  def scale_color(color, kwargs)
871
- assert_type color, :Color
897
+ assert_type color, :Color, :color
872
898
  with = Sass::Util.map_hash({
873
899
  "red" => 255,
874
900
  "green" => 255,
@@ -901,39 +927,40 @@ module Sass::Script
901
927
  end
902
928
  declare :scale_color, [:color], :var_kwargs => true
903
929
 
904
- # Changes one or more properties of a color.
905
- # This can change the red, green, blue, hue, saturation, value, and alpha properties.
906
- # The properties are specified as keyword arguments,
907
- # and replace the color's current value for that property.
908
- #
909
- # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
910
- # `$saturation` and `$lightness` should be between 0% and 100%.
911
- # `$alpha` should be between 0 and 1.
930
+ # Changes one or more properties of a color. This can change the red, green,
931
+ # blue, hue, saturation, value, and alpha properties. The properties are
932
+ # specified as keyword arguments, and replace the color's current value for
933
+ # that property.
912
934
  #
913
- # All properties are optional.
914
- # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
915
- # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
935
+ # All properties are optional. You can't specify both RGB properties
936
+ # (`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
937
+ # `$value`) at the same time.
916
938
  #
917
939
  # @example
918
940
  # change-color(#102030, $blue: 5) => #102005
919
941
  # change-color(#102030, $red: 120, $blue: 5) => #782005
920
942
  # change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
921
- # @param color [Color]
922
- # @param red [Number]
923
- # @param green [Number]
924
- # @param blue [Number]
925
- # @param hue [Number]
926
- # @param saturation [Number]
927
- # @param lightness [Number]
928
- # @param alpha [Number]
943
+ # @overload change_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
944
+ # @param $color [Color]
945
+ # @param $red [Number] The new red component for the color, within 0 and 255
946
+ # inclusive
947
+ # @param $green [Number] The new green component for the color, within 0 and
948
+ # 255 inclusive
949
+ # @param $blue [Number] The new blue component for the color, within 0 and
950
+ # 255 inclusive
951
+ # @param $hue [Number] The new hue component for the color, in degrees
952
+ # @param $saturation [Number] The new saturation component for the color,
953
+ # between `0%` and `100%` inclusive
954
+ # @param $lightness [Number] The new lightness component for the color,
955
+ # within `0%` and `100%` inclusive
956
+ # @param $alpha [Number] The new alpha component for the color, within 0 and
957
+ # 1 inclusive
929
958
  # @return [Color]
930
- # @raise [ArgumentError] if `color` is not a color,
931
- # if any keyword argument is not a number,
932
- # if any keyword argument is not in the legal range,
933
- # if an unexpected keyword argument is given,
934
- # or if both HSL and RGB properties are given.
959
+ # @raise [ArgumentError] if any parameter is the wrong type or out-of
960
+ # bounds, or if RGB properties and HSL properties are adjusted at the
961
+ # same time
935
962
  def change_color(color, kwargs)
936
- assert_type color, :Color
963
+ assert_type color, :Color, :color
937
964
  with = Sass::Util.map_hash(%w[red green blue hue saturation lightness alpha]) do |name, max|
938
965
  next unless val = kwargs.delete(name)
939
966
  assert_type val, :Number, name
@@ -949,33 +976,32 @@ module Sass::Script
949
976
  end
950
977
  declare :change_color, [:color], :var_kwargs => true
951
978
 
952
- # Mixes together two colors.
953
- # Specifically, takes the average of each of the RGB components,
954
- # optionally weighted by the given percentage.
955
- # The opacity of the colors is also considered when weighting the components.
979
+ # Mixes two colors together. Specifically, takes the average of each of the
980
+ # RGB components, optionally weighted by the given percentage. The opacity
981
+ # of the colors is also considered when weighting the components.
956
982
  #
957
983
  # The weight specifies the amount of the first color that should be included
958
- # in the returned color.
959
- # The default, 50%, means that half the first color
960
- # and half the second color should be used.
961
- # 25% means that a quarter of the first color
962
- # and three quarters of the second color should be used.
984
+ # in the returned color. The default, `50%`, means that half the first color
985
+ # and half the second color should be used. `25%` means that a quarter of
986
+ # the first color and three quarters of the second color should be used.
963
987
  #
964
988
  # @example
965
989
  # mix(#f00, #00f) => #7f007f
966
990
  # mix(#f00, #00f, 25%) => #3f00bf
967
991
  # mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
968
- # @overload mix(color1, color2, weight: 50%)
969
- # @param color1 [Color]
970
- # @param color2 [Color]
971
- # @param weight [Number] between 0% and 100%
972
- # @return [Color]
973
- # @raise [ArgumentError] if `color1` or `color2` aren't colors,
974
- # or `weight` isn't a number between 0% and 100%
975
- def mix(color1, color2, weight = Number.new(50))
976
- assert_type color1, :Color
977
- assert_type color2, :Color
978
- assert_type weight, :Number
992
+ # @overload mix($color-1, $color-2, $weight: 50%)
993
+ # @param $color-1 [Color]
994
+ # @param $color-2 [Color]
995
+ # @param $weight [Number] The relative weight of each color. Closer to `0%`
996
+ # gives more weight to `$color`, closer to `100%` gives more weight to
997
+ # `$color2`
998
+ # @return [Color]
999
+ # @raise [ArgumentError] if `$weight` is out of bounds or any parameter is
1000
+ # the wrong type
1001
+ def mix(color_1, color_2, weight = Number.new(50))
1002
+ assert_type color_1, :Color, :color_1
1003
+ assert_type color_2, :Color, :color_2
1004
+ assert_type weight, :Number, :weight
979
1005
 
980
1006
  Sass::Util.check_range("Weight", 0..100, weight, '%')
981
1007
 
@@ -984,11 +1010,11 @@ module Sass::Script
984
1010
  # to perform the weighted average of the two RGB values.
985
1011
  #
986
1012
  # It works by first normalizing both parameters to be within [-1, 1],
987
- # where 1 indicates "only use color1", -1 indicates "only use color2", and
1013
+ # where 1 indicates "only use color_1", -1 indicates "only use color_2", and
988
1014
  # all values in between indicated a proportionately weighted average.
989
1015
  #
990
1016
  # Once we have the normalized variables w and a, we apply the formula
991
- # (w + a)/(1 + w*a) to get the combined weight (in [-1, 1]) of color1.
1017
+ # (w + a)/(1 + w*a) to get the combined weight (in [-1, 1]) of color_1.
992
1018
  # This formula has two especially nice properties:
993
1019
  #
994
1020
  # * When either w or a are -1 or 1, the combined weight is also that number
@@ -996,57 +1022,60 @@ module Sass::Script
996
1022
  #
997
1023
  # * When a is 0, the combined weight is w, and vice versa.
998
1024
  #
999
- # Finally, the weight of color1 is renormalized to be within [0, 1]
1000
- # and the weight of color2 is given by 1 minus the weight of color1.
1025
+ # Finally, the weight of color_1 is renormalized to be within [0, 1]
1026
+ # and the weight of color_2 is given by 1 minus the weight of color_1.
1001
1027
  p = (weight.value/100.0).to_f
1002
1028
  w = p*2 - 1
1003
- a = color1.alpha - color2.alpha
1029
+ a = color_1.alpha - color_2.alpha
1004
1030
 
1005
1031
  w1 = (((w * a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0
1006
1032
  w2 = 1 - w1
1007
1033
 
1008
- rgb = color1.rgb.zip(color2.rgb).map {|v1, v2| v1*w1 + v2*w2}
1009
- alpha = color1.alpha*p + color2.alpha*(1-p)
1034
+ rgb = color_1.rgb.zip(color_2.rgb).map {|v1, v2| v1*w1 + v2*w2}
1035
+ alpha = color_1.alpha*p + color_2.alpha*(1-p)
1010
1036
  Color.new(rgb + [alpha])
1011
1037
  end
1012
1038
  declare :mix, [:color_1, :color_2]
1013
1039
  declare :mix, [:color_1, :color_2, :weight]
1014
1040
 
1015
- # Converts a color to grayscale.
1016
- # This is identical to `desaturate(color, 100%)`.
1041
+ # Converts a color to grayscale. This is identical to `desaturate(color,
1042
+ # 100%)`.
1017
1043
  #
1018
- # @param color [Color]
1019
- # @return [Color]
1020
- # @raise [ArgumentError] if `color` isn't a color
1021
1044
  # @see #desaturate
1045
+ # @overload grayscale($color)
1046
+ # @param $color [Color]
1047
+ # @return [Color]
1048
+ # @raise [ArgumentError] if `$color` isn't a color
1022
1049
  def grayscale(color)
1023
1050
  return Sass::Script::String.new("grayscale(#{color})") if color.is_a?(Sass::Script::Number)
1024
1051
  desaturate color, Number.new(100)
1025
1052
  end
1026
1053
  declare :grayscale, [:color]
1027
1054
 
1028
- # Returns the complement of a color.
1029
- # This is identical to `adjust-hue(color, 180deg)`.
1055
+ # Returns the complement of a color. This is identical to `adjust-hue(color,
1056
+ # 180deg)`.
1030
1057
  #
1031
- # @param color [Color]
1032
- # @return [Color]
1033
- # @raise [ArgumentError] if `color` isn't a color
1034
1058
  # @see #adjust_hue #adjust-hue
1059
+ # @overload complement($color)
1060
+ # @param $color [Color]
1061
+ # @return [Color]
1062
+ # @raise [ArgumentError] if `$color` isn't a color
1035
1063
  def complement(color)
1036
1064
  adjust_hue color, Number.new(180)
1037
1065
  end
1038
1066
  declare :complement, [:color]
1039
1067
 
1040
- # Returns the inverse (negative) of a color.
1041
- # The red, green, and blue values are inverted, while the opacity is left alone.
1068
+ # Returns the inverse (negative) of a color. The red, green, and blue values
1069
+ # are inverted, while the opacity is left alone.
1042
1070
  #
1043
- # @param color [Color]
1071
+ # @overload invert($color)
1072
+ # @param $color [Color]
1044
1073
  # @return [Color]
1045
- # @raise [ArgumentError] if `color` isn't a color
1074
+ # @raise [ArgumentError] if `$color` isn't a color
1046
1075
  def invert(color)
1047
1076
  return Sass::Script::String.new("invert(#{color})") if color.is_a?(Sass::Script::Number)
1048
1077
 
1049
- assert_type color, :Color
1078
+ assert_type color, :Color, :color
1050
1079
  color.with(
1051
1080
  :red => (255 - color.red),
1052
1081
  :green => (255 - color.green),
@@ -1054,16 +1083,17 @@ module Sass::Script
1054
1083
  end
1055
1084
  declare :invert, [:color]
1056
1085
 
1057
- # Removes quotes from a string if the string is quoted,
1058
- # or returns the same string if it's not.
1086
+ # Removes quotes from a string. If the string is already unquoted, this will
1087
+ # return it unmodified.
1059
1088
  #
1060
- # @param string [String]
1061
- # @return [String]
1062
- # @raise [ArgumentError] if `string` isn't a string
1063
1089
  # @see #quote
1064
1090
  # @example
1065
1091
  # unquote("foo") => foo
1066
1092
  # unquote(foo) => foo
1093
+ # @overload unquote($string)
1094
+ # @param $string [String]
1095
+ # @return [String]
1096
+ # @raise [ArgumentError] if `$string` isn't a string
1067
1097
  def unquote(string)
1068
1098
  if string.is_a?(Sass::Script::String)
1069
1099
  Sass::Script::String.new(string.value, :identifier)
@@ -1076,20 +1106,21 @@ module Sass::Script
1076
1106
  # Add quotes to a string if the string isn't quoted,
1077
1107
  # or returns the same string if it is.
1078
1108
  #
1079
- # @param string [String]
1080
- # @return [String]
1081
- # @raise [ArgumentError] if `string` isn't a string
1082
1109
  # @see #unquote
1083
1110
  # @example
1084
1111
  # quote("foo") => "foo"
1085
1112
  # quote(foo) => "foo"
1113
+ # @overload quote($string)
1114
+ # @param $string [String]
1115
+ # @return [String]
1116
+ # @raise [ArgumentError] if `$string` isn't a string
1086
1117
  def quote(string)
1087
- assert_type string, :String
1118
+ assert_type string, :String, :string
1088
1119
  Sass::Script::String.new(string.value, :string)
1089
1120
  end
1090
1121
  declare :quote, [:string]
1091
1122
 
1092
- # Inspects the type of the argument, returning it as an unquoted string.
1123
+ # Returns the type of a value.
1093
1124
  #
1094
1125
  # @example
1095
1126
  # type-of(100px) => number
@@ -1098,15 +1129,16 @@ module Sass::Script
1098
1129
  # type-of(true) => bool
1099
1130
  # type-of(#fff) => color
1100
1131
  # type-of(blue) => color
1101
- # @param value [Literal] The object to inspect
1102
- # @return [String] The unquoted string name of the literal's type
1132
+ # @overload type_of($value)
1133
+ # @param $value [Literal] The value to inspect
1134
+ # @return [String] The unquoted string name of the value's type
1103
1135
  def type_of(value)
1104
1136
  Sass::Script::String.new(value.class.name.gsub(/Sass::Script::/,'').downcase)
1105
1137
  end
1106
1138
  declare :type_of, [:value]
1107
1139
 
1108
- # Inspects the unit of the number, returning it as a quoted string.
1109
- # Complex units are sorted in alphabetical order by numerator and denominator.
1140
+ # Returns the unit(s) associated with a number. Complex units are sorted in
1141
+ # alphabetical order by numerator and denominator.
1110
1142
  #
1111
1143
  # @example
1112
1144
  # unit(100) => ""
@@ -1114,56 +1146,61 @@ module Sass::Script
1114
1146
  # unit(3em) => "em"
1115
1147
  # unit(10px * 5em) => "em*px"
1116
1148
  # unit(10px * 5em / 30cm / 1rem) => "em*px/cm*rem"
1117
- # @param number [Literal] The number to inspect
1118
- # @return [String] The unit(s) of the number
1119
- # @raise [ArgumentError] if `number` isn't a number
1149
+ # @overload unit($number)
1150
+ # @param $number [Number]
1151
+ # @return [String] The unit(s) of the number, as a quoted string
1152
+ # @raise [ArgumentError] if `$number` isn't a number
1120
1153
  def unit(number)
1121
- assert_type number, :Number
1154
+ assert_type number, :Number, :number
1122
1155
  Sass::Script::String.new(number.unit_str, :string)
1123
1156
  end
1124
1157
  declare :unit, [:number]
1125
1158
 
1126
- # Inspects the unit of the number, returning a boolean indicating if it is unitless.
1159
+ # Returns whether a number has units.
1127
1160
  #
1128
1161
  # @example
1129
1162
  # unitless(100) => true
1130
1163
  # unitless(100px) => false
1131
- # @param number [Literal] The number to inspect
1132
- # @return [Bool] Whether or not the number is unitless
1133
- # @raise [ArgumentError] if `number` isn't a number
1164
+ # @overload unitless($number)
1165
+ # @param $number [Number]
1166
+ # @return [Bool]
1167
+ # @raise [ArgumentError] if `$number` isn't a number
1134
1168
  def unitless(number)
1135
- assert_type number, :Number
1169
+ assert_type number, :Number, :number
1136
1170
  Sass::Script::Bool.new(number.unitless?)
1137
1171
  end
1138
1172
  declare :unitless, [:number]
1139
1173
 
1140
- # Returns true if two numbers are similar enough to be added, subtracted, or compared.
1174
+ # Returns whether two numbers can added, subtracted, or compared.
1141
1175
  #
1142
1176
  # @example
1143
1177
  # comparable(2px, 1px) => true
1144
1178
  # comparable(100px, 3em) => false
1145
1179
  # comparable(10cm, 3mm) => true
1146
- # @param number_1 [Number]
1147
- # @param number_2 [Number]
1148
- # @return [Bool] indicating if the numbers can be compared.
1149
- # @raise [ArgumentError] if `number_1` or `number_2` aren't numbers
1180
+ # @overload comparable($number-1, $number-2)
1181
+ # @param $number-1 [Number]
1182
+ # @param $number-2 [Number]
1183
+ # @return [Bool]
1184
+ # @raise [ArgumentError] if either parameter is the wrong type
1150
1185
  def comparable(number_1, number_2)
1151
- assert_type number_1, :Number
1152
- assert_type number_2, :Number
1186
+ assert_type number_1, :Number, :number_1
1187
+ assert_type number_2, :Number, :number_2
1153
1188
  Sass::Script::Bool.new(number_1.comparable_to?(number_2))
1154
1189
  end
1155
1190
  declare :comparable, [:number_1, :number_2]
1156
1191
 
1157
- # Converts a decimal number to a percentage.
1192
+ # Converts a unitless number to a percentage.
1158
1193
  #
1159
1194
  # @example
1195
+ # percentage(0.2) => 20%
1160
1196
  # percentage(100px / 50px) => 200%
1161
- # @param value [Number] The decimal number to convert to a percentage
1162
- # @return [Number] The percentage
1163
- # @raise [ArgumentError] If `value` isn't a unitless number
1197
+ # @overload percentage($value)
1198
+ # @param $value [Number]
1199
+ # @return [Number]
1200
+ # @raise [ArgumentError] if `$value` isn't a unitless number
1164
1201
  def percentage(value)
1165
1202
  unless value.is_a?(Sass::Script::Number) && value.unitless?
1166
- raise ArgumentError.new("#{value.inspect} is not a unitless number")
1203
+ raise ArgumentError.new("$value: #{value.inspect} is not a unitless number")
1167
1204
  end
1168
1205
  Sass::Script::Number.new(value.value * 100, ['%'])
1169
1206
  end
@@ -1174,76 +1211,83 @@ module Sass::Script
1174
1211
  # @example
1175
1212
  # round(10.4px) => 10px
1176
1213
  # round(10.6px) => 11px
1177
- # @param value [Number] The number
1178
- # @return [Number] The rounded number
1179
- # @raise [ArgumentError] if `value` isn't a number
1214
+ # @overload round($value)
1215
+ # @param $value [Number]
1216
+ # @return [Number]
1217
+ # @raise [ArgumentError] if `$value` isn't a number
1180
1218
  def round(value)
1181
1219
  numeric_transformation(value) {|n| n.round}
1182
1220
  end
1183
1221
  declare :round, [:value]
1184
1222
 
1185
- # Rounds a number up to the nearest whole number.
1223
+ # Rounds a number up to the next whole number.
1186
1224
  #
1187
1225
  # @example
1188
1226
  # ceil(10.4px) => 11px
1189
1227
  # ceil(10.6px) => 11px
1190
- # @param value [Number] The number
1191
- # @return [Number] The rounded number
1192
- # @raise [ArgumentError] if `value` isn't a number
1228
+ # @overload ceil($value)
1229
+ # @param $value [Number]
1230
+ # @return [Number]
1231
+ # @raise [ArgumentError] if `$value` isn't a number
1193
1232
  def ceil(value)
1194
1233
  numeric_transformation(value) {|n| n.ceil}
1195
1234
  end
1196
1235
  declare :ceil, [:value]
1197
1236
 
1198
- # Rounds down to the nearest whole number.
1237
+ # Rounds a number down to the previous whole number.
1199
1238
  #
1200
1239
  # @example
1201
1240
  # floor(10.4px) => 10px
1202
1241
  # floor(10.6px) => 10px
1203
- # @param value [Number] The number
1204
- # @return [Number] The rounded number
1205
- # @raise [ArgumentError] if `value` isn't a number
1242
+ # @overload floor($value)
1243
+ # @param $value [Number]
1244
+ # @return [Number]
1245
+ # @raise [ArgumentError] if `$value` isn't a number
1206
1246
  def floor(value)
1207
1247
  numeric_transformation(value) {|n| n.floor}
1208
1248
  end
1209
1249
  declare :floor, [:value]
1210
1250
 
1211
- # Finds the absolute value of a number.
1251
+ # Returns the absolute value of a number.
1212
1252
  #
1213
1253
  # @example
1214
1254
  # abs(10px) => 10px
1215
1255
  # abs(-10px) => 10px
1216
- # @param value [Number] The number
1217
- # @return [Number] The absolute value
1218
- # @raise [ArgumentError] if `value` isn't a number
1256
+ # @overload abs($value)
1257
+ # @param $value [Number]
1258
+ # @return [Number]
1259
+ # @raise [ArgumentError] if `$value` isn't a number
1219
1260
  def abs(value)
1220
1261
  numeric_transformation(value) {|n| n.abs}
1221
1262
  end
1222
1263
  declare :abs, [:value]
1223
1264
 
1224
- # Finds the minimum of several values. This function takes any number of
1265
+ # Finds the minimum of several numbers. This function takes any number of
1225
1266
  # arguments.
1226
1267
  #
1227
1268
  # @example
1228
1269
  # min(1px, 4px) => 1px
1229
1270
  # min(5em, 3em, 4em) => 3em
1230
- # @param values [[Number]] The numbers
1231
- # @return [Number] The minimum value
1271
+ # @overload min($numbers...)
1272
+ # @param $numbers [[Number]]
1273
+ # @return [Number]
1232
1274
  # @raise [ArgumentError] if any argument isn't a number, or if not all of
1233
1275
  # the arguments have comparable units
1234
- def min(*values)
1235
- values.each {|v| assert_type v, :Number}
1236
- values.inject {|min, val| min.lt(val).to_bool ? min : val}
1276
+ def min(*numbers)
1277
+ numbers.each {|n| assert_type n, :Number}
1278
+ numbers.inject {|min, num| min.lt(num).to_bool ? min : num}
1237
1279
  end
1238
1280
  declare :min, [], :var_args => :true
1239
1281
 
1240
- # Finds the maximum of several values. This function takes any number of
1282
+ # Finds the maximum of several numbers. This function takes any number of
1241
1283
  # arguments.
1242
1284
  #
1243
1285
  # @example
1244
1286
  # max(1px, 4px) => 4px
1245
1287
  # max(5em, 3em, 4em) => 5em
1246
- # @return [Number] The maximum value
1288
+ # @overload max($numbers...)
1289
+ # @param $numbers [[Number]]
1290
+ # @return [Number]
1247
1291
  # @raise [ArgumentError] if any argument isn't a number, or if not all of
1248
1292
  # the arguments have comparable units
1249
1293
  def max(*values)
@@ -1257,8 +1301,9 @@ module Sass::Script
1257
1301
  # @example
1258
1302
  # length(10px) => 1
1259
1303
  # length(10px 20px 30px) => 3
1260
- # @param list [Literal] The list
1261
- # @return [Number] The length
1304
+ # @overload length($list)
1305
+ # @param $list [Literal]
1306
+ # @return [Number]
1262
1307
  def length(list)
1263
1308
  Sass::Script::Number.new(list.to_a.size)
1264
1309
  end
@@ -1266,18 +1311,20 @@ module Sass::Script
1266
1311
 
1267
1312
  # Gets the nth item in a list.
1268
1313
  #
1269
- # Note that unlike some languages, the first item in a Sass list is number 1,
1270
- # the second number 2, and so forth.
1314
+ # Note that unlike some languages, the first item in a Sass list is number
1315
+ # 1, the second number 2, and so forth.
1271
1316
  #
1272
1317
  # @example
1273
1318
  # nth(10px 20px 30px, 1) => 10px
1274
1319
  # nth((Helvetica, Arial, sans-serif), 3) => sans-serif
1275
- # @param list [Literal] The list
1276
- # @param n [Number] The index into the list
1277
- # @return [Literal] The nth item in the list
1278
- # @raise [ArgumentError] If `n` isn't an integer between 1 and the list's length.
1320
+ # @overload nth($list, $n)
1321
+ # @param $list [Literal]
1322
+ # @param $n [Number] The index of the item to get
1323
+ # @return [Literal]
1324
+ # @raise [ArgumentError] if `$n` isn't an integer between 1 and the length
1325
+ # of `$list`
1279
1326
  def nth(list, n)
1280
- assert_type n, :Number
1327
+ assert_type n, :Number, :n
1281
1328
  if !n.int?
1282
1329
  raise ArgumentError.new("List index #{n} must be an integer")
1283
1330
  elsif n.to_i < 1
@@ -1292,12 +1339,12 @@ module Sass::Script
1292
1339
  end
1293
1340
  declare :nth, [:list, :n]
1294
1341
 
1295
- # Joins together two lists into a new list.
1342
+ # Joins together two lists into one.
1296
1343
  #
1297
- # Unless the `$separator` argument is passed,
1298
- # if one list is comma-separated and one is space-separated,
1299
- # the first parameter's separator is used for the resulting list.
1300
- # If the lists have only one item each, spaces are used for the resulting list.
1344
+ # Unless `$separator` is passed, if one list is comma-separated and one is
1345
+ # space-separated, the first parameter's separator is used for the resulting
1346
+ # list. If both lists have fewer than two items, spaces are used for the
1347
+ # resulting list.
1301
1348
  #
1302
1349
  # @example
1303
1350
  # join(10px 20px, 30px 40px) => 10px 20px 30px 40px
@@ -1305,14 +1352,15 @@ module Sass::Script
1305
1352
  # join(10px, 20px) => 10px 20px
1306
1353
  # join(10px, 20px, comma) => 10px, 20px
1307
1354
  # join((blue, red), (#abc, #def), space) => blue red #abc #def
1308
- # @overload join(list1, list2, separator: auto)
1309
- # @param list1 [Literal] The first list to join
1310
- # @param list2 [Literal] The second list to join
1311
- # @param separator [String] How the list separator (comma or space) should be determined.
1312
- # If this is `comma` or `space`, that is always the separator;
1313
- # if this is `auto` (the default), the separator is determined as explained above.
1355
+ # @overload join($list1, $list2, $separator: auto)
1356
+ # @param $list1 [Literal]
1357
+ # @param $list2 [Literal]
1358
+ # @param $separator [String] The list separator to use. If this is `comma`
1359
+ # or `space`, that separator will be used. If this is `auto` (the
1360
+ # default), the separator is determined as explained above.
1361
+ # @return [List]
1314
1362
  def join(list1, list2, separator = Sass::Script::String.new("auto"))
1315
- assert_type separator, :String
1363
+ assert_type separator, :String, :separator
1316
1364
  unless %w[auto space comma].include?(separator.value)
1317
1365
  raise ArgumentError.new("Separator name must be space, comma, or auto")
1318
1366
  end
@@ -1331,8 +1379,7 @@ module Sass::Script
1331
1379
 
1332
1380
  # Appends a single value onto the end of a list.
1333
1381
  #
1334
- # Unless the `$separator` argument is passed,
1335
- # if the list has only one item,
1382
+ # Unless the `$separator` argument is passed, if the list had only one item,
1336
1383
  # the resulting list will be space-separated.
1337
1384
  #
1338
1385
  # @example
@@ -1341,14 +1388,15 @@ module Sass::Script
1341
1388
  # append(10px 20px, 30px 40px) => 10px 20px (30px 40px)
1342
1389
  # append(10px, 20px, comma) => 10px, 20px
1343
1390
  # append((blue, red), green, space) => blue red green
1344
- # @overload append(list, val, separator: auto)
1345
- # @param list [Literal] The list to add the value to
1346
- # @param val [Literal] The value to add to the end of the list
1347
- # @param separator [String] How the list separator (comma or space) should be determined.
1348
- # If this is `comma` or `space`, that is always the separator;
1349
- # if this is `auto` (the default), the separator is the same as that used by the list.
1391
+ # @overload append($list, $val, $separator: auto)
1392
+ # @param $list [Literal]
1393
+ # @param $val [Literal]
1394
+ # @param $separator [String] The list separator to use. If this is `comma`
1395
+ # or `space`, that separator will be used. If this is `auto` (the
1396
+ # default), the separator is determined as explained above.
1397
+ # @return [List]
1350
1398
  def append(list, val, separator = Sass::Script::String.new("auto"))
1351
- assert_type separator, :String
1399
+ assert_type separator, :String, :separator
1352
1400
  unless %w[auto space comma].include?(separator.value)
1353
1401
  raise ArgumentError.new("Separator name must be space, comma, or auto")
1354
1402
  end
@@ -1364,8 +1412,9 @@ module Sass::Script
1364
1412
  declare :append, [:list, :val]
1365
1413
  declare :append, [:list, :val, :separator]
1366
1414
 
1367
- # Combines several lists into a single comma separated list, where the nth
1368
- # value is a space separated list of the source lists' nth values.
1415
+ # Combines several lists into a single multidimensional list. The nth value
1416
+ # of the resulting list is a space separated list of the source lists' nth
1417
+ # values.
1369
1418
  #
1370
1419
  # The length of the resulting list is the length of the
1371
1420
  # shortest list.
@@ -1373,6 +1422,9 @@ module Sass::Script
1373
1422
  # @example
1374
1423
  # zip(1px 1px 3px, solid dashed solid, red green blue)
1375
1424
  # => 1px solid red, 1px dashed green, 3px solid blue
1425
+ # @overload zip($lists...)
1426
+ # @param $lists [[Literal]]
1427
+ # @return [List]
1376
1428
  def zip(*lists)
1377
1429
  length = nil
1378
1430
  values = []
@@ -1390,12 +1442,20 @@ module Sass::Script
1390
1442
  declare :zip, [], :var_args => true
1391
1443
 
1392
1444
 
1393
- # Returns the position of a value within a list. If not found, returns
1394
- # false.
1445
+ # Returns the position of a value within a list. If the value isn't found,
1446
+ # returns false instead.
1447
+ #
1448
+ # Note that unlike some languages, the first item in a Sass list is number
1449
+ # 1, the second number 2, and so forth.
1395
1450
  #
1396
1451
  # @example
1397
1452
  # index(1px solid red, solid) => 2
1398
1453
  # index(1px solid red, dashed) => false
1454
+ # @overload index($list, $value)
1455
+ # @param $list [Literal]
1456
+ # @param $value [Literal]
1457
+ # @return [Number, Bool] The 1-based index of `$value` in `$list`, or
1458
+ # `false`
1399
1459
  def index(list, value)
1400
1460
  index = list.to_a.index {|e| e.eq(value).to_bool }
1401
1461
  if index
@@ -1406,14 +1466,19 @@ module Sass::Script
1406
1466
  end
1407
1467
  declare :index, [:list, :value]
1408
1468
 
1409
- # Returns one of two values based on the truth value of the first argument.
1469
+ # Returns one of two values, depending on whether or not `$condition` is
1470
+ # true. Just like in `@if`, all values other than `false` and `null` are
1471
+ # considered to be true.
1410
1472
  #
1411
1473
  # @example
1412
1474
  # if(true, 1px, 2px) => 1px
1413
1475
  # if(false, 1px, 2px) => 2px
1414
- # @param condition [Bool] Whether the first or second value will be returned.
1415
- # @param if_true [Literal] The value that will be returned if `$condition` is true.
1416
- # @param if_false [Literal] The value that will be returned if `$condition` is false.
1476
+ # @overload if($condition, $if-true, $if-false)
1477
+ # @param $condition [Literal] Whether the `$if-true` or `$if-false` will be
1478
+ # returned
1479
+ # @param $if-true [Literal]
1480
+ # @param $if-false [Literal]
1481
+ # @return [Literal] `$if-true` or `$if-false`
1417
1482
  def if(condition, if_true, if_false)
1418
1483
  if condition.to_bool
1419
1484
  if_true
@@ -1431,6 +1496,8 @@ module Sass::Script
1431
1496
  #
1432
1497
  # @example
1433
1498
  # counter(item, ".") => counter(item,".")
1499
+ # @overload counter($args...)
1500
+ # @return [String]
1434
1501
  def counter(*args)
1435
1502
  Sass::Script::String.new("counter(#{args.map {|a| a.to_s(options)}.join(',')})")
1436
1503
  end
@@ -1442,13 +1509,13 @@ module Sass::Script
1442
1509
  # another numeric value with the same units.
1443
1510
  # It yields a number to a block to perform the operation and return a number
1444
1511
  def numeric_transformation(value)
1445
- assert_type value, :Number
1512
+ assert_type value, :Number, :value
1446
1513
  Sass::Script::Number.new(yield(value.value), value.numerator_units, value.denominator_units)
1447
1514
  end
1448
1515
 
1449
1516
  def _adjust(color, amount, attr, range, op, units = "")
1450
- assert_type color, :Color
1451
- assert_type amount, :Number
1517
+ assert_type color, :Color, :color
1518
+ assert_type amount, :Number, :amount
1452
1519
  Sass::Util.check_range('Amount', range, amount, units)
1453
1520
 
1454
1521
  # TODO: is it worth restricting here,