You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-doc.md
+48-12Lines changed: 48 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
## Introduction
2
2
3
-
LibSass wouldn't be much good without a way to interface with it. These interface documentations describe the various functions and data structures available to implementers. They are split up over three major components, which have all their own source files (plus some common functionality).
3
+
LibSass wouldn't be much good without a way to interface with it. These
4
+
interface documentations describe the various functions and data structures
5
+
available to implementers. They are split up over three major components, which
6
+
have all their own source files (plus some common functionality).
4
7
5
8
-[Sass Context](api-context.md) - Trigger and handle the main Sass compilation
6
9
-[Sass Value](api-value.md) - Exchange values and its format with LibSass
The most important is your sass file (or string of sass code). With this, you will want to start a LibSass compiler. Here is some pseudocode describing the process. The compiler has two different modes: direct input as a string with `Sass_Data_Context` or LibSass will do file reading for you by using `Sass_File_Context`. See the code for a list of options available [Sass_Options](https://github.com/sass/libsass/blob/36feef0/include/sass/interface.h#L18)
47
+
The most important is your sass file (or string of sass code). With this, you
48
+
will want to start a LibSass compiler. Here is some pseudocode describing the
49
+
process. The compiler has two different modes: direct input as a string with
50
+
`Sass_Data_Context` or LibSass will do file reading for you by using
51
+
`Sass_File_Context`. See the code for a list of options available
This mirrors very well how `libsass` uses these structures.
99
107
100
-
-`Sass_Options` holds everything you feed in before the compilation. It also hosts `input_path` and `output_path` options, because they are used to generate/calculate relative links in source-maps. The `input_path` is shared with `Sass_File_Context`.
108
+
-`Sass_Options` holds everything you feed in before the compilation. It also hosts
109
+
`input_path` and `output_path` options, because they are used to generate/calculate
110
+
relative links in source-maps. The `input_path` is shared with `Sass_File_Context`.
101
111
-`Sass_Context` holds all the data returned by the compilation step.
102
112
-`Sass_File_Context` is a specific implementation that requires no additional fields
103
113
-`Sass_Data_Context` is a specific implementation that adds the `input_source` field
@@ -106,8 +116,11 @@ Structs can be down-casted to access `context` or `options`!
106
116
107
117
## Memory handling and life-cycles
108
118
109
-
We keep memory around for as long as the main [context](api-context.md) object is not destroyed (`sass_delete_context`). LibSass will create copies of most inputs/options beside the main sass code.
110
-
You need to allocate and fill that buffer before passing it to LibSass. You may also overtake memory management from libsass for certain return values (i.e. `sass_context_take_output_string`).
119
+
We keep memory around for as long as the main [context](api-context.md) object
120
+
is not destroyed (`sass_delete_context`). LibSass will create copies of most
121
+
inputs/options beside the main sass code. You need to allocate and fill that
122
+
buffer before passing it to LibSass. You may also overtake memory management
123
+
from libsass for certain return values (i.e. `sass_context_take_output_string`).
The `input_path` is part of `Sass_Options`, but it also is the main option for `Sass_File_Context`. It is also used to generate relative file links in source-maps. Therefore it is pretty usefull to pass this information if you have a `Sass_Data_Context` and know the original path.
153
+
The `input_path` is part of `Sass_Options`, but it also is the main option for
154
+
`Sass_File_Context`. It is also used to generate relative file links in source-
155
+
maps. Therefore it is pretty usefull to pass this information if you have a
156
+
`Sass_Data_Context` and know the original path.
141
157
142
158
**output_path**
143
159
144
-
Be aware that `libsass` does not write the output file itself. This option merely exists to give `libsass` the proper information to generate links in source-maps. The file has to be written to the disk by the binding/implementation. If the `output_path` is omitted, `libsass` tries to extrapolate one from the `input_path` by replacing (or adding) the file ending with `.css`.
160
+
Be aware that `libsass` does not write the output file itself. This option
161
+
merely exists to give `libsass` the proper information to generate links in
162
+
source-maps. The file has to be written to the disk by the
163
+
binding/implementation. If the `output_path` is omitted, `libsass` tries to
164
+
extrapolate one from the `input_path` by replacing (or adding) the file ending
165
+
with `.css`.
145
166
146
167
## Error Codes
147
168
148
-
The `error_code` is integer value which indicates the type of error that occurred inside the LibSass process. Following is the list of error codes along with the short description:
169
+
The `error_code` is integer value which indicates the type of error that
170
+
occurred inside the LibSass process. Following is the list of error codes along
171
+
with the short description:
149
172
150
173
* 1: normal errors like parsing or `eval` errors
151
174
* 2: bad allocation error (memory error)
152
175
* 3: "untranslated" C++ exception (`throw std::exception`)
Although for the API consumer, error codes do not offer much value except indicating whether *any* error occurred during the compilation, it helps debugging the LibSass internal code paths.
179
+
Although for the API consumer, error codes do not offer much value except
180
+
indicating whether *any* error occurred during the compilation, it helps
181
+
debugging the LibSass internal code paths.
157
182
158
183
## Real-World Implementations
159
184
160
-
The proof is in the pudding, so we have highlighted a few implementations that should be on par with the latest LibSass interface version. Some of them may not have all features implemented!
185
+
The proof is in the pudding, so we have highlighted a few implementations that
186
+
should be on par with the latest LibSass interface version. Some of them may not
We use a functional API to make dynamic linking more robust and future compatible. The API is not yet 100% stable, so we do not yet guarantee [ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) forward compatibility. We will do so, once we increase the shared library version above 1.0.
195
+
We use a functional API to make dynamic linking more robust and future
196
+
compatible. The API is not yet 100% stable, so we do not yet guarantee
LibSass can load plugins from directories. Just define `plugin_path` on context options to load all plugins from the given directories. To implement plugins, please consult the [[Wiki-Page for plugins|API-Plugins]].
202
+
LibSass can load plugins from directories. Just define `plugin_path` on context
203
+
options to load all plugins from the directories. To implement plugins, please
0 commit comments