Skip to content

Commit 2c9841f

Browse files
authored
Merge pull request #225 from mprahl/add-compiledir-example
Add an example in the docs about compiling a directory
2 parents d3081c3 + 87f294f commit 2c9841f

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

docs/index.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,38 @@ It's available on PyPI_, so you can install it using :program:`pip`:
5656

5757
.. _example:
5858

59-
Example
60-
-------
59+
Examples
60+
--------
61+
62+
Compile a String of SASS to CSS
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6164

6265
>>> import sass
6366
>>> sass.compile(string='a { b { color: blue; } }')
6467
'a b {\n color: blue; }\n'
6568

69+
Compile a Directory of SASS Files to CSS
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
>>> import sass
73+
>>> import os
74+
>>> os.mkdir('css')
75+
>>> os.mkdir('sass')
76+
>>> scss = """\
77+
... $theme_color: #cc0000;
78+
... body {
79+
... background-color: $theme_color;
80+
... }
81+
... """
82+
>>> with open('sass/example.scss', 'w') as example_scss:
83+
... example_scss.write(scss)
84+
...
85+
>>> sass.compile(dirname=('sass', 'css'), output_style='compressed')
86+
>>> with open('css/example.css') as example_css:
87+
... print(example_css.read())
88+
...
89+
body{background-color:#c00}
90+
6691

6792
User's Guide
6893
------------

0 commit comments

Comments
 (0)