Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 740b6de

Browse files
committed
Add sass.OUTPUT_STYLES constant
1 parent dad88e5 commit 740b6de

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Version 0.2.4
66

77
To be released.
88

9+
- Added :const:`sass.OUTPUT_STYLES` constant map.
10+
911

1012
Version 0.2.3
1113
-------------

docs/sass.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ type.
3838
:raises exceptions.IOError: when the ``filename`` doesn't exist or
3939
cannot be read
4040

41+
.. data:: OUTPUT_STYLES
42+
43+
(:class:`collections.Mapping`) The dictionary of output styles.
44+
Keys are output name strings, and values are flag integers.
45+
4146
.. exception:: CompileError
4247

4348
The exception type that is raised by :func:`compile()`. It is a subtype

sass.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,25 @@ static PyMethodDef PySass_methods[] = {
272272
PyMODINIT_FUNC
273273
initsass()
274274
{
275-
PyObject *module, *version;
275+
PyObject *module, *version, *output_styles;
276+
size_t i = 0;
276277

277278
module = Py_InitModule3("sass", PySass_methods,
278279
"The thin binding of libsass for Python.");
279280
if (module == NULL) {
280281
return;
281282
}
283+
284+
output_styles = PyDict_New();
285+
for (i = 0; PySass_output_style_enum[i].label; ++i) {
286+
PyDict_SetItemString(
287+
output_styles,
288+
PySass_output_style_enum[i].label,
289+
PyInt_FromLong((long) PySass_output_style_enum[i].value)
290+
);
291+
}
292+
PyModule_AddObject(module, "OUTPUT_STYLES", output_styles);
293+
282294
#ifdef LIBSASS_PYTHON_VERSION
283295
version = PyString_FromString(LIBSASS_PYTHON_VERSION);
284296
#else

sasstests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import with_statement
22
from attest import assert_hook
33

4+
import collections
45
import os.path
56
import re
67
import shutil
@@ -23,6 +24,13 @@ def version():
2324
assert re.match(r'^\d+\.\d+\.\d+$', sass.__version__)
2425

2526

27+
@suite.test
28+
def output_styles():
29+
if hasattr(collections, 'Mapping'):
30+
assert isinstance(sass.OUTPUT_STYLES, collections.Mapping)
31+
assert 'nested' in sass.OUTPUT_STYLES
32+
33+
2634
@suite.test
2735
def compile_required_arguments():
2836
with raises(TypeError):

0 commit comments

Comments
 (0)