@@ -130,6 +130,8 @@ def compile(**kwargs):
130
130
:type image_path: :class:`str`
131
131
:param precision: optional precision for numbers. :const:`5` by default.
132
132
:type precision: :class:`int`
133
+ :param custom_functions: optional mapping of custom functions
134
+ :type custom_functions: :class:`collections.Mapping`
133
135
:returns: the compiled CSS string
134
136
:rtype: :class:`str`
135
137
:raises sass.CompileError: when it fails for any reason
@@ -161,6 +163,8 @@ def compile(**kwargs):
161
163
:type image_path: :class:`str`
162
164
:param precision: optional precision for numbers. :const:`5` by default.
163
165
:type precision: :class:`int`
166
+ :param custom_functions: optional mapping of custom functions
167
+ :type custom_functions: :class:`collections.Mapping`
164
168
:returns: the compiled CSS string, or a pair of the compiled CSS string
165
169
and the source map string if ``source_comments='map'``
166
170
:rtype: :class:`str`, :class:`tuple`
@@ -195,6 +199,8 @@ def compile(**kwargs):
195
199
:type image_path: :class:`str`
196
200
:param precision: optional precision for numbers. :const:`5` by default.
197
201
:type precision: :class:`int`
202
+ :param custom_functions: optional mapping of custom functions
203
+ :type custom_functions: :class:`collections.Mapping`
198
204
:raises sass.CompileError: when it fails for any reason
199
205
(for example the given SASS has broken syntax)
200
206
@@ -212,6 +218,9 @@ def compile(**kwargs):
212
218
.. versionadded:: 0.7.0
213
219
Added ``precision`` parameter.
214
220
221
+ .. versionadded:: 0.7.0
222
+ Added ``custom_functions`` parameter.
223
+
215
224
"""
216
225
modes = set ()
217
226
for mode_name in MODES :
@@ -397,6 +406,7 @@ def and_join(strings):
397
406
iterator = enumerate (strings )
398
407
return ', ' .join ('and ' + s if i == last else s for i , s in iterator )
399
408
409
+
400
410
"""
401
411
This module provides datatypes to be used in custom sass functions.
402
412
@@ -415,6 +425,7 @@ def and_join(strings):
415
425
416
426
417
427
class SassNumber (collections .namedtuple ('SassNumber' , ('value' , 'unit' ))):
428
+
418
429
def __new__ (cls , value , unit ):
419
430
value = float (value )
420
431
if not isinstance (unit , text_type ):
@@ -423,6 +434,7 @@ def __new__(cls, value, unit):
423
434
424
435
425
436
class SassColor (collections .namedtuple ('SassColor' , ('r' , 'g' , 'b' , 'a' ))):
437
+
426
438
def __new__ (cls , r , g , b , a ):
427
439
r = float (r )
428
440
g = float (g )
@@ -437,20 +449,23 @@ def __new__(cls, r, g, b, a):
437
449
438
450
439
451
class SassList (collections .namedtuple ('SassList' , ('items' , 'separator' ))):
452
+
440
453
def __new__ (cls , items , separator ):
441
454
items = tuple (items )
442
455
assert separator in SEPARATORS
443
456
return super (SassList , cls ).__new__ (cls , items , separator )
444
457
445
458
446
459
class SassError (collections .namedtuple ('SassError' , ('msg' ,))):
460
+
447
461
def __new__ (cls , msg ):
448
462
if not isinstance (msg , text_type ):
449
463
msg = msg .decode ('UTF-8' )
450
464
return super (SassError , cls ).__new__ (cls , msg )
451
465
452
466
453
- class SassWarning (collections .namedtuple ('SassError' , ('msg' ,))):
467
+ class SassWarning (collections .namedtuple ('SassWarning' , ('msg' ,))):
468
+
454
469
def __new__ (cls , msg ):
455
470
if not isinstance (msg , text_type ):
456
471
msg = msg .decode ('UTF-8' )
@@ -460,8 +475,12 @@ def __new__(cls, msg):
460
475
class SassMap (collections .Mapping ):
461
476
"""Because sass maps can have mapping types as keys, we need an immutable
462
477
hashable mapping type.
478
+
479
+ .. versionadded:: 0.7.0
480
+
463
481
"""
464
- __slots__ = ('_dict' , '_hash' ,)
482
+
483
+ __slots__ = '_dict' , '_hash'
465
484
466
485
def __init__ (self , * args , ** kwargs ):
467
486
self ._dict = dict (* args , ** kwargs )
0 commit comments