mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 17:14:42 +00:00
ee743f869d
* Add lib/ve. * Remove modules provided by VisualEditor core. * Update paths. * Remove VisualEditor core specific things from Gruntfile. * Remove entries from external.js already in lib/ve/.docs/external.js. * Implement build script to compose a jsduck index that includes all of VisualEditor core. Right now it includes VisualEditor's index as-is, and because those patterns (e.g. ve.dm.*Node) will also MW subclasses this means our category page will include MW classes under "VisualEditor (core)" (before the repo split, this was intentional). This is inevitable unless we list every class individually, or (the plan) until we move the MW subclasses out of the ve.* namespace and into mw.* somewhere. Bug: 45342 Change-Id: Iff45cd555430634c9fc341fd3b177c1e0625300b
74 lines
1.8 KiB
JavaScript
74 lines
1.8 KiB
JavaScript
/*!
|
|
* Merge jsduck configuration files with a downstream one
|
|
*/
|
|
|
|
/*jshint node:true */
|
|
module.exports = function ( grunt ) {
|
|
var _ = grunt.util._;
|
|
|
|
grunt.registerMultiTask( 'jsduckcatconfig', function () {
|
|
var targetFile = this.data.target,
|
|
from = this.data.from,
|
|
output = [];
|
|
|
|
from.forEach( function ( src ) {
|
|
var srcCategories;
|
|
|
|
if ( typeof src === 'string' ) {
|
|
src = {
|
|
file: src
|
|
};
|
|
}
|
|
|
|
srcCategories = grunt.file.readJSON( src.file );
|
|
|
|
if ( !src.include && !src.aggregate ) {
|
|
// Default to a straight inclusion
|
|
output.push.apply( output, srcCategories );
|
|
return;
|
|
}
|
|
|
|
if ( src.aggregate ) {
|
|
_.forIn( src.aggregate, function ( targetCat, targetCatName ) {
|
|
var targetGroups = [];
|
|
// For each of the target category groups...
|
|
targetCat.forEach( function ( targetGroupName ) {
|
|
// ... find the category in the aggregate source
|
|
srcCategories.forEach( function ( aggrCat ) {
|
|
if ( aggrCat.name === targetGroupName ) {
|
|
var targetGroup = {
|
|
name: targetGroupName,
|
|
classes: []
|
|
};
|
|
aggrCat.groups.forEach( function ( group ) {
|
|
targetGroup.classes = targetGroup.classes.concat( group.classes );
|
|
} );
|
|
targetGroups.push( targetGroup );
|
|
}
|
|
} );
|
|
} );
|
|
output.push( {
|
|
name: targetCatName,
|
|
groups: targetGroups
|
|
} );
|
|
} );
|
|
|
|
}
|
|
|
|
if ( src.include ) {
|
|
src.include.forEach( function ( targetCatName ) {
|
|
srcCategories.forEach( function ( aggrCat ) {
|
|
if ( aggrCat.name === targetCatName ) {
|
|
output.push( aggrCat );
|
|
}
|
|
} );
|
|
} );
|
|
}
|
|
|
|
} );
|
|
|
|
grunt.file.write( targetFile, JSON.stringify( output, null, '\t' ) + '\n' );
|
|
grunt.log.ok( 'File "' + targetFile + '" written.' );
|
|
} );
|
|
};
|