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

Commit 5bd15b1

Browse files
committed
docs: split up into separate files like lib sass
1 parent a04e84d commit 5bd15b1

26 files changed

Lines changed: 449 additions & 475 deletions

README.md

Lines changed: 0 additions & 475 deletions
Large diffs are not rendered by default.

docs/api-data.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# data
2+
Type: `String`
3+
Default: `null`
4+
**Special**: `file` or `data` must be specified
5+
6+
A string to pass to [LibSass] to render. It is recommended that you use `includePaths` in conjunction with this so that [LibSass] can find files when using the `@import` directive.

docs/api-file.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# file
2+
Type: `String`
3+
Default: `null`
4+
**Special**: `file` or `data` must be specified
5+
6+
Path to a file for [LibSass] to render.

docs/api-functions.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# functions (>= v3.0.0) - _experimental_
2+
3+
**This is an experimental LibSass feature. Use with caution.**
4+
5+
`functions` is an `Object` that holds a collection of custom functions that may be invoked by the sass files being compiled. They may take zero or more input parameters and must return a value either synchronously (`return ...;`) or asynchronously (`done();`). Those parameters will be instances of one of the constructors contained in the `require('node-sass').types` hash. The return value must be of one of these types as well. See the list of available types below:
6+
7+
## types.Number(value [, unit = ""])
8+
* `getValue()`/ `setValue(value)` : gets / sets the numerical portion of the number
9+
* `getUnit()` / `setUnit(unit)` : gets / sets the unit portion of the number
10+
11+
## types.String(value)
12+
* `getValue()` / `setValue(value)` : gets / sets the enclosed string
13+
14+
## types.Color(r, g, b [, a = 1.0]) or types.Color(argb)
15+
* `getR()` / `setR(value)` : red component (integer from `0` to `255`)
16+
* `getG()` / `setG(value)` : green component (integer from `0` to `255`)
17+
* `getB()` / `setB(value)` : blue component (integer from `0` to `255`)
18+
* `getA()` / `setA(value)` : alpha component (number from `0` to `1.0`)
19+
20+
Example:
21+
22+
```javascript
23+
var Color = require('node-sass').types.Color,
24+
c1 = new Color(255, 0, 0),
25+
c2 = new Color(0xff0088cc);
26+
```
27+
28+
## types.Boolean(value)
29+
* `getValue()` : gets the enclosed boolean
30+
* `types.Boolean.TRUE` : Singleton instance of `types.Boolean` that holds "true"
31+
* `types.Boolean.FALSE` : Singleton instance of `types.Boolean` that holds "false"
32+
33+
## types.List(length [, commaSeparator = true])
34+
* `getValue(index)` / `setValue(index, value)` : `value` must itself be an instance of one of the constructors in `sass.types`.
35+
* `getSeparator()` / `setSeparator(isComma)` : whether to use commas as a separator
36+
* `getLength()`
37+
38+
## types.Map(length)
39+
* `getKey(index)` / `setKey(index, value)`
40+
* `getValue(index)` / `setValue(index, value)`
41+
* `getLength()`
42+
43+
## types.Null()
44+
* `types.Null.NULL` : Singleton instance of `types.Null`.
45+
46+
## Example
47+
48+
```javascript
49+
sass.renderSync({
50+
data: '#{headings(2,5)} { color: #08c; }',
51+
functions: {
52+
'headings($from: 0, $to: 6)': function(from, to) {
53+
var i, f = from.getValue(), t = to.getValue(),
54+
list = new sass.types.List(t - f + 1);
55+
56+
for (i = f; i <= t; i++) {
57+
list.setValue(i - f, new sass.types.String('h' + i));
58+
}
59+
60+
return list;
61+
}
62+
}
63+
});
64+
```

docs/api-importers.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# importer (>= v2.0.0) - _experimental_
2+
3+
**This is an experimental LibSass feature. Use with caution.**
4+
5+
Type: `Function | Function[]` signature `function(url, prev, done)`
6+
Default: `undefined`
7+
8+
Function Parameters and Information:
9+
* `url (String)` - the path in import **as-is**, which [LibSass] encountered
10+
* `prev (String)` - the previously resolved path
11+
* `done (Function)` - a callback function to invoke on async completion, takes an object literal containing
12+
* `file (String)` - an alternate path for [LibSass] to use **OR**
13+
* `contents (String)` - the imported contents (for example, read from memory or the file system)
14+
15+
Handles when [LibSass] encounters the `@import` directive. A custom importer allows extension of the [LibSass] engine in both a synchronous and asynchronous manner. In both cases, the goal is to either `return` or call `done()` with an object literal. Depending on the value of the object literal, one of two things will happen.
16+
17+
When returning or calling `done()` with `{ file: "String" }`, the new file path will be assumed for the `@import`. It's recommended to be mindful of the value of `prev` in instances where relative path resolution may be required.
18+
19+
When returning or calling `done()` with `{ contents: "String" }`, the string value will be used as if the file was read in through an external source.
20+
21+
Starting from v3.0.0:
22+
23+
* `this` refers to a contextual scope for the immediate run of `sass.render` or `sass.renderSync`
24+
25+
* importers can return error and LibSass will emit that error in response. For instance:
26+
27+
```javascript
28+
done(new Error('doesn\'t exist!'));
29+
// or return synchornously
30+
return new Error('nothing to do here');
31+
```
32+
33+
* importer can be an array of functions, which will be called by LibSass in the order of their occurrence in array. This helps user specify special importer for particular kind of path (filesystem, http). If an importer does not want to handle a particular path, it should return `null`. See [functions section](#functions--v300) for more details on Sass types.

docs/api-includepaths.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# includePaths
2+
Type: `Array<String>`
3+
Default: `[]`
4+
5+
An array of paths that [LibSass] can look in to attempt to resolve your `@import` declarations. When using `data`, it is recommended that you use this.

docs/api-indentedsyntax.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# indentedSyntax
2+
Type: `Boolean`
3+
Default: `false`
4+
5+
`true` values enable [Sass Indented Syntax](http://sass-lang.com/documentation/file.INDENTED_SYNTAX.html) for parsing the data string or file.
6+
7+
__Note:__ node-sass/libsass will compile a mixed library of scss and indented syntax (.sass) files with the Default setting (false) as long as .sass and .scss extensions are used in filenames.

docs/api-indenttype.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# indentType (>= v3.0.0)
2+
Type: `String`
3+
Default: `space`
4+
5+
Used to determine whether to use space or tab character for indentation.

docs/api-indentwidth.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# indentWidth (>= v3.0.0)
2+
Type: `Number`
3+
Default: `2`
4+
Maximum: `10`
5+
6+
Used to determine the number of spaces or tabs to be used for indentation.

docs/api-info.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Version information (>= v2.0.0)
2+
3+
Both `node-sass` and `libsass` version info is now exposed via the `info` method:
4+
5+
```javascript
6+
var sass = require('node-sass');
7+
8+
console.log(sass.info);
9+
10+
/*
11+
it will output something like:
12+
13+
node-sass 2.0.1 (Wrapper) [JavaScript]
14+
libsass 3.1.0 (Sass Compiler) [C/C++]
15+
*/
16+
```
17+
18+
Since node-sass >=v3.0.0 LibSass version is determined at run time.

0 commit comments

Comments
 (0)