Skip to content

Commit 3cd0d3a

Browse files
committed
docs(fix code examples): Previously the code examples omitted the necessary require statement.
relates to #20
1 parent 2cafc52 commit 3cd0d3a

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

README.md

+14-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Documentation stream intended for use within the gulp system.
2222

2323
**Parameters**
2424

25-
- `format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** format - one of 'html', 'md', or 'json' (optional, default `md`)
25+
- `format` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** format - one of 'html', 'md', or 'json' (optional, default `md`)
2626
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** documentation options - the same as given to [documentation](https://github.com/documentationjs/documentation)
2727
- `options.filename` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** custom filename for md or json output
2828
- `formatterOptions` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** output options - same as given to documentation
@@ -34,60 +34,56 @@ Documentation stream intended for use within the gulp system.
3434
var gulpDocumentation = require('gulp-documentation'),
3535
var gulp = require('gulp');
3636
// Out of the box, you can generate JSON, HTML, and Markdown documentation
37-
gulp.task('documentation', function () {
38-
37+
gulp.task('documentation-readme-example', function () {
3938
// Generating README documentation
40-
gulp.src('./index.js')
39+
return gulp.src('./index.js')
4140
.pipe(gulpDocumentation('md'))
4241
.pipe(gulp.dest('md-documentation'));
42+
});
4343

44-
// Generating a pretty HTML documentation site
45-
gulp.src('./index.js')
44+
// Generating a pretty HTML documentation site
45+
gulp.task('documentation-html-example', function () {
46+
return gulp.src('./index.js')
4647
.pipe(gulpDocumentation('html'))
4748
.pipe(gulp.dest('html-documentation'));
49+
});
4850

49-
// Generating raw JSON documentation output
50-
gulp.src('./index.js')
51+
// Generating raw JSON documentation output
52+
gulp.task('documentation-json-example', function () {
53+
return gulp.src('./index.js')
5154
.pipe(gulpDocumentation('json'))
5255
.pipe(gulp.dest('json-documentation'));
53-
5456
});
5557

5658
// Generate documentation for multiple files using normal glob syntax.
5759
// Note that this generates one documentation output, so that it can
5860
// easily cross-reference and use types.
5961
gulp.task('documentation-multiple-files', function () {
60-
61-
gulp.src('./src/*.js')
62+
return gulp.src('./src/*.js')
6263
.pipe(gulpDocumentation('md'))
6364
.pipe(gulp.dest('md-documentation'));
64-
6565
});
6666

6767

6868
// If you're using HTML documentation, you can specify additional 'name'
6969
// and 'version' options
7070
gulp.task('documentation-html-options', function () {
71-
72-
gulp.src('./src/*.js')
71+
return gulp.src('./src/*.js')
7372
.pipe(gulpDocumentation('html', {}, {
7473
name: 'My Project',
7574
version: '1.0.0'
7675
}))
7776
.pipe(gulp.dest('html-documentation'));
78-
7977
});
8078

8179
// Document non-JavaScript files with JSDoc comments using polyglot: true
8280
gulp.task('documentation-for-cplusplus', function () {
83-
84-
gulp.src('./src/*.cpp')
81+
return gulp.src('./src/*.cpp')
8582
.pipe(gulpDocumentation('html', { polyglot: true }, {
8683
name: 'My Project',
8784
version: '1.0.0'
8885
}))
8986
.pipe(gulp.dest('html-documentation'));
90-
9187
});
9288
```
9389

index.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,56 @@ var File = require('vinyl');
1616
* var gulpDocumentation = require('gulp-documentation'),
1717
* var gulp = require('gulp');
1818
* // Out of the box, you can generate JSON, HTML, and Markdown documentation
19-
* gulp.task('documentation', function () {
20-
*
19+
* gulp.task('documentation-readme-example', function () {
2120
* // Generating README documentation
22-
* gulp.src('./index.js')
21+
* return gulp.src('./index.js')
2322
* .pipe(gulpDocumentation('md'))
2423
* .pipe(gulp.dest('md-documentation'));
24+
* });
2525
*
26-
* // Generating a pretty HTML documentation site
27-
* gulp.src('./index.js')
26+
* // Generating a pretty HTML documentation site
27+
* gulp.task('documentation-html-example', function () {
28+
* return gulp.src('./index.js')
2829
* .pipe(gulpDocumentation('html'))
2930
* .pipe(gulp.dest('html-documentation'));
31+
* });
3032
*
31-
* // Generating raw JSON documentation output
32-
* gulp.src('./index.js')
33+
* // Generating raw JSON documentation output
34+
* gulp.task('documentation-json-example', function () {
35+
* return gulp.src('./index.js')
3336
* .pipe(gulpDocumentation('json'))
3437
* .pipe(gulp.dest('json-documentation'));
35-
*
3638
* });
3739
*
3840
* // Generate documentation for multiple files using normal glob syntax.
3941
* // Note that this generates one documentation output, so that it can
4042
* // easily cross-reference and use types.
4143
* gulp.task('documentation-multiple-files', function () {
42-
*
43-
* gulp.src('./src/*.js')
44+
* return gulp.src('./src/*.js')
4445
* .pipe(gulpDocumentation('md'))
4546
* .pipe(gulp.dest('md-documentation'));
46-
*
4747
* });
4848
*
4949
*
5050
* // If you're using HTML documentation, you can specify additional 'name'
5151
* // and 'version' options
5252
* gulp.task('documentation-html-options', function () {
53-
*
54-
* gulp.src('./src/*.js')
53+
* return gulp.src('./src/*.js')
5554
* .pipe(gulpDocumentation('html', {}, {
5655
* name: 'My Project',
5756
* version: '1.0.0'
5857
* }))
5958
* .pipe(gulp.dest('html-documentation'));
60-
*
6159
* });
6260
*
6361
* // Document non-JavaScript files with JSDoc comments using polyglot: true
6462
* gulp.task('documentation-for-cplusplus', function () {
65-
*
66-
* gulp.src('./src/*.cpp')
63+
* return gulp.src('./src/*.cpp')
6764
* .pipe(gulpDocumentation('html', { polyglot: true }, {
6865
* name: 'My Project',
6966
* version: '1.0.0'
7067
* }))
7168
* .pipe(gulp.dest('html-documentation'));
72-
*
7369
* });
7470
*/
7571
module.exports = function (format, options, formatterOptions) {

0 commit comments

Comments
 (0)