Skip to content

Commit d0ced75

Browse files
cssmagicphated
authored andcommitted
Docs: Improve format of API
1 parent 430df36 commit d0ced75

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

docs/API.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ The following expression matches `a.js` and `bad.js`:
3838

3939

4040
Note that globs are evaluated in order, which means this is possible:
41-
```
41+
42+
```js
4243
// exclude every JS file that starts with a b except bad.js
4344
gulp.src(['*.js', '!b*.js', 'bad.js'])
4445
```
@@ -106,6 +107,7 @@ emits globbed files.
106107

107108
##### options.allowEmpty
108109
Type: `Boolean`
110+
109111
Default: `false`
110112

111113
When true, will allow singular globs to fail to match. Otherwise, globs which are only supposed to match one file (such as `./foo/bar.js`) will cause an error to be thrown if they don't match.
@@ -120,6 +122,7 @@ gulp.src('app/scripts.js', { allowEmpty: true })
120122
.pipe(...);
121123
```
122124

125+
123126
### gulp.dest(path[, options])
124127

125128
Can be piped to and it will write files. Re-emits all data passed to it so you
@@ -290,6 +293,7 @@ is not provided.
290293
##### fn.description
291294

292295
gulp-cli prints this description alongside the task name when listing tasks:
296+
293297
```js
294298
var gulp = require('gulp');
295299

@@ -300,7 +304,8 @@ test.description = 'I do nothing';
300304

301305
gulp.task(test);
302306
```
303-
```shell
307+
308+
```sh
304309
$> gulp --tasks
305310
[12:00:02] Tasks for ~/Documents/some-project/gulpfile.js
306311
[12:00:02] └── test I do nothing
@@ -389,6 +394,7 @@ gulp.task('sometask', function() {
389394
});
390395
```
391396

397+
392398
### gulp.lastRun(taskName, [timeResolution])
393399

394400
Returns the timestamp of the last time the task ran successfully. The time
@@ -409,19 +415,22 @@ Default: `1000` on node v0.10, `0` on node v0.12 (and iojs v1.5).
409415

410416
Set the time resolution of the returned timestamps. Assuming
411417
the task named "someTask" ran at `1426000004321`:
418+
412419
- `gulp.lastRun('someTask', 1000)` would return `1426000004000`.
413420
- `gulp.lastRun('someTask', 100)` would return `1426000004300`.
414421

415422
`timeResolution` allows you to compare a run time to a file [mtime stat][fs stats]
416423
attribute. This attribute time resolution may vary depending of the node version
417424
and the file system used:
425+
418426
- on node v0.10, a file [mtime stat][fs stats] time resolution of any files will be 1s at best;
419427
- on node v0.12 and iojs v1.5, 1ms at best;
420428
- for files on FAT32, the mtime time resolution is 2s;
421429
- on HFS+ and Ext3, 1s;
422430
- on NTFS, 1s on node v0.10, 100ms on node 0.12;
423431
- on Ext4, 1s on node v0.10, 1ms on node 0.12.
424432

433+
425434
### gulp.parallel(...tasks)
426435

427436
Takes a number of task names or functions and returns a function of the composed
@@ -515,20 +524,21 @@ Type: `Object`
515524
Options that are passed to [`chokidar`][chokidar].
516525

517526
Commonly used options:
518-
* `ignored` ([anymatch](https://github.com/es128/anymatch)-compatible definition)
527+
528+
* `ignored` ([anymatch](https://github.com/es128/anymatch)-compatible definition).
519529
Defines files/paths to be excluded from being watched.
520530
* `usePolling` (boolean, default: `false`). When `true` uses a watch method backed
521531
by stat polling. Usually necessary when watching files on a network mount or on a
522532
VMs file system.
523533
* `cwd` (path string). The base directory from which watch paths are to be
524534
derived. Paths emitted with events will be relative to this.
525535
* `alwaysStat` (boolean, default: `false`). If relying upon the
526-
[`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) object
536+
[`fs.Stats`][fs stats] object
527537
that may get passed as a second argument with `add`, `addDir`, and `change` events
528538
when available, set this to `true` to ensure it is provided with every event. May
529539
have a slight performance penalty.
530540

531-
Read about the full set of options in [`chokidar`'s README][chokidar]
541+
Read about the full set of options in [`chokidar`'s README][chokidar].
532542

533543
#### fn
534544
Type: `Function`
@@ -552,15 +562,15 @@ watcher.on('unlink', function(path) {
552562
```
553563

554564
##### path
555-
Type: String
565+
Type: `String`
556566

557567
The relative path of the document.
558568

559569
##### stats
560-
Type: Object
570+
Type: `Object`
561571

562-
[File stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) object when available.
563-
Setting the `alwaysStat` option to true will ensure that a file stat object will be
572+
[File stats][fs stats] object when available.
573+
Setting the `alwaysStat` option to `true` will ensure that a file stat object will be
564574
provided.
565575

566576
#### watcher methods
@@ -578,12 +588,13 @@ Watch additional glob (or array of globs) with an already-running watcher instan
578588
Stop watching a glob (or array of globs) while leaving the watcher running and
579589
emitting events for the remaining paths it is watching.
580590

591+
581592
### gulp.tree(options)
582593

583594
Returns the tree of tasks. Inherited from [undertaker]. See the [undertaker docs for this function](https://github.com/phated/undertaker#treeoptions--object).
584595

585596
#### options
586-
Type: Object
597+
Type: `Object`
587598

588599
Options to pass to [undertaker].
589600

@@ -592,7 +603,7 @@ Type: `Boolean`
592603

593604
Default: `false`
594605

595-
If set to true whole tree should be returned.
606+
If set to `true` whole tree should be returned.
596607

597608
#### Example gulpfile
598609

@@ -725,12 +736,13 @@ gulp.tree({ deep: true })
725736
*/
726737
```
727738

739+
728740
### gulp.registry([registry])
729741

730742
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:
731743

732744
- [Sharing tasks](https://github.com/phated/undertaker#sharing-tasks)
733-
- [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.)
745+
- [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.)
734746
- Handling other behavior that hooks into the registry lifecycle (see [gulp-hub](https://github.com/frankwallis/gulp-hub) for an example)
735747

736748
To build your own custom registry see the [undertaker documentation on custom registries](https://github.com/phated/undertaker#custom-registries).

0 commit comments

Comments
 (0)