sassutils.builder
— Build the whole directory¶
- class sassutils.builder.Manifest(sass_path, css_path=None, wsgi_path=None, strip_extension=None)¶
Building manifest of Sass/SCSS.
- Parameters:
sass_path (
str
,basestring
) – the path of the directory that contains Sass/SCSS source filescss_path (
str
,basestring
) – the path of the directory to store compiled CSS filesstrip_extension (
bool
) – whether to remove the original file extension
- build(package_dir, output_style='nested')¶
Builds the Sass/SCSS files in the specified
sass_path
. It findssass_path
and locatescss_path
as relative to the givenpackage_dir
.- Parameters:
package_dir (
str
,basestring
) – the path of package directoryoutput_style (
str
) – an optional coding style of the compiled result. choose one of:'nested'
(default),'expanded'
,'compact'
,'compressed'
- Returns:
the set of compiled CSS filenames
- Return type:
frozenset
Added in version 0.6.0: The
output_style
parameter.
- build_one(package_dir, filename, source_map=False)¶
Builds one Sass/SCSS file.
- Parameters:
package_dir (
str
,basestring
) – the path of package directoryfilename (
str
,basestring
) – the filename of Sass/SCSS source to compilesource_map (
bool
) – whether to use source maps. ifTrue
it also write a source map to afilename
followed by.map
suffix. default isFalse
- Returns:
the filename of compiled CSS
- Return type:
str
,basestring
Added in version 0.4.0: Added optional
source_map
parameter.
- resolve_filename(package_dir, filename)¶
Gets a proper full relative path of Sass source and CSS source that will be generated, according to
package_dir
andfilename
.- Parameters:
package_dir (
str
,basestring
) – the path of package directoryfilename (
str
,basestring
) – the filename of Sass/SCSS source to compile
- Returns:
a pair of (sass, css) path
- Return type:
tuple
- unresolve_filename(package_dir, filename)¶
Retrieves the probable source path from the output filename. Pass in a .css path to get out a .scss path.
- Parameters:
package_dir (
str
) – the path of the package directoryfilename (
str
) – the css filename
- Returns:
the scss filename
- Return type:
str
- sassutils.builder.SUFFIXES = frozenset({'sass', 'scss'})¶
(
frozenset
) The set of supported filename suffixes.
- sassutils.builder.SUFFIX_PATTERN = re.compile('[.](sass|scss)$')¶
(
re.RegexObject
) The regular expression pattern which matches to filenames of supportedSUFFIXES
.
- sassutils.builder.build_directory(sass_path, css_path, output_style='nested', _root_sass=None, _root_css=None, strip_extension=False)¶
Compiles all Sass/SCSS files in
path
to CSS.- Parameters:
sass_path (
str
,basestring
) – the path of the directory which contains source files to compilecss_path (
str
,basestring
) – the path of the directory compiled CSS files will gooutput_style (
str
) – an optional coding style of the compiled result. choose one of:'nested'
(default),'expanded'
,'compact'
,'compressed'
- Returns:
a dictionary of source filenames to compiled CSS filenames
- Return type:
collections.abc.Mapping
Added in version 0.6.0: The
output_style
parameter.