1 Sass Contexts come in two flavors:
9 #include "sass/context.h"
15 // Precision for fractional numbers
19 // Output style for the generated css code
20 // A value from above SASS_STYLE_* constants
24 // Emit comments in the generated CSS indicating
25 // the corresponding source line.
29 // embed sourceMappingUrl as data uri
30 bool source_map_embed;
33 // embed include contents in maps
34 bool source_map_contents;
37 // create file urls for sources
38 bool source_map_file_urls;
41 // Disable sourceMappingUrl in css output
42 bool omit_source_map_url;
45 // Treat source_string as sass (as opposed to scss)
46 bool is_indented_syntax_src;
49 // The input path is used for source map
50 // generating. It can be used to define
51 // something with string compilation or to
52 // overload the input file path. It is
53 // set to "stdin" for data contexts and
54 // to the input file on file contexts.
58 // The output path is used for source map
59 // generating. LibSass will not write to
60 // this file, it is just used to create
61 // information in source-maps etc.
65 // String to be used for indentation
69 // String to be used to for line feeds
73 // Colon-separated list of paths
74 // Semicolon-separated on Windows
79 // Additional include paths
80 // Must be null delimited
85 // Path to source map file
86 // Enables the source map generating
87 // Used to create sourceMappingUrl
88 char* source_map_file;
91 // Directly inserted in source maps
92 char* source_map_root;
95 // Custom functions that can be called from Sass code
96 Sass_C_Function_List c_functions;
99 // Callback to overload imports
100 Sass_C_Import_Callback importer;
106 // store context type info
107 enum Sass_Input_Style type;
110 // generated output data
114 // generated source map json
115 char* source_map_string;
129 // report imported files
130 char** included_files;
133 ***Sass_File_Context***
136 // no additional fields required
137 // input_path is already on options
140 ***Sass_Data_Context***
143 // provided source string
150 // Forward declaration
151 struct Sass_Compiler;
153 // Forward declaration
155 struct Sass_Context; // : Sass_Options
156 struct Sass_File_Context; // : Sass_Context
157 struct Sass_Data_Context; // : Sass_Context
159 // Create and initialize an option struct
160 struct Sass_Options* sass_make_options (void);
161 // Create and initialize a specific context
162 struct Sass_File_Context* sass_make_file_context (const char* input_path);
163 struct Sass_Data_Context* sass_make_data_context (char* source_string);
165 // Call the compilation step for the specific context
166 int sass_compile_file_context (struct Sass_File_Context* ctx);
167 int sass_compile_data_context (struct Sass_Data_Context* ctx);
169 // Create a sass compiler instance for more control
170 struct Sass_Compiler* sass_make_file_compiler (struct Sass_File_Context* file_ctx);
171 struct Sass_Compiler* sass_make_data_compiler (struct Sass_Data_Context* data_ctx);
173 // Execute the different compilation steps individually
174 // Usefull if you only want to query the included files
175 int sass_compiler_parse (struct Sass_Compiler* compiler);
176 int sass_compiler_execute (struct Sass_Compiler* compiler);
178 // Release all memory allocated with the compiler
179 // This does _not_ include any contexts or options
180 void sass_delete_compiler (struct Sass_Compiler* compiler);
181 void sass_delete_options(struct Sass_Options* options);
183 // Release all memory allocated and also ourself
184 void sass_delete_file_context (struct Sass_File_Context* ctx);
185 void sass_delete_data_context (struct Sass_Data_Context* ctx);
187 // Getters for Context from specific implementation
188 struct Sass_Context* sass_file_context_get_context (struct Sass_File_Context* file_ctx);
189 struct Sass_Context* sass_data_context_get_context (struct Sass_Data_Context* data_ctx);
191 // Getters for Context_Options from Sass_Context
192 struct Sass_Options* sass_context_get_options (struct Sass_Context* ctx);
193 struct Sass_Options* sass_file_context_get_options (struct Sass_File_Context* file_ctx);
194 struct Sass_Options* sass_data_context_get_options (struct Sass_Data_Context* data_ctx);
195 void sass_file_context_set_options (struct Sass_File_Context* file_ctx, struct Sass_Options* opt);
196 void sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt);
198 // Getters for Sass_Context values
199 const char* sass_context_get_output_string (struct Sass_Context* ctx);
200 int sass_context_get_error_status (struct Sass_Context* ctx);
201 const char* sass_context_get_error_json (struct Sass_Context* ctx);
202 const char* sass_context_get_error_text (struct Sass_Context* ctx);
203 const char* sass_context_get_error_message (struct Sass_Context* ctx);
204 const char* sass_context_get_error_file (struct Sass_Context* ctx);
205 size_t sass_context_get_error_line (struct Sass_Context* ctx);
206 size_t sass_context_get_error_column (struct Sass_Context* ctx);
207 const char* sass_context_get_source_map_string (struct Sass_Context* ctx);
208 char** sass_context_get_included_files (struct Sass_Context* ctx);
210 // Getters for Sass_Compiler options (query import stack)
211 size_t sass_compiler_get_import_stack_size(struct Sass_Compiler* compiler);
212 Sass_Import_Entry sass_compiler_get_last_import(struct Sass_Compiler* compiler);
213 Sass_Import_Entry sass_compiler_get_import_entry(struct Sass_Compiler* compiler, size_t idx);
214 // Getters for Sass_Compiler options (query function stack)
215 size_t sass_compiler_get_callee_stack_size(struct Sass_Compiler* compiler);
216 Sass_Callee_Entry sass_compiler_get_last_callee(struct Sass_Compiler* compiler);
217 Sass_Callee_Entry sass_compiler_get_callee_entry(struct Sass_Compiler* compiler, size_t idx);
219 // Take ownership of memory (value on context is set to 0)
220 char* sass_context_take_error_json (struct Sass_Context* ctx);
221 char* sass_context_take_error_text (struct Sass_Context* ctx);
222 char* sass_context_take_error_message (struct Sass_Context* ctx);
223 char* sass_context_take_error_file (struct Sass_Context* ctx);
224 char* sass_context_take_output_string (struct Sass_Context* ctx);
225 char* sass_context_take_source_map_string (struct Sass_Context* ctx);
231 // Getters for Context_Option values
232 int sass_option_get_precision (struct Sass_Options* options);
233 enum Sass_Output_Style sass_option_get_output_style (struct Sass_Options* options);
234 bool sass_option_get_source_comments (struct Sass_Options* options);
235 bool sass_option_get_source_map_embed (struct Sass_Options* options);
236 bool sass_option_get_source_map_contents (struct Sass_Options* options);
237 bool sass_option_get_source_map_file_urls (struct Sass_Options* options);
238 bool sass_option_get_omit_source_map_url (struct Sass_Options* options);
239 bool sass_option_get_is_indented_syntax_src (struct Sass_Options* options);
240 const char* sass_option_get_indent (struct Sass_Options* options);
241 const char* sass_option_get_linefeed (struct Sass_Options* options);
242 const char* sass_option_get_input_path (struct Sass_Options* options);
243 const char* sass_option_get_output_path (struct Sass_Options* options);
244 const char* sass_option_get_source_map_file (struct Sass_Options* options);
245 const char* sass_option_get_source_map_root (struct Sass_Options* options);
246 Sass_C_Function_List sass_option_get_c_functions (struct Sass_Options* options);
247 Sass_C_Import_Callback sass_option_get_importer (struct Sass_Options* options);
249 // Getters for Context_Option include path array
250 size_t sass_option_get_include_path_size(struct Sass_Options* options);
251 const char* sass_option_get_include_path(struct Sass_Options* options, size_t i);
252 // Plugin paths to load dynamic libraries work the same
253 size_t sass_option_get_plugin_path_size(struct Sass_Options* options);
254 const char* sass_option_get_plugin_path(struct Sass_Options* options, size_t i);
256 // Setters for Context_Option values
257 void sass_option_set_precision (struct Sass_Options* options, int precision);
258 void sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style);
259 void sass_option_set_source_comments (struct Sass_Options* options, bool source_comments);
260 void sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed);
261 void sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents);
262 void sass_option_set_source_map_file_urls (struct Sass_Options* options, bool source_map_file_urls);
263 void sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url);
264 void sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src);
265 void sass_option_set_indent (struct Sass_Options* options, const char* indent);
266 void sass_option_set_linefeed (struct Sass_Options* options, const char* linefeed);
267 void sass_option_set_input_path (struct Sass_Options* options, const char* input_path);
268 void sass_option_set_output_path (struct Sass_Options* options, const char* output_path);
269 void sass_option_set_plugin_path (struct Sass_Options* options, const char* plugin_path);
270 void sass_option_set_include_path (struct Sass_Options* options, const char* include_path);
271 void sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file);
272 void sass_option_set_source_map_root (struct Sass_Options* options, const char* source_map_root);
273 void sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions);
274 void sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer);
276 // Push function for paths (no manipulation support for now)
277 void sass_option_push_plugin_path (struct Sass_Options* options, const char* path);
278 void sass_option_push_include_path (struct Sass_Options* options, const char* path);
280 // Resolve a file via the given include paths in the sass option struct
281 // find_file looks for the exact file name while find_include does a regular sass include
282 char* sass_find_file (const char* path, struct Sass_Options* opt);
283 char* sass_find_include (const char* path, struct Sass_Options* opt);
285 // Resolve a file relative to last import or include paths in the sass option struct
286 // find_file looks for the exact file name while find_include does a regular sass include
287 char* sass_compiler_find_file (const char* path, struct Sass_Compiler* compiler);
288 char* sass_compiler_find_include (const char* path, struct Sass_Compiler* compiler);
293 - [Sass Context Example](api-context-example.md)
294 - [Sass Context Internal](api-context-internal.md)