Skip to content

Commit 6d156ae

Browse files
committed
Changelog for #43 and #44
1 parent 3710fca commit 6d156ae

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

docs/changes.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Version 0.7.0
77
To be released.
88

99
- Follow up the libsass upstream: :upcommit:`3.1.0` --- See the `release note`__
10-
of Libsass.
10+
of Libsass. [:issue:`38`, :issue:`43` by Anthony Sottile]
1111

1212
- Custom functions and imports
1313
- Decrementing in ``@for`` loops
@@ -19,6 +19,18 @@ To be released.
1919
- ``unique-id()``
2020
- ``random()``
2121

22+
- Added custom functions support. [:issue:`13`, :issue:`44` by Anthony Sottile]
23+
24+
- Added ``custom_functions`` parameter to :func:`sass.compile()` function.
25+
- Added data types for custom functions:
26+
27+
- :class:`sass.SassNumber`
28+
- :class:`sass.SassColor`
29+
- :class:`sass.SassList`
30+
- :class:`sass.SassMap`
31+
- :class:`sass.SassError`
32+
- :class:`sass.SassWarning`
33+
2234
- Added ``precision`` parameter to :func:`sass.compile()` function.
2335
[:issue:`39` by Andrea Stagi]
2436
- :program:`sassc` has a new :option:`-p <sassc -p>`/:option:`--precision

sass.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def compile(**kwargs):
130130
:type image_path: :class:`str`
131131
:param precision: optional precision for numbers. :const:`5` by default.
132132
:type precision: :class:`int`
133+
:param custom_functions: optional mapping of custom functions
134+
:type custom_functions: :class:`collections.Mapping`
133135
:returns: the compiled CSS string
134136
:rtype: :class:`str`
135137
:raises sass.CompileError: when it fails for any reason
@@ -161,6 +163,8 @@ def compile(**kwargs):
161163
:type image_path: :class:`str`
162164
:param precision: optional precision for numbers. :const:`5` by default.
163165
:type precision: :class:`int`
166+
:param custom_functions: optional mapping of custom functions
167+
:type custom_functions: :class:`collections.Mapping`
164168
:returns: the compiled CSS string, or a pair of the compiled CSS string
165169
and the source map string if ``source_comments='map'``
166170
:rtype: :class:`str`, :class:`tuple`
@@ -195,6 +199,8 @@ def compile(**kwargs):
195199
:type image_path: :class:`str`
196200
:param precision: optional precision for numbers. :const:`5` by default.
197201
:type precision: :class:`int`
202+
:param custom_functions: optional mapping of custom functions
203+
:type custom_functions: :class:`collections.Mapping`
198204
:raises sass.CompileError: when it fails for any reason
199205
(for example the given SASS has broken syntax)
200206
@@ -212,6 +218,9 @@ def compile(**kwargs):
212218
.. versionadded:: 0.7.0
213219
Added ``precision`` parameter.
214220
221+
.. versionadded:: 0.7.0
222+
Added ``custom_functions`` parameter.
223+
215224
"""
216225
modes = set()
217226
for mode_name in MODES:
@@ -397,6 +406,7 @@ def and_join(strings):
397406
iterator = enumerate(strings)
398407
return ', '.join('and ' + s if i == last else s for i, s in iterator)
399408

409+
400410
"""
401411
This module provides datatypes to be used in custom sass functions.
402412
@@ -415,6 +425,7 @@ def and_join(strings):
415425

416426

417427
class SassNumber(collections.namedtuple('SassNumber', ('value', 'unit'))):
428+
418429
def __new__(cls, value, unit):
419430
value = float(value)
420431
if not isinstance(unit, text_type):
@@ -423,6 +434,7 @@ def __new__(cls, value, unit):
423434

424435

425436
class SassColor(collections.namedtuple('SassColor', ('r', 'g', 'b', 'a'))):
437+
426438
def __new__(cls, r, g, b, a):
427439
r = float(r)
428440
g = float(g)
@@ -437,20 +449,23 @@ def __new__(cls, r, g, b, a):
437449

438450

439451
class SassList(collections.namedtuple('SassList', ('items', 'separator'))):
452+
440453
def __new__(cls, items, separator):
441454
items = tuple(items)
442455
assert separator in SEPARATORS
443456
return super(SassList, cls).__new__(cls, items, separator)
444457

445458

446459
class SassError(collections.namedtuple('SassError', ('msg',))):
460+
447461
def __new__(cls, msg):
448462
if not isinstance(msg, text_type):
449463
msg = msg.decode('UTF-8')
450464
return super(SassError, cls).__new__(cls, msg)
451465

452466

453-
class SassWarning(collections.namedtuple('SassError', ('msg',))):
467+
class SassWarning(collections.namedtuple('SassWarning', ('msg',))):
468+
454469
def __new__(cls, msg):
455470
if not isinstance(msg, text_type):
456471
msg = msg.decode('UTF-8')
@@ -460,8 +475,12 @@ def __new__(cls, msg):
460475
class SassMap(collections.Mapping):
461476
"""Because sass maps can have mapping types as keys, we need an immutable
462477
hashable mapping type.
478+
479+
.. versionadded:: 0.7.0
480+
463481
"""
464-
__slots__ = ('_dict', '_hash',)
482+
483+
__slots__ = '_dict', '_hash'
465484

466485
def __init__(self, *args, **kwargs):
467486
self._dict = dict(*args, **kwargs)

0 commit comments

Comments
 (0)