mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 03:30:02 +08:00
chore(doc-gen): move git info into its own processor
This commit is contained in:
@@ -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'),
|
||||
|
||||
17
docs/config/processors/git-data.js
Normal file
17
docs/config/processors/git-data.js
Normal 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;
|
||||
}
|
||||
};
|
||||
@@ -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',
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user