Skip to content

Commit a3b8ce1

Browse files
committed
Docs: Split API docs into separate markdown files
1 parent af4bd51 commit a3b8ce1

13 files changed

+904
-846
lines changed

docs/API.md

Lines changed: 0 additions & 845 deletions
This file was deleted.

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar_label: Docs
88
# gulp documentation
99

1010
* [Getting Started](getting-started/) - Get started with gulp
11-
* [API documentation](API.md) - The programming interface, defined
11+
* [API documentation](api/) - The programming interface, defined
1212
* [CLI documentation](CLI.md) - Learn how to call tasks and use compilers
1313
* [Writing a Plugin](writing-a-plugin/) - The essentials of writing a gulp plugin
1414
* [Why Use Pump?](why-use-pump/README.md) - Why to use the `pump` module instead of calling `.pipe` yourself

docs/api/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- front-matter
2+
id: api-toc
3+
title: API Table of Contents
4+
hide_title: true
5+
sidebar_label: api-toc
6+
-->
7+
8+
## gulp API docs
9+
10+
* [gulp.src](src.md) - Emit files matching one or more globs
11+
* [gulp.dest](dest.md) - Write files to directories
12+
* [gulp.symlink](symlink.md) - Write files to symlinks
13+
* [gulp.task](task.md) - Define tasks
14+
* [gulp.lastRun](lastRun.md) - Get timestamp of last successful run
15+
* [gulp.parallel](parallel.md) - Run tasks in parallel
16+
* [gulp.series](series.md) - Run tasks in series
17+
* [gulp.watch](watch.md) - Do something when a file changes
18+
* [gulp.tree](tree.md) - Get the tree of tasks
19+
* [gulp.registry](registry.md) - Get or set the task registry

docs/api/dest.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!-- front-matter
2+
id: api-dest
3+
title: dest()
4+
hide_title: true
5+
sidebar_label: dest()
6+
-->
7+
8+
# `gulp.dest(path[, options])`
9+
10+
Can be piped to and it will write files. Re-emits all data passed to it so you
11+
can pipe to multiple folders. Folders that don't exist will be created.
12+
13+
```javascript
14+
gulp.src('./client/templates/*.pug')
15+
.pipe(pug())
16+
.pipe(gulp.dest('./build/templates'))
17+
.pipe(minify())
18+
.pipe(gulp.dest('./build/minified_templates'));
19+
```
20+
21+
The write path is calculated by appending the file relative path to the given
22+
destination directory. In turn, relative paths are calculated against
23+
the file base. See `gulp.src` above for more info.
24+
25+
## path
26+
Type: `String` or `Function`
27+
28+
The path (output folder) to write files to. Or a function that returns it,
29+
the function will be provided a [vinyl File instance].
30+
31+
## options
32+
Type: `Object`
33+
34+
### options.cwd
35+
Type: `String`
36+
37+
Default: `process.cwd()`
38+
39+
`cwd` for the output folder, only has an effect if provided output folder is
40+
relative.
41+
42+
### options.mode
43+
Type: `String` or `Number`
44+
45+
Default: the mode of the input file (file.stat.mode) or the process mode
46+
if the input file has no mode property.
47+
48+
Octal permission specifying the mode the files should be created with: e.g.
49+
`"0744"`, `0744` or `484` (`0744` in base 10).
50+
51+
### options.dirMode
52+
Type: `String` or `Number`
53+
54+
Default: Default is the process mode.
55+
56+
Octal permission specifying the mode the directory should be created with: e.g.
57+
`"0755"`, `0755` or `493` (`0755` in base 10).
58+
59+
### options.overwrite
60+
Type: `Boolean`
61+
62+
Default: `true`
63+
64+
Specify if existing files with the same path should be overwritten or not.
65+
66+
[vinyl File instance]: https://github.com/gulpjs/vinyl

docs/api/lastRun.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!-- front-matter
2+
id: api-lastRun
3+
title: lastRun()
4+
hide_title: true
5+
sidebar_label: lastRun()
6+
-->
7+
8+
# `gulp.lastRun(taskName, [timeResolution])`
9+
10+
Returns the timestamp of the last time the task ran successfully. The time
11+
will be the time the task started. Returns `undefined` if the task has
12+
not run yet.
13+
14+
## taskName
15+
16+
Type: `String`
17+
18+
The name of the registered task or of a function.
19+
20+
## timeResolution
21+
22+
Type: `Number`.
23+
24+
Default: `1000` on node v0.10, `0` on node v0.12 (and iojs v1.5).
25+
26+
Set the time resolution of the returned timestamps. Assuming
27+
the task named "someTask" ran at `1426000004321`:
28+
29+
- `gulp.lastRun('someTask', 1000)` would return `1426000004000`.
30+
- `gulp.lastRun('someTask', 100)` would return `1426000004300`.
31+
32+
`timeResolution` allows you to compare a run time to a file [mtime stat][fs stats]
33+
attribute. This attribute time resolution may vary depending of the node version
34+
and the file system used:
35+
36+
- on node v0.10, a file [mtime stat][fs stats] time resolution of any files will be 1s at best;
37+
- on node v0.12 and iojs v1.5, 1ms at best;
38+
- for files on FAT32, the mtime time resolution is 2s;
39+
- on HFS+ and Ext3, 1s;
40+
- on NTFS, 1s on node v0.10, 100ms on node 0.12;
41+
- on Ext4, 1s on node v0.10, 1ms on node 0.12.
42+
43+
[fs stats]: https://nodejs.org/api/fs.html#fs_class_fs_stats

