chore(doc-gen): move git info into its own processor

This commit is contained in:
Peter Bacon Darwin
2014-02-13 21:50:13 +00:00
parent 4a938213df
commit 0b35521d8f
4 changed files with 22 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ module.exports = function(config) {
config = angularjsPackage(config);
config.append('processing.processors', [
require('./processors/git-data'),
require('./processors/keywords'),
require('./processors/versions-data'),
require('./processors/pages-data'),

View File

@@ -0,0 +1,17 @@
var gruntUtils = require('../../../lib/grunt/utils');
module.exports = {
name: 'git-data',
runBefore: ['loading-files'],
description: 'This processor adds information from the local git repository to the extraData injectable',
init: function(config, injectables) {
injectables.value('gitData', {
version: gruntUtils.getVersion(),
versions: gruntUtils.getPreviousVersions(),
info: gruntUtils.getGitRepoInfo()
});
},
process: function(extraData, gitData) {
extraData.git = gitData;
}
};

View File

@@ -1,17 +1,15 @@
var _ = require('lodash');
var version;
var versions;
module.exports = {
name: 'versions-data',
description: 'This plugin will create a new doc that will be rendered as an angularjs module ' +
'which will contain meta information about the versions of angular',
runAfter: ['adding-extra-docs', 'pages-data'],
runBefore: ['extra-docs-added'],
init: function(config) {
version = config.source.currentVersion;
versions = config.source.previousVersions;
process: function(docs, gitData) {
var version = gitData.version;
var versions = gitData.versions;
if ( !version ) {
throw new Error('Invalid configuration. Please provide a valid `source.currentVersion` property');
@@ -19,8 +17,6 @@ module.exports = {
if ( !versions ) {
throw new Error('Invalid configuration. Please provide a valid `source.previousVersions` property');
}
},
process: function(docs) {
var versionDoc = {
docType: 'versions-data',

View File

@@ -1,5 +1,4 @@
var path = require('canonical-path');
var gruntUtils = require('../lib/grunt/utils');
var basePath = __dirname;
var basePackage = require('./config');
@@ -13,21 +12,11 @@ module.exports = function(config) {
{ pattern: '**/*.ngdoc', basePath: path.resolve(basePath, 'content') }
]);
var version = gruntUtils.getVersion();
var versions = gruntUtils.getPreviousVersions();
config.set('source.currentVersion', version);
config.set('source.previousVersions', versions);
config.set('processing.examples.commonFiles', {
scripts: [ '../../../angular.js' ],
stylesheets: []
});
config.merge('rendering.extra', {
git: gruntUtils.getGitRepoInfo(),
version: version
});
config.set('rendering.outputFolder', '../build/docs');
config.set('logging.level', 'debug');