Skip to content

Commit 0b35521

Browse files
chore(doc-gen): move git info into its own processor
1 parent 4a93821 commit 0b35521

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

docs/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = function(config) {
99
config = angularjsPackage(config);
1010

1111
config.append('processing.processors', [
12+
require('./processors/git-data'),
1213
require('./processors/keywords'),
1314
require('./processors/versions-data'),
1415
require('./processors/pages-data'),

docs/config/processors/git-data.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var gruntUtils = require('../../../lib/grunt/utils');
2+
3+
module.exports = {
4+
name: 'git-data',
5+
runBefore: ['loading-files'],
6+
description: 'This processor adds information from the local git repository to the extraData injectable',
7+
init: function(config, injectables) {
8+
injectables.value('gitData', {
9+
version: gruntUtils.getVersion(),
10+
versions: gruntUtils.getPreviousVersions(),
11+
info: gruntUtils.getGitRepoInfo()
12+
});
13+
},
14+
process: function(extraData, gitData) {
15+
extraData.git = gitData;
16+
}
17+
};

docs/config/processors/versions-data.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
var _ = require('lodash');
22

3-
var version;
4-
var versions;
5-
63
module.exports = {
74
name: 'versions-data',
85
description: 'This plugin will create a new doc that will be rendered as an angularjs module ' +
96
'which will contain meta information about the versions of angular',
107
runAfter: ['adding-extra-docs', 'pages-data'],
118
runBefore: ['extra-docs-added'],
12-
init: function(config) {
13-
version = config.source.currentVersion;
14-
versions = config.source.previousVersions;
9+
process: function(docs, gitData) {
10+
11+
var version = gitData.version;
12+
var versions = gitData.versions;
1513

1614
if ( !version ) {
1715
throw new Error('Invalid configuration. Please provide a valid `source.currentVersion` property');
1816
}
1917
if ( !versions ) {
2018
throw new Error('Invalid configuration. Please provide a valid `source.previousVersions` property');
2119
}
22-
},
23-
process: function(docs) {
2420

2521
var versionDoc = {
2622
docType: 'versions-data',

docs/docs.config.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var path = require('canonical-path');
2-
var gruntUtils = require('../lib/grunt/utils');
32
var basePath = __dirname;
43

54
var basePackage = require('./config');
@@ -13,21 +12,11 @@ module.exports = function(config) {
1312
{ pattern: '**/*.ngdoc', basePath: path.resolve(basePath, 'content') }
1413
]);
1514

16-
var version = gruntUtils.getVersion();
17-
var versions = gruntUtils.getPreviousVersions();
18-
config.set('source.currentVersion', version);
19-
config.set('source.previousVersions', versions);
20-
2115
config.set('processing.examples.commonFiles', {
2216
scripts: [ '../../../angular.js' ],
2317
stylesheets: []
2418
});
2519

26-
config.merge('rendering.extra', {
27-
git: gruntUtils.getGitRepoInfo(),
28-
version: version
29-
});
30-
3120
config.set('rendering.outputFolder', '../build/docs');
3221

3322
config.set('logging.level', 'debug');

0 commit comments

Comments
 (0)