build(aio): big move of docs related files (#14361)

All the docs related files (docs-app, doc-gen, content, etc)
are now to be found inside the `/aio` folder.

The related gulp tasks have been moved from the top level
gulp file to a new one inside the `/aio` folder.

The structure of the `/aio` folder now looks like:

```
/aio/
  build/         # gulp tasks
  content/       #MARKDOWN FILES for devguides, cheatsheet, etc
    devguides/
    cheatsheets/
  transforms/    #dgeni packages, templates, etc
  src/
    app/
    assets/
    content/    #HTML + JSON build artifacts produced by dgeni from /aio/content.
                #This dir is .gitignored-ed
  e2e/           #protractor tests for the doc viewer app
  node_modules/ #dependencies for both the doc viewer builds and the dgeni stuff
                #This dir is .gitignored-ed
  gulpfile.js   #Tasks for generating docs and building & deploying the doc viewer
```

Closes #14361
This commit is contained in:
Pete Bacon Darwin
2017-02-09 19:58:36 +00:00
committed by Igor Minar
parent 5e7a2fa854
commit 600402d440
437 changed files with 855 additions and 531 deletions

View File

@ -0,0 +1,10 @@
var Package = require('dgeni').Package;
module.exports = new Package('target', [require('dgeni-packages/jsdoc')])
.factory(require('./services/targetEnvironments'))
.factory(require('./inline-tag-defs/target'))
.config(function(inlineTagProcessor, targetInlineTagDef) {
inlineTagProcessor.inlineTagDefinitions.push(targetInlineTagDef);
});

View File

@ -0,0 +1,33 @@
/**
* @dgService
* @description
* Process inline `target` block tags
* (of the form `{@target environment1 environment2}...{@endtarget}`),
* filtering out the blocks that do not match the active `targetEnvironments`.
*/
module.exports = function targetInlineTagDef(targetEnvironments, log, createDocMessage) {
return {
name: 'target',
end: 'endtarget',
handler: function(doc, tagName, tagDescription) {
var targets = tagDescription && tagDescription.tag.split(' ');
var hasTargets = targets && targets.length;
try {
// Return the contents of this block if any of the following is true:
// * it has no targets
// * there are no targets stored in the targetEnvironments service
// * the block's targets overlap with the active targets in the targetEnvironments service
if (!hasTargets || !targetEnvironments.hasActive() ||
targetEnvironments.someActive(targets)) {
return tagDescription.content;
}
} catch (x) {
log.error(createDocMessage('Error processing target inline tag def - ' + x.message, doc));
}
// Otherwise return an empty string
return '';
}
};
};

View File

@ -0,0 +1,40 @@
var testPackage = require('../../helpers/test-package');
var Dgeni = require('dgeni');
describe('target inline-tag-def', function() {
var dgeni, injector, targetInlineTagDef;
beforeEach(function() {
dgeni = new Dgeni([testPackage('target-package', true)]);
injector = dgeni.configureInjector();
targetInlineTagDef = injector.get('targetInlineTagDef');
});
it('should filter out content that does not match the targetEnvironments', function() {
var doc = {};
var targetEnvironments = injector.get('targetEnvironments');
targetEnvironments.addAllowed('js', true);
targetEnvironments.addAllowed('es6', true);
targetEnvironments.addAllowed('ts', false);
var result = targetInlineTagDef.handler(doc, 'target', {tag: 'es6 ts', content: 'abc'});
expect(result).toEqual('abc');
result = targetInlineTagDef.handler(doc, 'target', {tag: 'ts', content: 'xyz'});
expect(result).toEqual('');
});
it('should not filter anything if there are no doc nor global target environments', function() {
var doc = {};
var result = targetInlineTagDef.handler(doc, 'target', {tag: 'es6 ts', content: 'abc'});
expect(result).toEqual('abc');
result = targetInlineTagDef.handler(doc, 'target', {tag: 'ts', content: 'xyz'});
expect(result).toEqual('xyz');
});
});

View File

@ -0,0 +1,51 @@
module.exports = function targetEnvironments() {
var _targets = Object.create(null);
var _activeCount = 0;
var checkAllowed = function(target) {
if (!(target in _targets)) {
throw new Error(
'Error accessing target "' + target + '". It is not in the list of allowed targets: ' +
Object.keys(_targets));
}
};
var updateActiveCount = function() {
_activeCount = 0;
for (target in _targets) {
if (_targets[target]) _activeCount++;
}
};
return {
addAllowed: function(target, isActive) {
_targets[target] = !!isActive;
updateActiveCount();
},
removeAllowed: function(target) {
delete _targets[target];
updateActiveCount();
},
activate: function(target) {
checkAllowed(target);
_targets[target] = true;
updateActiveCount();
},
deactivate: function(target) {
checkAllowed(target);
_targets[target] = false;
updateActiveCount();
},
isActive: function(target) {
checkAllowed(target);
return _targets[target];
},
hasActive: function() { return _activeCount > 0; },
someActive: function(targets) {
for (var i = 0, ii = targets.length; i < ii; i++) {
if (this.isActive(targets[i])) return true;
}
return false;
}
};
};

View File

@ -0,0 +1,108 @@
var testPackage = require('../../helpers/test-package');
var Dgeni = require('dgeni');
describe('target inline-tag-def', function() {
var dgeni, injector, te;
beforeEach(function() {
dgeni = new Dgeni([testPackage('target-package', true)]);
injector = dgeni.configureInjector();
te = injector.get('targetEnvironments');
});
describe('addAllowed', function() {
it('should store the target and whether it is active', function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
te.addAllowed('c');
expect(te.isActive('a')).toBe(true);
expect(te.isActive('b')).toBe(false);
expect(te.isActive('c')).toBe(false);
});
});
describe('removeAllowed', function() {
it('should disallow the target', function() {
te.addAllowed('a');
te.addAllowed('b');
te.removeAllowed('b');
expect(te.isActive('a')).toBe(false);
expect(function() {
te.isActive('b');
}).toThrowError('Error accessing target "b". It is not in the list of allowed targets: a');
});
});
describe('activate', function() {
it('should active an already allowed target', function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
te.addAllowed('c');
te.activate('a');
te.activate('b');
te.activate('c');
expect(te.isActive('a')).toBe(true);
expect(te.isActive('b')).toBe(true);
expect(te.isActive('c')).toBe(true);
});
});
describe('deactivate', function() {
it('should deactive an already allowed target', function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
te.addAllowed('c');
te.deactivate('a');
te.deactivate('b');
te.deactivate('c');
expect(te.isActive('a')).toBe(false);
expect(te.isActive('b')).toBe(false);
expect(te.isActive('c')).toBe(false);
});
});
describe('isActive', function() {
it('should return true if the item is allowed and active', function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
expect(te.isActive('a')).toBe(true);
expect(te.isActive('b')).toBe(false);
});
});
describe('hasActive', function() {
it('should return true if there are any active targets', function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
expect(te.hasActive()).toBe(true);
te.deactivate('a');
expect(te.hasActive()).toBe(false);
te.activate('b');
expect(te.hasActive()).toBe(true);
});
});
describe('someActive', function() {
it('should return true if the array of targets passed are all allowed and at least on is active',
function() {
te.addAllowed('a', true);
te.addAllowed('b', false);
te.addAllowed('c');
expect(te.someActive(['a'])).toBe(true);
expect(te.someActive(['b'])).toBe(false);
expect(te.someActive(['a', 'b'])).toBe(true);
expect(te.someActive(['b', 'c'])).toBe(false);
expect(te.someActive([])).toBe(false);
expect(function() { te.someActive('d'); })
.toThrowError(
'Error accessing target "d". It is not in the list of allowed targets: a,b,c');
});
});
});