Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit cbc7496

Browse files
chore(doc-gen): update to dgeni 0.3.0
1 parent 69d96e8 commit cbc7496

12 files changed

+155
-112
lines changed

docs/config/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ module.exports = function(config) {
2525
require('./tag-defs/tutorial-step')
2626
]);
2727

28+
config.append('processing.defaultTagTransforms', [
29+
require('dgeni-packages/jsdoc/tag-defs/transforms/trim-whitespace')
30+
]);
31+
2832
config.append('processing.inlineTagDefinitions', [
2933
require('./inline-tag-defs/type')
3034
]);

docs/config/processors/debug-dump.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
var writer = require('dgeni/lib/utils/doc-writer');
1+
var fs = require('q-io/fs');
22
var log = require('winston');
33
var util = require("util");
44

5-
var filter, outputPath, depth;
6-
75
module.exports = {
86
name: 'debug-dump',
97
runBefore: ['write-files'],
108
description: 'This processor dumps docs that match a filter to a file',
11-
init: function(config, injectables) {
9+
process: function(docs, config) {
10+
11+
var filter, outputPath, depth;
12+
1213
filter = config.get('processing.debug-dump.filter');
1314
outputPath = config.get('processing.debug-dump.outputPath');
1415
depth = config.get('processing.debug-dump.depth', 2);
15-
},
16-
process: function(docs) {
16+
17+
1718
if ( filter && outputPath ) {
1819
log.info('Dumping docs:', filter, outputPath);
1920
var filteredDocs = filter(docs);
2021
var dumpedDocs = util.inspect(filteredDocs, depth);
21-
return writer.writeFile(outputPath, dumpedDocs).then(function() {
22+
return writeFile(outputPath, dumpedDocs).then(function() {
2223
return docs;
2324
});
2425
}
2526
}
26-
};
27+
};
28+
29+
function writeFile(file, content) {
30+
return fs.makeTree(fs.directory(file)).then(function() {
31+
return fs.write(file, content, 'wb');
32+
});
33+
}

docs/config/processors/error-docs.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ var path = require('canonical-path');
55
module.exports = {
66
name: 'error-docs',
77
description: 'Compute the various fields for docs in the Error area',
8-
runAfter: ['tags-extracted'],
9-
init: function(config, injectables) {
10-
injectables.value('errorNamespaces', {});
11-
12-
var minerrInfoPath = config.get('processing.errors.minerrInfoPath');
13-
if ( !minerrInfoPath ) {
14-
throw new Error('Error in configuration: Please provide a path to the minerr info file (errors.json) ' +
15-
'in the `config.processing.errors.minerrInfoPath` property');
16-
}
17-
injectables.value('minerrInfo', require(minerrInfoPath));
8+
runAfter: ['tags-extracted', 'compute-path'],
9+
runBefore: ['extra-docs-added'],
10+
exports: {
11+
errorNamespaces: ['factory', function() { return {}; }],
12+
minerrInfo: ['factory', function(config) {
13+
var minerrInfoPath = config.get('processing.errors.minerrInfoPath');
14+
if ( !minerrInfoPath ) {
15+
throw new Error('Error in configuration: Please provide a path to the minerr info file (errors.json) ' +
16+
'in the `config.processing.errors.minerrInfoPath` property');
17+
}
18+
return require(minerrInfoPath);
19+
}]
1820
},
1921
process: function(docs, partialNames, errorNamespaces, minerrInfo) {
2022

docs/config/processors/git-data.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ var versionInfo = require('../../../lib/versions/version-info');
33

44
module.exports = {
55
name: 'git-data',
6-
runBefore: ['loading-files'],
6+
runBefore: ['reading-files'],
77
description: 'This processor adds information from the local git repository to the extraData injectable',
8-
init: function(config, injectables) {
9-
injectables.value('gitData', {
10-
version: versionInfo.currentVersion,
11-
versions: versionInfo.previousVersions,
12-
info: versionInfo.gitRepoInfo
13-
});
8+
exports: {
9+
gitData: ['factory', function() {
10+
return {
11+
version: versionInfo.currentVersion,
12+
versions: versionInfo.previousVersions,
13+
info: versionInfo.gitRepoInfo
14+
};
15+
}]
1416
},
1517
process: function(extraData, gitData) {
1618
extraData.git = gitData;

docs/config/processors/index-page.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
var _ = require('lodash');
22
var log = require('winston');
33
var path = require('canonical-path');
4-
var deployment;
54

65
module.exports = {
76
name: 'index-page',
87
runAfter: ['adding-extra-docs'],
98
runBefore: ['extra-docs-added'],
109
description: 'This processor creates docs that will be rendered as the index page for the app',
11-
init: function(config) {
12-
deployment = config.deployment;
10+
process: function(docs, config) {
11+
12+
var deployment = config.deployment;
1313
if ( !deployment || !deployment.environments ) {
1414
throw new Error('No deployment environments found in the config.');
1515
}
16-
},
17-
process: function(docs) {
1816

1917
// Collect up all the areas in the docs
2018
var areas = {};

docs/config/processors/keywords.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ var log = require('winston');
33
var fs = require('fs');
44
var path = require('canonical-path');
55

6-
// Keywords to ignore
7-
var wordsToIgnore = [];
8-
var propertiesToIgnore;
9-
var areasToSearch;
10-
11-
// Keywords start with "ng:" or one of $, _ or a letter
12-
var KEYWORD_REGEX = /^((ng:|[\$_a-z])[\w\-_]+)/;
13-
146
module.exports = {
157
name: 'keywords',
168
runAfter: ['docs-processed'],
179
runBefore: ['adding-extra-docs'],
1810
description: 'This processor extracts all the keywords from the document',
19-
init: function(config) {
11+
process: function(docs, config) {
12+
13+
// Keywords to ignore
14+
var wordsToIgnore = [];
15+
var propertiesToIgnore;
16+
var areasToSearch;
17+
18+
// Keywords start with "ng:" or one of $, _ or a letter
19+
var KEYWORD_REGEX = /^((ng:|[\$_a-z])[\w\-_]+)/;
2020

2121
// Load up the keywords to ignore, if specified in the config
2222
if ( config.processing.search && config.processing.search.ignoreWordsFile ) {
@@ -34,9 +34,6 @@ module.exports = {
3434
propertiesToIgnore = _.indexBy(config.get('processing.search.propertiesToIgnore', []));
3535
log.debug('Properties to ignore', propertiesToIgnore);
3636

37-
},
38-
process: function(docs) {
39-
4037
var ignoreWordsMap = _.indexBy(wordsToIgnore);
4138

4239
// If the title contains a name starting with ng, e.g. "ngController", then add the module name

docs/config/processors/pages-data.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,15 @@ var navGroupMappers = {
129129
}
130130
};
131131

132-
var outputFolder;
133-
134132
module.exports = {
135133
name: 'pages-data',
136134
description: 'This plugin will create a new doc that will be rendered as an angularjs module ' +
137135
'which will contain meta information about the pages and navigation',
138-
runAfter: ['adding-extra-docs', 'component-groups-generate'],
136+
runAfter: ['adding-extra-docs', 'component-groups-generate', 'compute-path'],
139137
runBefore: ['extra-docs-added'],
140-
init: function(config) {
141-
outputFolder = config.rendering.outputFolder;
142-
},
143-
process: function(docs) {
138+
process: function(docs, config) {
139+
140+
var outputFolder = config.rendering.outputFolder;
144141

145142
_(docs)
146143
.filter(function(doc) { return doc.area === 'api'; })
@@ -191,7 +188,7 @@ module.exports = {
191188
area.navGroups = navGroupMapper(pages, area);
192189
});
193190

194-
// Extract a list of basic page information for mapping paths to paritals and for client side searching
191+
// Extract a list of basic page information for mapping paths to partials and for client side searching
195192
var pages = _(docs)
196193
.map(function(doc) {
197194
var page = _.pick(doc, [
+26-29
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,20 @@
11
var _ = require('lodash');
2-
var log = require('winston');
32
var path = require('canonical-path');
4-
var trimIndentation = require('dgeni/lib/utils/trim-indentation');
5-
var code = require('dgeni/lib/utils/code');
6-
var protractorFolder;
7-
8-
function createProtractorDoc(example, file, env) {
9-
var protractorDoc = {
10-
docType: 'e2e-test',
11-
id: 'protractorTest' + '-' + example.id,
12-
template: 'protractorTests.template.js',
13-
outputPath: path.join(protractorFolder, example.id, env + '_test.js'),
14-
innerTest: file.fileContents,
15-
pathPrefix: '.', // Hold for if we test with full jQuery
16-
exampleId: example.id,
17-
description: example.doc.id
18-
};
19-
20-
if (env === 'jquery') {
21-
protractorDoc.examplePath = example.outputFolder + '/index-jquery.html'
22-
} else {
23-
protractorDoc.examplePath = example.outputFolder + '/index.html'
24-
}
25-
return protractorDoc;
26-
}
273

284
module.exports = {
295
name: 'protractor-generate',
306
description: 'Generate a protractor test file from the e2e tests in the examples',
317
runAfter: ['adding-extra-docs'],
328
runBefore: ['extra-docs-added'],
33-
init: function(config, injectables) {
34-
protractorFolder = config.get('rendering.protractor.outputFolder', 'ptore2e');
35-
},
36-
process: function(docs, examples) {
9+
process: function(docs, examples, config) {
10+
var protractorFolder = config.get('rendering.protractor.outputFolder', 'ptore2e');
11+
3712
_.forEach(examples, function(example) {
3813

3914
_.forEach(example.files, function(file) {
4015

4116
// Check if it's a Protractor test.
42-
if (!(file.type == 'protractor')) {
17+
if (file.type !== 'protractor') {
4318
return;
4419
}
4520

@@ -48,5 +23,27 @@ module.exports = {
4823
docs.push(createProtractorDoc(example, file, 'jqlite'));
4924
});
5025
});
26+
27+
function createProtractorDoc(example, file, env) {
28+
var protractorDoc = {
29+
docType: 'e2e-test',
30+
id: 'protractorTest' + '-' + example.id,
31+
template: 'protractorTests.template.js',
32+
outputPath: path.join(protractorFolder, example.id, env + '_test.js'),
33+
innerTest: file.fileContents,
34+
pathPrefix: '.', // Hold for if we test with full jQuery
35+
exampleId: example.id,
36+
description: example.doc.id
37+
};
38+
39+
if (env === 'jquery') {
40+
protractorDoc.examplePath = example.outputFolder + '/index-jquery.html';
41+
} else {
42+
protractorDoc.examplePath = example.outputFolder + '/index.html';
43+
}
44+
return protractorDoc;
45+
}
46+
47+
5148
}
5249
};

docs/config/tag-defs/tutorial-step.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module.exports = {
22
name: 'step',
3-
transformFn: function(doc, tag) {
3+
transforms: function(doc, tag, value) {
44
if ( doc.docType !== 'tutorial' ) {
55
throw new Error('Invalid tag, step. You should only use this tag on tutorial docs');
66
}
7-
return parseInt(tag.description,10);
7+
return parseInt(value,10);
88
}
99
};

docs/gulpfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var gulp = require('gulp');
22
var concat = require('gulp-concat');
33
var jshint = require('gulp-jshint');
44
var bower = require('bower');
5-
var docGenerator = require('dgeni');
5+
var dgeni = require('dgeni');
66
var merge = require('event-stream').merge;
77
var path = require('canonical-path');
88

@@ -49,8 +49,8 @@ gulp.task('assets', ['bower'], function() {
4949

5050

5151
gulp.task('doc-gen', function() {
52-
return docGenerator('docs.config.js')
53-
.generateDocs()
52+
var generateDocs = dgeni.generator('docs.config.js');
53+
return generateDocs()
5454
.catch(function(error) {
5555
process.exit(1);
5656
});

0 commit comments

Comments
 (0)