Skip to content

Commit 54197db

Browse files
committed
docs - more cleanup
1 parent 112a3e0 commit 54197db

10 files changed

+86
-80
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="http://gulpjs.com">
3-
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png"/>
3+
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
44
</a>
55
</p>
66

@@ -19,9 +19,8 @@ For a Getting started guide, API docs, recipes, making a plugin, etc. see the [d
1919

2020
This file is just a quick sample to give you a taste of what gulp does.
2121

22-
```javascript
22+
```js
2323
var gulp = require('gulp');
24-
2524
var coffee = require('gulp-coffee');
2625
var concat = require('gulp-concat');
2726
var uglify = require('gulp-uglify');
@@ -69,7 +68,6 @@ gulp.task('watch', function() {
6968

7069
// The default task (called when you run `gulp` from cli)
7170
gulp.task('default', ['watch', 'scripts', 'images']);
72-
7371
```
7472

7573
## Incremental Builds

docs/API.md

+23-27
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
### gulp.src(globs[, options])
44

5-
Takes a glob and represents a file structure. Can be piped to plugins.
5+
Takes a glob and represents a file structure. Can be piped to plugins.
66

7-
```javascript
8-
gulp.src('./client/templates/*.jade')
9-
.pipe(jade())
10-
.pipe(minify())
11-
.pipe(gulp.dest('./build/minified_templates'));
7+
```js
8+
gulp.src('client/templates/*.jade')
9+
.pipe(jade())
10+
.pipe(minify())
11+
.pipe(gulp.dest('build/minified_templates'));
1212
```
1313

1414
`glob` refers to [node-glob syntax](https://github.com/isaacs/node-glob) or it can be a direct file path.
@@ -37,7 +37,6 @@ Default: `true`
3737

3838
Setting this to `false` will return `file.contents` as null and not read the file at all.
3939

40-
4140
### gulp.dest(path)
4241

4342
Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders. Folders that don't exist will be created.
@@ -55,12 +54,11 @@ Type: `String`
5554

5655
The path (folder) to write files to.
5756

58-
5957
### gulp.task(name[, deps], fn)
6058

6159
Define a task using [Orchestrator].
6260

63-
```javascript
61+
```js
6462
gulp.task('somename', function() {
6563
// Do stuff
6664
});
@@ -75,14 +73,13 @@ Type: `Array`
7573

7674
An array of tasks to be executed and completed before your task will run.
7775

78-
```javascript
76+
```js
7977
gulp.task('mytask', ['array', 'of', 'task', 'names'], function() {
8078
// Do stuff
8179
});
8280
```
8381

84-
**Note:** Are your tasks running before the dependencies are complete? Make sure your dependency tasks
85-
are correctly using the async run hints: take in a callback or return a promise or event stream.
82+
**Note:** Are your tasks running before the dependencies are complete? Make sure your dependency tasks are correctly using the async run hints: take in a callback or return a promise or event stream.
8683

8784
#### fn
8885

@@ -95,24 +92,24 @@ Tasks can be made asynchronous if its `fn` does one of the following:
9592
##### Accept a callback
9693

9794
```javascript
98-
// Run a command in a shell
95+
// run a command in a shell
9996
var exec = require('child_process').exec;
10097
gulp.task('jekyll', function(cb) {
101-
// Build Jekyl
102-
exec('jekyll build', function(err) {
103-
if (err) return cb(err); //return error
98+
// build Jekyll
99+
exec('jekyll build', function(err) {
100+
if (err) return cb(err); // return error
104101
cb(); // finished task
105102
});
106103
});
107104
```
108105

109106
##### Return a stream
110107

111-
```javascript
108+
```js
112109
gulp.task('somename', function() {
113-
var stream = gulp.src('./client/**/*.js')
110+
var stream = gulp.src('client/**/*.js')
114111
.pipe(minify())
115-
.pipe(gulp.dest('/build'));
112+
.pipe(gulp.dest('build'));
116113
return stream;
117114
});
118115
```
@@ -125,7 +122,7 @@ var Q = require('q');
125122
gulp.task('somename', function() {
126123
var deferred = Q.defer();
127124

128-
// Do async stuff
125+
// do async stuff
129126
setTimeout(function() {
130127
deferred.resolve();
131128
}, 1);
@@ -134,8 +131,7 @@ gulp.task('somename', function() {
134131
});
135132
```
136133

137-
**Note:** By default, tasks run with maximum concurrency -- e.g. it launches all the tasks at once and waits for nothing.
138-
If you want to create a series where tasks run in a particular order, you need to do two things:
134+
**Note:** By default, tasks run with maximum concurrency -- e.g. it launches all the tasks at once and waits for nothing. If you want to create a series where tasks run in a particular order, you need to do two things:
139135

140136
- give it a hint to tell it when the task is done,
141137
- and give it a hint that a task depends on completion of another.
@@ -149,7 +145,7 @@ done or return a promise or stream that the engine should wait to resolve or end
149145

150146
So this example would look like this:
151147

152-
```javascript
148+
```js
153149
var gulp = require('gulp');
154150

155151
// takes in a callback so the engine knows when it'll be done
@@ -188,10 +184,10 @@ Type: `Array`
188184

189185
Names of task(s) to run when a file changes, added with `gulp.task()`
190186

191-
```javascript
187+
```js
192188
var watcher = gulp.watch('js/**/*.js', ['uglify','reload']);
193189
watcher.on('change', function(event) {
194-
console.log('File '+event.path+' was '+event.type+', running tasks...');
190+
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
195191
});
196192
```
197193

@@ -212,9 +208,9 @@ Type: `Function`
212208

213209
Callback to be called on each change.
214210

215-
```javascript
211+
```js
216212
gulp.watch('js/**/*.js', function(event) {
217-
console.log('File '+event.path+' was '+event.type+', running tasks...');
213+
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
218214
});
219215
```
220216

docs/CLI.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ gulp has very few flags to know about. All other flags are for tasks to use if n
1414
- `--no-color` will force gulp and gulp plugins to not display colors even when color support is detected
1515
- `--silent` will disable all gulp logging
1616

17-
The CLI adds process.env.INIT_CWD which is the original cwd it was launched from
17+
The CLI adds process.env.INIT_CWD which is the original cwd it was launched from.
1818

1919
### Tasks
2020

docs/README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
* [CLI documentation](CLI.md) - Learn how to call tasks and use compilers
66
* [Writing a Plugin](writing-a-plugin/README.md) - So you're writing a gulp plugin? Go here for the essential dos and don'ts.
77

8+
89
## FAQ
910

10-
See [the FAQ](FAQ.md) for the answers to commonly asked questions.
11+
See the [FAQ](FAQ.md) for the answers to commonly asked questions.
12+
1113

1214
## Recipes
1315

14-
The community has compiled guides on how to use gulp for common use cases. Check out the [recipes folder](recipes) for a full list.
16+
The community has written [recipes](recipes) common gulp use-cases.
17+
1518

1619
## Still got questions?
1720

1821
Post on [StackOverflow with a #gulp tag](http://stackoverflow.com/questions/tagged/gulp), or come chat with us in [#gulpjs](http://webchat.freenode.net/?channels=gulpjs) on [Freenode](http://freenode.net/).
1922

23+
2024
## Articles
2125
* [Tagtree intro to gulp video](http://tagtree.tv/gulp)
2226
* [Introduction to node.js streams](https://github.com/substack/stream-handbook)
@@ -29,6 +33,7 @@ Post on [StackOverflow with a #gulp tag](http://stackoverflow.com/questions/tagg
2933
* [Gulp - The Basics (screencast)](https://www.youtube.com/watch?v=dwSLFai8ovQ)
3034
* [Get started with gulp (video series)](http://www.youtube.com/playlist?list=PLRk95HPmOM6PN-G1xyKj9q6ap_dc9Yckm)
3135

36+
3237
## License
3338

3439
All the documentation is covered by the CC0 license *(do whatever you want with it - public domain)*.

docs/getting-started.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
## Getting Started
1+
# Getting Started
22

3-
### 1. Install gulp globally:
3+
#### 1. Install gulp globally:
44

5-
```
6-
npm install -g gulp
5+
```sh
6+
$ npm install --global gulp
77
```
88

9-
### 2. Install gulp in your project devDependencies:
9+
#### 2. Install gulp in your project devDependencies:
1010

11-
```
12-
npm install --save-dev gulp
11+
```sh
12+
$ npm install --save-dev gulp
1313
```
1414

15-
### 3. Create a `gulpfile.js` at the root of your project:
15+
#### 3. Create a `gulpfile.js` at the root of your project:
1616

17-
```javascript
17+
```js
1818
var gulp = require('gulp');
1919

2020
gulp.task('default', function() {
2121
// place code for your default task here
2222
});
2323
```
2424

25-
### 4. Run gulp:
25+
#### 4. Run gulp:
2626

27-
```
28-
gulp
27+
```sh
28+
$ gulp
2929
```
3030

3131
The default task will run and do nothing.
@@ -34,7 +34,7 @@ To run individual tasks, use `gulp <task> <othertask>`.
3434

3535
## Where do I go now?
3636

37-
You have an empty gulpfile and everything is installed. How do you REALLY get started? Check out the [recipes and articles section](README.md#articles-and-recipes) for more information.
37+
You have an empty gulpfile and everything is installed. How do you REALLY get started? Check out the [recipes](recipes) and the [list of articles](README.md#articles) for more information.
3838

3939
## .src, .watch, .dest, CLI args - How do I use these things?
4040

docs/writing-a-plugin/dealing-with-streams.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var through = require('through2');
1515
var gutil = require('gulp-util');
1616
var PluginError = gutil.PluginError;
1717

18-
// Consts
18+
// consts
1919
const PLUGIN_NAME = 'gulp-prefixer';
2020

2121
function prefixStream(prefixText) {
@@ -24,19 +24,19 @@ function prefixStream(prefixText) {
2424
return stream;
2525
}
2626

27-
// Plugin level function(dealing with files)
27+
// plugin level function (dealing with files)
2828
function gulpPrefixer(prefixText) {
29-
3029
if (!prefixText) {
31-
throw new PluginError(PLUGIN_NAME, "Missing prefix text!");
30+
throw new PluginError(PLUGIN_NAME, 'Missing prefix text!');
3231
}
32+
3333
prefixText = new Buffer(prefixText); // allocate ahead of time
3434

35-
// Creating a stream through which each file will pass
36-
var stream = through.obj(function(file, enc, callback) {
35+
// creating a stream through which each file will pass
36+
var stream = through.obj(function(file, enc, cb) {
3737
if (file.isBuffer()) {
3838
this.emit('error', new PluginError(PLUGIN_NAME, 'Buffers not supported!'));
39-
return callback();
39+
return cb();
4040
}
4141

4242
if (file.isStream()) {
@@ -51,14 +51,14 @@ function gulpPrefixer(prefixText) {
5151
// make sure the file goes through the next gulp plugin
5252
this.push(file);
5353
// tell the stream engine that we are done with this file
54-
callback();
54+
cb();
5555
});
5656

5757
// returning the file stream
5858
return stream;
5959
};
6060

61-
// Exporting the plugin main function
61+
// exporting the plugin main function
6262
module.exports = gulpPrefixer;
6363
```
6464

@@ -70,10 +70,10 @@ var gulpPrefixer = require('gulp-prefixer');
7070

7171
gulp.src('files/**/*.js', { buffer: false })
7272
.pipe(gulpPrefixer('prepended string'))
73-
.pipe(gulp.dest('/modified-files/'));
73+
.pipe(gulp.dest('modified-files'));
7474
```
7575

7676
## Some plugins using streams
7777

7878
* [gulp-svgicons2svgfont](https://github.com/nfroidure/gulp-svgiconstosvgfont)
79-
* gulp-browserify (Soon)
79+

docs/writing-a-plugin/guidelines.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var through = require('through2');
5656
var gutil = require('gulp-util');
5757
var PluginError = gutil.PluginError;
5858

59-
// Consts
59+
// consts
6060
const PLUGIN_NAME = 'gulp-prefixer';
6161

6262
function prefixStream(prefixText) {
@@ -65,19 +65,20 @@ function prefixStream(prefixText) {
6565
return stream;
6666
}
6767

68-
// Plugin level function(dealing with files)
68+
// plugin level function (dealing with files)
6969
function gulpPrefixer(prefixText) {
70-
7170
if (!prefixText) {
72-
throw new PluginError(PLUGIN_NAME, "Missing prefix text!");
71+
throw new PluginError(PLUGIN_NAME, 'Missing prefix text!');
7372
}
73+
7474
prefixText = new Buffer(prefixText); // allocate ahead of time
7575

76-
// Creating a stream through which each file will pass
77-
var stream = through.obj(function(file, enc, callback) {
76+
// creating a stream through which each file will pass
77+
var stream = through.obj(function(file, enc, cb) {
7878
if (file.isNull()) {
79-
// Do nothing if no contents
79+
// do nothing if no contents
8080
}
81+
8182
if (file.isBuffer()) {
8283
file.contents = Buffer.concat([prefixText, file.contents]);
8384
}
@@ -87,14 +88,14 @@ function gulpPrefixer(prefixText) {
8788
}
8889

8990
this.push(file);
90-
return callback();
9191

92+
return cb();
9293
});
9394

9495
// returning the file stream
9596
return stream;
9697
};
9798

98-
// Exporting the plugin main function
99+
// exporting the plugin main function
99100
module.exports = gulpPrefixer;
100101
```

docs/writing-a-plugin/recommended-modules.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ Use [chalk](https://github.com/sindresorhus/chalk)
2020

2121
Use [dateformat](https://github.com/felixge/node-dateformat)
2222

23-
24-
Display as `HH:MM:ss`
23+
Display as `HH:MM:ss`

0 commit comments

Comments
 (0)