simplify compilation requestors
This commit is contained in:
@@ -217,21 +217,21 @@ This tells you: `connect` is a function taking `(from, to, label)`, declared on
|
||||
|
||||
The index and explain modules can be used directly from ƿit scripts:
|
||||
|
||||
### index.cm
|
||||
### Via shop (recommended)
|
||||
|
||||
```javascript
|
||||
var tokenize_mod = use('tokenize')
|
||||
var parse_mod = use('parse')
|
||||
var fold_mod = use('fold')
|
||||
var index_mod = use('index')
|
||||
|
||||
var pipeline = {tokenize: tokenize_mod, parse: parse_mod, fold: fold_mod}
|
||||
var idx = index_mod.index_file(src, filename, pipeline)
|
||||
var shop = use('internal/shop')
|
||||
var idx = shop.index_file(path)
|
||||
```
|
||||
|
||||
`index_file` runs the full pipeline (tokenize, parse, fold) and returns the index. If you already have a parsed AST and tokens, use `index_ast` instead:
|
||||
`shop.index_file` runs the full pipeline (tokenize, parse, index, resolve imports) and caches the result.
|
||||
|
||||
### index.cm (direct)
|
||||
|
||||
If you already have a parsed AST and tokens, use `index_ast` directly:
|
||||
|
||||
```javascript
|
||||
var index_mod = use('index')
|
||||
var idx = index_mod.index_ast(ast, tokens, filename)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user