docs/api/parallel.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!-- front-matter
2+
id: api-parallel
3+
title: parallel()
4+
hide_title: true
5+
sidebar_label: parallel()
6+
-->
7+
8+
# `gulp.parallel(...tasks)`
9+
10+
Takes a number of task names or functions and returns a function of the composed
11+
tasks or functions.
12+
13+
When using task names, the task should already be registered.
14+
15+
When the returned function is executed, the tasks or functions will be executed
16+
in parallel, all being executed at the same time. If an error occurs,
17+
all execution will complete.
18+
19+
```js
20+
gulp.task('one', function(done) {
21+
// do stuff
22+
done();
23+
});
24+
25+
gulp.task('two', function(done) {
26+
// do stuff
27+
done();
28+
});
29+
30+
gulp.task('default', gulp.parallel('one', 'two', function(done) {
31+
// do more stuff
32+
done();
33+
}));
34+
```
35+
36+
## tasks
37+
Type: `Array`, `String` or `Function`
38+
39+
A task name, a function or an array of either.
40+

docs/api/registry.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- front-matter
2+
id: api-registry
3+
title: registry()
4+
hide_title: true
5+
sidebar_label: registry()
6+
-->
7+
8+
# `gulp.registry([registry])`
9+
10+
Get or set the underlying task registry. Inherited from [undertaker]; see the undertaker documention on [registries](https://github.com/phated/undertaker#registryregistryinstance). Using this, you can change registries that enhance gulp in different ways. Utilizing a custom registry has at least three use cases:
11+
12+
- [Sharing tasks](https://github.com/phated/undertaker#sharing-tasks)
13+
- [Sharing functionality](https://github.com/phated/undertaker#sharing-functionalities) (e.g. you could override the task prototype to add some additional logging, bind task metadata or include some config settings.)
14+
- Handling other behavior that hooks into the registry lifecycle (see [gulp-hub](https://github.com/frankwallis/gulp-hub) for an example)
15+
16+
To build your own custom registry see the [undertaker documentation on custom registries](https://github.com/phated/undertaker#custom-registries).
17+
18+
## registry
19+
20+
A registry instance. When passed in, the tasks from the current registry will be transferred to the new registry and then current registry will be replaced with the new registry.
21+
22+
## Example
23+
24+
This example shows how to create and use a simple custom registry to add tasks.
25+
26+
```js
27+
//gulpfile.js
28+
var gulp = require('gulp');
29+
30+
var companyTasks = require('./myCompanyTasksRegistry.js');
31+
32+
gulp.registry(companyTasks);
33+
34+
gulp.task('one', gulp.parallel('someCompanyTask', function(done) {
35+
console.log('in task one');
36+
done();
37+
}));
38+
```
39+
40+
```js
41+
//myCompanyTasksRegistry.js
42+
var util = require('util');
43+
44+
var DefaultRegistry = require('undertaker-registry');
45+
46+
function MyCompanyTasksRegistry() {
47+
DefaultRegistry.call(this);
48+
}
49+
util.inherits(MyCompanyTasksRegistry, DefaultRegistry);
50+
51+
MyCompanyTasksRegistry.prototype.init = function(gulp) {
52+
gulp.task('clean', function(done) {
53+
done();
54+
});
55+
gulp.task('someCompanyTask', function(done) {
56+
console.log('performing some company task.');
57+
done();
58+
});
59+
};
60+
61+
module.exports = new MyCompanyTasksRegistry();
62+
```
63+
64+
[undertaker]: https://github.com/gulpjs/undertaker

docs/api/series.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!-- front-matter
2+
id: api-series
3+
title: series()
4+
hide_title: true
5+
sidebar_label: series()
6+
-->
7+
8+
# `gulp.series(...tasks)`
9+
10+
Takes a number of task names or functions and returns a function of the composed
11+
tasks or functions.
12+
13+
When using task names, the task should already be registered.
14+
15+
When the returned function is executed, the tasks or functions will be executed
16+
in series, each waiting for the prior to finish. If an error occurs,
17+
execution will stop.
18+
19+
```js
20+
gulp.task('one', function(done) {
21+
// do stuff
22+
done();
23+
});
24+
25+
gulp.task('two', function(done) {
26+
// do stuff
27+
done();
28+
});
29+
30+
gulp.task('default', gulp.series('one', 'two', function(done) {
31+
// do more stuff
32+
done();
33+
}));
34+
```
35+
36+
## tasks
37+
Type: `Array`, `String` or `Function`
38+
39+
A task name, a function or an array of either.

0 commit comments

Comments
 (0)