refact(api-builder): move into `tools` folder
This commit is contained in:
parent
ce298009e6
commit
83fbe75980
|
@ -2,6 +2,10 @@ var path = require('canonical-path');
|
|||
var Package = require('dgeni').Package;
|
||||
var basePackage = require('../docs-package');
|
||||
|
||||
var PROJECT_PATH = path.resolve(__dirname, "../../..");
|
||||
var PUBLIC_PATH = path.resolve(PROJECT_PATH, 'public');
|
||||
var DOCS_PATH = path.resolve(PUBLIC_PATH, 'docs');
|
||||
|
||||
module.exports = new Package('angular.io', [basePackage])
|
||||
|
||||
.factory(require('./services/renderMarkdown'))
|
||||
|
@ -35,7 +39,7 @@ module.exports = new Package('angular.io', [basePackage])
|
|||
];
|
||||
readTypeScriptModules.hidePrivateMembers = true;
|
||||
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, "../../docs");
|
||||
readFilesProcessor.basePath = DOCS_PATH;
|
||||
writeFilesProcessor.outputFolder = 'js/latest/api';
|
||||
})
|
||||
|
||||
|
@ -76,7 +80,7 @@ module.exports = new Package('angular.io', [basePackage])
|
|||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['app-data'],
|
||||
pathTemplate: '../../../../resources/js/app-data',
|
||||
pathTemplate: path.resolve(PUBLIC_PATH, 'resources/js/app-data'),
|
||||
outputPathTemplate: '${path}.json'
|
||||
});
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
var Package = require('dgeni').Package;
|
||||
|
||||
module.exports = new Package('target', [])
|
||||
|
||||
.factory(require('./inline-tag-defs/target'))
|
||||
|
||||
.config(function(inlineTagProcessor, targetInlineTagDef) {
|
||||
inlineTagProcessor.inlineTagDefinitions.push(targetInlineTagDef);
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
var _ = require('lodash');
|
||||
|
||||
/**
|
||||
* @dgService
|
||||
* @description
|
||||
* Process inline `target` block tags
|
||||
* (of the form `{@target environment1 environment2}...{@endtarget}`),
|
||||
* filtering out the blocks that do not match the containing document's
|
||||
* `targetEnvironments`.
|
||||
*/
|
||||
module.exports = function targetInlineTagDef() {
|
||||
return {
|
||||
name: 'target',
|
||||
end: 'endtarget',
|
||||
handler: function(doc, tagName, tagDescription) {
|
||||
var targets = tagDescription && tagDescription.tag.split(' ');
|
||||
if (!targets || !doc.targetEnvironments ||
|
||||
_.intersection(targets, doc.targetEnvironments).length) {
|
||||
return tagDescription.content;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
var targetFactory = require('./target');
|
||||
|
||||
describe('target inline-tag-def', function() {
|
||||
it('should filter out content that does not match the doc.targetEnvironments', function() {
|
||||
var doc, target, result;
|
||||
|
||||
doc = {
|
||||
targetEnvironments: ['js', 'es6']
|
||||
};
|
||||
|
||||
target = targetFactory();
|
||||
result = target.handler(doc, 'target', {
|
||||
tag: 'es6 ts',
|
||||
content: 'abc'
|
||||
});
|
||||
expect(result).toEqual('abc');
|
||||
|
||||
result = target.handler(doc, 'target', {
|
||||
tag: 'ts',
|
||||
content: 'xyz'
|
||||
});
|
||||
expect(result).toEqual('');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue