chore(docs): setting up dgeni and circle CI
This commit is contained in:
parent
262d52d3b9
commit
ca82c358dc
9
circle.yml
Normal file
9
circle.yml
Normal file
@ -0,0 +1,9 @@
|
||||
test:
|
||||
override:
|
||||
- echo "Skipping tests for now"
|
||||
|
||||
deployment:
|
||||
staging:
|
||||
branch: master
|
||||
commands:
|
||||
- ./scripts/docs/update_docs.sh
|
19
dist/src/plugins/actionsheet.js
vendored
19
dist/src/plugins/actionsheet.js
vendored
@ -1,9 +1,13 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var plugin_1 = require('./plugin');
|
||||
var ActionSheet = (function () {
|
||||
function ActionSheet() {
|
||||
@ -13,10 +17,16 @@ var ActionSheet = (function () {
|
||||
ActionSheet.hide = function (options) { };
|
||||
;
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], ActionSheet, "show", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], ActionSheet, "hide", null);
|
||||
ActionSheet = __decorate([
|
||||
plugin_1.Plugin({
|
||||
@ -24,9 +34,10 @@ var ActionSheet = (function () {
|
||||
plugin: 'cordova-plugin-actionsheet',
|
||||
pluginRef: 'plugins.actionsheet',
|
||||
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet'
|
||||
})
|
||||
}),
|
||||
__metadata('design:paramtypes', [])
|
||||
], ActionSheet);
|
||||
return ActionSheet;
|
||||
})();
|
||||
}());
|
||||
exports.ActionSheet = ActionSheet;
|
||||
//# sourceMappingURL=actionsheet.js.map
|
2
dist/src/plugins/actionsheet.js.map
vendored
2
dist/src/plugins/actionsheet.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"actionsheet.js","sourceRoot":"","sources":["../../../src/plugins/actionsheet.ts"],"names":["ActionSheet","ActionSheet.constructor","ActionSheet.show","ActionSheet.hide"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAYAC,CAACA;IAJQD,gBAAIA,GADXA,UACYA,OAAWA,IAAEE,CAACA;;IAGnBF,gBAAIA,GADXA,UACYA,OAAWA,IAAEG,CAACA;;IAJ1BH;QAACA,gBAAOA,EAAEA;OACHA,mBAAIA,QAAeA;IAE1BA;QAACA,gBAAOA,EAAEA;OACHA,mBAAIA,QAAeA;IAX5BA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,qBAAqBA;YAChCA,IAAIA,EAAEA,8DAA8DA;SACrEA,CAACA;oBAODA;IAADA,kBAACA;AAADA,CAACA,AAZD,IAYC;AANY,mBAAW,cAMvB,CAAA"}
|
||||
{"version":3,"file":"actionsheet.js","sourceRoot":"","sources":["../../../src/plugins/actionsheet.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAQzC;IAAA;IAMA,CAAC;IAJQ,gBAAI,GAAX,UAAY,OAAW,IAAE,CAAC;;IAGnB,gBAAI,GAAX,UAAY,OAAW,IAAE,CAAC;;IAJ1B;QAAC,gBAAO,EAAE;;;;iCAAA;IAGV;QAAC,gBAAO,EAAE;;;;iCAAA;IAVZ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,4BAA4B;YACpC,SAAS,EAAE,qBAAqB;YAChC,IAAI,EAAE,8DAA8D;SACrE,CAAC;;mBAAA;IAOF,kBAAC;AAAD,CAAC,AAND,IAMC;AANY,mBAAW,cAMvB,CAAA"}
|
20
dist/src/plugins/camera.js
vendored
20
dist/src/plugins/camera.js
vendored
@ -1,9 +1,13 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var plugin_1 = require('./plugin');
|
||||
var Camera = (function () {
|
||||
function Camera() {
|
||||
@ -14,21 +18,27 @@ var Camera = (function () {
|
||||
;
|
||||
__decorate([
|
||||
plugin_1.Cordova({
|
||||
// Not sure why this plugin has the success/err come first...
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
}),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Camera, "getPicture", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Camera, "cleanup", null);
|
||||
Camera = __decorate([
|
||||
plugin_1.Plugin({
|
||||
name: 'Camera',
|
||||
plugin: 'cordova-plugin-camera',
|
||||
pluginRef: 'navigator.camera'
|
||||
})
|
||||
}),
|
||||
__metadata('design:paramtypes', [])
|
||||
], Camera);
|
||||
return Camera;
|
||||
})();
|
||||
}());
|
||||
exports.Camera = Camera;
|
||||
//# sourceMappingURL=camera.js.map
|
2
dist/src/plugins/camera.js.map
vendored
2
dist/src/plugins/camera.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../../src/plugins/camera.ts"],"names":["Camera","Camera.constructor","Camera.getPicture","Camera.cleanup"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAcAC,CAACA;IAJQD,iBAAUA,GAJjBA,UAIkBA,OAAWA,IAAEE,CAACA;;IAGzBF,cAAOA,GADdA,cACiBG,CAACA;;IAPlBH;QAACA,gBAAOA,CAACA;YACPA,6DAA6DA;YAC7DA,aAAaA,EAAEA,SAASA;SACzBA,CAACA;OACKA,oBAAUA,QAAeA;IAEhCA;QAACA,gBAAOA,EAAEA;OACHA,iBAAOA,QAAIA;IAbpBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,kBAAkBA;SAC9BA,CAACA;eAUDA;IAADA,aAACA;AAADA,CAACA,AAdD,IAcC;AATY,cAAM,SASlB,CAAA"}
|
||||
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../../src/plugins/camera.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAsBzC;IAAA;IASA,CAAC;IAJQ,iBAAU,GAAjB,UAAkB,OAAW,IAAE,CAAC;;IAGzB,cAAO,GAAd,cAAiB,CAAC;;IAPlB;QAAC,gBAAO,CAAC;YAEP,aAAa,EAAE,SAAS;SACzB,CAAC;;;;kCAAA;IAGF;QAAC,gBAAO,EAAE;;;;+BAAA;IAZZ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,uBAAuB;YAC/B,SAAS,EAAE,kBAAkB;SAC9B,CAAC;;cAAA;IAUF,aAAC;AAAD,CAAC,AATD,IASC;AATY,cAAM,SASlB,CAAA"}
|
24
dist/src/plugins/contacts.js
vendored
24
dist/src/plugins/contacts.js
vendored
@ -1,9 +1,13 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var plugin_1 = require('./plugin');
|
||||
var Contacts = (function () {
|
||||
function Contacts() {
|
||||
@ -18,16 +22,25 @@ var Contacts = (function () {
|
||||
plugin_1.Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
}),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Array, Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Contacts, "create", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
}),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Array, Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Contacts, "find", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Contacts, "pickContact", null);
|
||||
Contacts = __decorate([
|
||||
plugin_1.Plugin({
|
||||
@ -35,9 +48,10 @@ var Contacts = (function () {
|
||||
plugin: 'cordova-plugin-contacts',
|
||||
pluginRef: 'navigator.contacts',
|
||||
repo: 'https://github.com/apache/cordova-plugin-contacts'
|
||||
})
|
||||
}),
|
||||
__metadata('design:paramtypes', [])
|
||||
], Contacts);
|
||||
return Contacts;
|
||||
})();
|
||||
}());
|
||||
exports.Contacts = Contacts;
|
||||
//# sourceMappingURL=contacts.js.map
|
2
dist/src/plugins/contacts.js.map
vendored
2
dist/src/plugins/contacts.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../../src/plugins/contacts.ts"],"names":["Contacts","Contacts.constructor","Contacts.create","Contacts.find","Contacts.pickContact"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAsBAC,CAACA;IAVQD,eAAMA,GALbA,UAKcA,MAAeA,EAAEA,OAAWA,IAAEE,CAACA;;IAMtCF,aAAIA,GAJXA,UAIYA,MAAeA,EAAEA,OAAWA,IAAEG,CAACA;;IAGpCH,oBAAWA,GADlBA,cACqBI,CAACA;;IAdtBJ;QAACA,gBAAOA,CAACA;YACPA,YAAYA,EAAEA,CAACA;YACfA,UAAUA,EAAEA,CAACA;SACdA,CAACA;OAEKA,kBAAMA,QAAgCA;IAE7CA;QAACA,gBAAOA,CAACA;YACPA,YAAYA,EAAEA,CAACA;YACfA,UAAUA,EAAEA,CAACA;SACdA,CAACA;OACKA,gBAAIA,QAAgCA;IAE3CA;QAACA,gBAAOA,EAAEA;OACHA,uBAAWA,QAAIA;IArBxBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,UAAUA;YAChBA,MAAMA,EAAEA,yBAAyBA;YACjCA,SAASA,EAAEA,oBAAoBA;YAC/BA,IAAIA,EAAEA,mDAAmDA;SAC1DA,CAACA;iBAiBDA;IAADA,eAACA;AAADA,CAACA,AAtBD,IAsBC;AAhBY,gBAAQ,WAgBpB,CAAA"}
|
||||
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../../src/plugins/contacts.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AA0BzC;IAAA;IAyDA,CAAC;IAzBQ,eAAM,GAAb,UAAc,MAAe,EAAE,OAAW,IAAE,CAAC;;IAqBtC,aAAI,GAAX,UAAY,MAAe,EAAE,OAAW,IAAE,CAAC;;IAGpC,oBAAW,GAAlB,cAAqB,CAAC;;IAvDtB;QAAC,gBAAO,CAAC;YACP,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;SACd,CAAC;;;;gCAAA;IA8BF;QAAC,gBAAO,CAAC;YACP,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;SACd,CAAC;;;;8BAAA;IAkBF;QAAC,gBAAO,EAAE;;;;qCAAA;IA7DZ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,yBAAyB;YACjC,SAAS,EAAE,oBAAoB;YAC/B,IAAI,EAAE,mDAAmD;SAC1D,CAAC;;gBAAA;IA0DF,eAAC;AAAD,CAAC,AAzDD,IAyDC;AAzDY,gBAAQ,WAyDpB,CAAA"}
|
14
dist/src/plugins/device.js
vendored
14
dist/src/plugins/device.js
vendored
@ -1,9 +1,13 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var plugin_1 = require('./plugin');
|
||||
var Device = (function () {
|
||||
function Device() {
|
||||
@ -12,16 +16,20 @@ var Device = (function () {
|
||||
return window.device;
|
||||
};
|
||||
__decorate([
|
||||
plugin_1.RequiresPlugin
|
||||
plugin_1.RequiresPlugin,
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], Device, "getDevice", null);
|
||||
Device = __decorate([
|
||||
plugin_1.Plugin({
|
||||
name: 'Device',
|
||||
plugin: 'cordova-plugin-device',
|
||||
pluginRef: 'device'
|
||||
})
|
||||
}),
|
||||
__metadata('design:paramtypes', [])
|
||||
], Device);
|
||||
return Device;
|
||||
})();
|
||||
}());
|
||||
exports.Device = Device;
|
||||
//# sourceMappingURL=device.js.map
|
2
dist/src/plugins/device.js.map
vendored
2
dist/src/plugins/device.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../../src/plugins/device.ts"],"names":["Device","Device.constructor","Device.getDevice"],"mappings":";;;;;;AAAA,uBAAqC,UAAU,CAAC,CAAA;AAIhD;IAAAA;IAWAC,CAACA;IAHQD,gBAASA,GADhBA;QAEEE,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACvBA,CAACA;IAHDF;QAACA,uBAAcA;OACRA,mBAASA,QAEfA;IAVHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,QAAQA;SACpBA,CAACA;eAODA;IAADA,aAACA;AAADA,CAACA,AAXD,IAWC;AANY,cAAM,SAMlB,CAAA"}
|
||||
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../../src/plugins/device.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAAqC,UAAU,CAAC,CAAA;AAoBhD;IAAA;IAWA,CAAC;IAHQ,gBAAS,GAAhB;QACE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAHD;QAAC,uBAAc;;;;iCAAA;IAZjB;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,uBAAuB;YAC/B,SAAS,EAAE,QAAQ;SACpB,CAAC;;cAAA;IAYF,aAAC;AAAD,CAAC,AAXD,IAWC;AAXY,cAAM,SAWlB,CAAA"}
|
3
dist/src/plugins/geolocation.js
vendored
3
dist/src/plugins/geolocation.js
vendored
@ -1,3 +1,4 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
@ -40,6 +41,6 @@ var Geolocation = (function () {
|
||||
__metadata('design:paramtypes', [])
|
||||
], Geolocation);
|
||||
return Geolocation;
|
||||
})();
|
||||
}());
|
||||
exports.Geolocation = Geolocation;
|
||||
//# sourceMappingURL=geolocation.js.map
|
2
dist/src/plugins/geolocation.js.map
vendored
2
dist/src/plugins/geolocation.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../../../src/plugins/geolocation.ts"],"names":["Geolocation","Geolocation.constructor","Geolocation.getCurrentPosition","Geolocation.watchPosition"],"mappings":";;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAMzC;IAAAA;IAgBAC,CAACA;IATQD,8BAAkBA,GADzBA,UAC0BA,OAAWA,IAAEE,CAACA;;IAQjCF,yBAAaA,GALpBA,UAKqBA,OAAWA,IAAEG,CAACA;;IATnCH;QAACA,gBAAOA,EAAEA;;;;OACHA,iCAAkBA,QAAeA;IAGxCA;QAACA,gBAAOA,CAACA;YACPA,aAAaA,EAAEA,SAASA;YACxBA,UAAUA,EAAEA,IAAIA;YAChBA,aAAaA,EAAEA,cAAcA;SAC9BA,CAACA;;;;OACKA,4BAAaA,QAAeA;IAfrCA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,uBAAuBA;SACnCA,CAACA;;oBAYDA;IAADA,kBAACA;AAADA,CAACA,AAhBD,IAgBC;AAXY,mBAAW,cAWvB,CAAA"}
|
||||
{"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../../../src/plugins/geolocation.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AA6BzC;IAAA;IAWA,CAAC;IATQ,8BAAkB,GAAzB,UAA0B,OAAW,IAAE,CAAC;;IAQjC,yBAAa,GAApB,UAAqB,OAAW,IAAE,CAAC;;IATnC;QAAC,gBAAO,EAAE;;;;+CAAA;IAIV;QAAC,gBAAO,CAAC;YACP,aAAa,EAAE,SAAS;YACxB,UAAU,EAAE,IAAI;YAChB,aAAa,EAAE,cAAc;SAC9B,CAAC;;;;0CAAA;IAdJ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,4BAA4B;YACpC,SAAS,EAAE,uBAAuB;SACnC,CAAC;;mBAAA;IAYF,kBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,mBAAW,cAWvB,CAAA"}
|
54
dist/src/plugins/statusbar.js
vendored
54
dist/src/plugins/statusbar.js
vendored
@ -1,9 +1,13 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var plugin_1 = require('./plugin');
|
||||
var StatusBar = (function () {
|
||||
function StatusBar() {
|
||||
@ -27,40 +31,68 @@ var StatusBar = (function () {
|
||||
StatusBar.show = function () { };
|
||||
;
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Boolean]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "overlaysWebView", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "styleDefault", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "styleLightContent", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "styleBlackTranslucent", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "styleBlackOpaque", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [String]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "backgroundColorByName", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [String]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "backgroundColorByHexString", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "hide", null);
|
||||
__decorate([
|
||||
plugin_1.Cordova()
|
||||
plugin_1.Cordova(),
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', []),
|
||||
__metadata('design:returntype', void 0)
|
||||
], StatusBar, "show", null);
|
||||
StatusBar = __decorate([
|
||||
plugin_1.Plugin({
|
||||
name: 'StatusBar',
|
||||
plugin: 'cordova-plugin-statusbar',
|
||||
pluginRef: 'StatusBar'
|
||||
})
|
||||
}),
|
||||
__metadata('design:paramtypes', [])
|
||||
], StatusBar);
|
||||
return StatusBar;
|
||||
})();
|
||||
}());
|
||||
exports.StatusBar = StatusBar;
|
||||
//# sourceMappingURL=statusbar.js.map
|
2
dist/src/plugins/statusbar.js.map
vendored
2
dist/src/plugins/statusbar.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"statusbar.js","sourceRoot":"","sources":["../../../src/plugins/statusbar.ts"],"names":["StatusBar","StatusBar.constructor","StatusBar.overlaysWebView","StatusBar.styleDefault","StatusBar.styleLightContent","StatusBar.styleBlackTranslucent","StatusBar.styleBlackOpaque","StatusBar.backgroundColorByName","StatusBar.backgroundColorByHexString","StatusBar.hide","StatusBar.show"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAwBAC,CAACA;IAjBQD,yBAAeA,GADtBA,UACuBA,SAAiBA,IAAEE,CAACA;;IAEpCF,sBAAYA,GADnBA,cACsBG,CAACA;;IAEhBH,2BAAiBA,GADxBA,cAC2BI,CAACA;;IAErBJ,+BAAqBA,GAD5BA,cAC+BK,CAACA;;IAEzBL,0BAAgBA,GADvBA,cAC0BM,CAACA;;IAEpBN,+BAAqBA,GAD5BA,UAC6BA,SAAgBA,IAAEO,CAACA;;IAEzCP,oCAA0BA,GADjCA,UACkCA,SAAgBA,IAAEQ,CAACA;;IAE9CR,cAAIA,GADXA,cACcS,CAACA;;IAERT,cAAIA,GADXA,cACcU,CAACA;;IAjBfV;QAACA,gBAAOA,EAAEA;OACHA,4BAAeA,QAAqBA;IAC3CA;QAACA,gBAAOA,EAAEA;OACHA,yBAAYA,QAAIA;IACvBA;QAACA,gBAAOA,EAAEA;OACHA,8BAAiBA,QAAIA;IAC5BA;QAACA,gBAAOA,EAAEA;OACHA,kCAAqBA,QAAIA;IAChCA;QAACA,gBAAOA,EAAEA;OACHA,6BAAgBA,QAAIA;IAC3BA;QAACA,gBAAOA,EAAEA;OACHA,kCAAqBA,QAAoBA;IAChDA;QAACA,gBAAOA,EAAEA;OACHA,uCAA0BA,QAAoBA;IACrDA;QAACA,gBAAOA,EAAEA;OACHA,iBAAIA,QAAIA;IACfA;QAACA,gBAAOA,EAAEA;OACHA,iBAAIA,QAAIA;IAvBjBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,WAAWA;YACjBA,MAAMA,EAAEA,0BAA0BA;YAClCA,SAASA,EAAEA,WAAWA;SACvBA,CAACA;kBAoBDA;IAADA,gBAACA;AAADA,CAACA,AAxBD,IAwBC;AAnBY,iBAAS,YAmBrB,CAAA"}
|
||||
{"version":3,"file":"statusbar.js","sourceRoot":"","sources":["../../../src/plugins/statusbar.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAkBzC;IAAA;IA+DA,CAAC;IAvDQ,yBAAe,GAAtB,UAAuB,SAAiB,IAAE,CAAC;;IAGpC,sBAAY,GAAnB,cAAsB,CAAC;;IAGhB,2BAAiB,GAAxB,cAA2B,CAAC;;IAGrB,+BAAqB,GAA5B,cAA+B,CAAC;;IAGzB,0BAAgB,GAAvB,cAA0B,CAAC;;IAWpB,+BAAqB,GAA5B,UAA6B,SAAgB,IAAE,CAAC;;IAUzC,oCAA0B,GAAjC,UAAkC,SAAgB,IAAE,CAAC;;IAe9C,cAAI,GAAX,cAAc,CAAC;;IAMR,cAAI,GAAX,cAAc,CAAC;;IAvDf;QAAC,gBAAO,EAAE;;;;0CAAA;IAGV;QAAC,gBAAO,EAAE;;;;uCAAA;IAGV;QAAC,gBAAO,EAAE;;;;4CAAA;IAGV;QAAC,gBAAO,EAAE;;;;gDAAA;IAGV;QAAC,gBAAO,EAAE;;;;2CAAA;IAWV;QAAC,gBAAO,EAAE;;;;gDAAA;IAUV;QAAC,gBAAO,EAAE;;;;qDAAA;IAeV;QAAC,gBAAO,EAAE;;;;+BAAA;IAMV;QAAC,gBAAO,EAAE;;;;+BAAA;IAlEZ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,0BAA0B;YAClC,SAAS,EAAE,WAAW;SACvB,CAAC;;iBAAA;IAgEF,gBAAC;AAAD,CAAC,AA/DD,IA+DC;AA/DY,iBAAS,YA+DrB,CAAA"}
|
13
gulpfile.js
Normal file
13
gulpfile.js
Normal file
@ -0,0 +1,13 @@
|
||||
var gulp = require('gulp');
|
||||
var minimist = require('minimist');
|
||||
|
||||
var flagConfig = {
|
||||
string: ['port', 'version', 'ngVersion', 'animations'],
|
||||
boolean: ['dry-run'],
|
||||
alias: {'p': 'port', 'v': 'version', 'a': 'ngVersion'},
|
||||
default: { port: 8000 }
|
||||
};
|
||||
var flags = minimist(process.argv.slice(2), flagConfig);
|
||||
|
||||
/* Docs tasks */
|
||||
require('./scripts/docs/gulp-tasks')(gulp, flags);
|
15
package.json
15
package.json
@ -9,6 +9,21 @@
|
||||
"dependencies": {
|
||||
"@reactivex/rxjs": "^5.0.0-alpha.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"canonical-path": "0.0.2",
|
||||
"cpr": "^1.0.0",
|
||||
"dgeni": "^0.4.2",
|
||||
"dgeni-packages": "^0.10.18",
|
||||
"glob": "^6.0.4",
|
||||
"gulp": "~3.9.0",
|
||||
"lodash": "3.10.1",
|
||||
"minimist": "^1.1.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-html-encoder": "0.0.2",
|
||||
"q": "1.4.1",
|
||||
"semver": "^5.0.1",
|
||||
"typescript": "^1.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc --module commonjs --sourcemap --outDir dist/ --experimentalDecorators -d node_modules/@reactivex/rxjs/typings/es6-shim/es6-shim.d.ts src/index.ts --target ES5",
|
||||
|
5
scripts/config.json
Normal file
5
scripts/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"sitePath": "../ionic-site",
|
||||
"v2DocsDir": "docs/v2/platform",
|
||||
"docsDest": "../ionic-site/docs/v2/platform"
|
||||
}
|
50
scripts/docs/deploy.sh
Executable file
50
scripts/docs/deploy.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARG_DEFS=(
|
||||
"--version-name=(.*)"
|
||||
)
|
||||
|
||||
echo "##### "
|
||||
echo "##### docs/deploy.sh"
|
||||
echo "#####"
|
||||
|
||||
function init {
|
||||
cd ..
|
||||
SITE_PATH=$(readJsonProp "config.json" "sitePath")
|
||||
SITE_DIR=$IONIC_DIR/$SITE_PATH
|
||||
}
|
||||
|
||||
function run {
|
||||
./git/clone.sh --repository="driftyco/ionic-site" \
|
||||
--directory="$SITE_DIR" \
|
||||
--branch="master"
|
||||
cd ..
|
||||
VERSION=$(readJsonProp "package.json" "version")
|
||||
|
||||
# process new docs
|
||||
gulp docs --doc-version="$VERSION_NAME"
|
||||
|
||||
# compile sass vars json for ionic-site docs
|
||||
gulp docs.sass-variables
|
||||
cp tmp/sass.json $SITE_DIR/docs/v2/theming/overriding-ionic-variables/
|
||||
|
||||
# CD in to the site dir to commit updated docs
|
||||
cd $SITE_DIR
|
||||
|
||||
CHANGES=$(git status --porcelain)
|
||||
|
||||
# if no changes, don't commit
|
||||
if [[ "$CHANGES" == "" ]]; then
|
||||
ls
|
||||
echo "-- No changes detected in docs for $VERSION_NAME; docs not updated."
|
||||
else
|
||||
git add -A
|
||||
git commit -am "docs: update for $VERSION"
|
||||
git push origin master
|
||||
|
||||
echo "-- Updated docs for $VERSION_NAME succesfully!"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
source $(dirname $0)/../utils.sh.inc
|
160
scripts/docs/dgeni-config.js
Normal file
160
scripts/docs/dgeni-config.js
Normal file
@ -0,0 +1,160 @@
|
||||
var Package = require('dgeni').Package;
|
||||
var jsdocPackage = require('dgeni-packages/jsdoc');
|
||||
var nunjucksPackage = require('dgeni-packages/nunjucks');
|
||||
var typescriptPackage = require('./typescript-package');
|
||||
var linksPackage = require('./links-package');
|
||||
var gitPackage = require('dgeni-packages/git');
|
||||
var path = require('path');
|
||||
var semver = require('semver');
|
||||
var fs = require('fs');
|
||||
var _ = require('lodash');
|
||||
var config = require('../config.json');
|
||||
var projectPackage = require('../../package.json');
|
||||
|
||||
// Define the dgeni package for generating the docs
|
||||
module.exports = function(currentVersion) {
|
||||
|
||||
return new Package('ionic-v2-docs',
|
||||
[jsdocPackage, nunjucksPackage, typescriptPackage,
|
||||
linksPackage, gitPackage])
|
||||
|
||||
// .processor(require('./processors/latest-version'))
|
||||
.processor(require('./processors/jekyll'))
|
||||
.processor(require('./processors/remove-private-members'))
|
||||
.processor(require('./processors/hide-private-api'))
|
||||
|
||||
// for debugging docs
|
||||
// .processor(function test(){
|
||||
// return {
|
||||
//
|
||||
// $runBefore: ['rendering-docs'],
|
||||
// $process: function(docs){
|
||||
// docs.forEach(function(doc){
|
||||
// if (doc.members && doc.name == "IonicApp"){
|
||||
// doc.members.forEach(function(method){
|
||||
// if (method.name === "load") {
|
||||
// console.log(method);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
||||
.config(function(log) {
|
||||
log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
|
||||
})
|
||||
|
||||
.config(function(renderDocsProcessor, computePathsProcessor, versionInfo) {
|
||||
|
||||
versions = [];
|
||||
// new version, add it to the versions list
|
||||
if (currentVersion != 'nightly' && !_.contains(versions, currentVersion)) {
|
||||
versions.unshift(currentVersion);
|
||||
}
|
||||
//First semver valid version is latest
|
||||
var latestVersion = _.find(versions, semver.valid);
|
||||
versions = versions.map(function(version) {
|
||||
// We don't separate by versions so always put the docs in the root
|
||||
var folder = '';
|
||||
return {
|
||||
href: path.join('/' + config.v2DocsDir, folder),
|
||||
folder: folder,
|
||||
name: version
|
||||
};
|
||||
});
|
||||
|
||||
var versionData = {
|
||||
list: versions,
|
||||
current: _.find(versions, {name: currentVersion}),
|
||||
latest: _.find(versions, {name: latestVersion}) || _.first(versions)
|
||||
};
|
||||
|
||||
renderDocsProcessor.extraData.version = versionData;
|
||||
renderDocsProcessor.extraData.versionInfo = versionInfo;
|
||||
|
||||
computePathsProcessor.pathTemplates = [{
|
||||
docTypes: ['class', 'var', 'function', 'let'],
|
||||
getOutputPath: function(doc) {
|
||||
var docPath = doc.name + '/index.md';
|
||||
var path = config.v2DocsDir + '/' + docPath;
|
||||
|
||||
return path;
|
||||
}
|
||||
}];
|
||||
})
|
||||
|
||||
//configure file reading
|
||||
.config(function(readFilesProcessor, readTypeScriptModules) {
|
||||
|
||||
// Don't run unwanted processors since we are not using the normal file reading processor
|
||||
readFilesProcessor.$enabled = false;
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
|
||||
|
||||
readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname,
|
||||
'../..'));
|
||||
readTypeScriptModules.sourceFiles = [
|
||||
'src/index.ts'
|
||||
];
|
||||
})
|
||||
|
||||
.config(function(parseTagsProcessor) {
|
||||
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions
|
||||
.concat(require('./tag-defs/tag-defs'));
|
||||
})
|
||||
|
||||
// .config(function(parseTagsProcessor) {
|
||||
// // We actually don't want to parse param docs in this package as we are
|
||||
// // getting the data out using TS
|
||||
// parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
|
||||
// console.log(tagDef);
|
||||
// if (tagDef.name === 'param') {
|
||||
// tagDef.docProperty = 'paramData';
|
||||
// tagDef.transforms = [];
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
|
||||
// Configure links
|
||||
.config(function(getLinkInfo) {
|
||||
getLinkInfo.useFirstAmbiguousLink = false;
|
||||
})
|
||||
|
||||
// Configure file writing
|
||||
.config(function(writeFilesProcessor) {
|
||||
writeFilesProcessor.outputFolder = config.sitePath;
|
||||
})
|
||||
|
||||
// Configure rendering
|
||||
.config(function(templateFinder, templateEngine) {
|
||||
|
||||
// Nunjucks and Angular conflict in their template bindings so change the Nunjucks
|
||||
// Also conflict with Jekyll
|
||||
templateEngine.config.tags = {
|
||||
variableStart: '<$',
|
||||
variableEnd: '$>',
|
||||
blockStart: '<@',
|
||||
blockEnd: '@>',
|
||||
commentStart: '<#',
|
||||
commentEnd: '#>'
|
||||
};
|
||||
|
||||
// add custom filters to nunjucks
|
||||
templateEngine.filters.push(
|
||||
require('./filters/capital'),
|
||||
require('./filters/code'),
|
||||
require('./filters/dump')
|
||||
);
|
||||
|
||||
templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
|
||||
|
||||
// Specify how to match docs to templates.
|
||||
templateFinder.templatePatterns = [
|
||||
'${ doc.template }',
|
||||
'${ doc.docType }.template.html',
|
||||
'common.template.html'
|
||||
];
|
||||
});
|
||||
|
||||
};
|
7
scripts/docs/filters/capital.js
Normal file
7
scripts/docs/filters/capital.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
name: 'capital',
|
||||
process: function(str) {
|
||||
str || (str = '');
|
||||
return str.charAt(0).toUpperCase() + str.substring(1);
|
||||
}
|
||||
};
|
25
scripts/docs/filters/code.js
Normal file
25
scripts/docs/filters/code.js
Normal file
@ -0,0 +1,25 @@
|
||||
var encoder = new require('node-html-encoder').Encoder();
|
||||
|
||||
function code(str, inline, lang) {
|
||||
// Encode any HTML entities in the code string
|
||||
str = encoder.htmlEncode(str, true);
|
||||
|
||||
// If a language is provided then attach a CSS class to the code element
|
||||
lang = lang ? ' class="lang-' + lang + '"' : '';
|
||||
|
||||
str = '<code' + lang + '>' + str + '</code>';
|
||||
|
||||
// If not inline then wrap the code element in a pre element
|
||||
if ( !inline ) {
|
||||
str = '<pre>' + str + '</pre>';
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'code',
|
||||
process: function(str, lang) {
|
||||
return code(str, true, lang);
|
||||
}
|
||||
};
|
6
scripts/docs/filters/dump.js
Normal file
6
scripts/docs/filters/dump.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
name: 'dump',
|
||||
process: function(obj) {
|
||||
console.log(obj);
|
||||
}
|
||||
};
|
15
scripts/docs/gulp-tasks.js
Normal file
15
scripts/docs/gulp-tasks.js
Normal file
@ -0,0 +1,15 @@
|
||||
var config = require('../config.json');
|
||||
var projectPackage = require('../../package.json');
|
||||
module.exports = function(gulp) {
|
||||
gulp.task('docs', [], function() {
|
||||
var Dgeni = require('dgeni');
|
||||
var semver = require('semver');
|
||||
try {
|
||||
var ionicPackage = require('./dgeni-config')(projectPackage.version);
|
||||
var dgeni = new Dgeni([ionicPackage]);
|
||||
return dgeni.generate();
|
||||
} catch (err) {
|
||||
console.log(err.stack);
|
||||
}
|
||||
});
|
||||
}
|
12
scripts/docs/links-package/index.js
Normal file
12
scripts/docs/links-package/index.js
Normal file
@ -0,0 +1,12 @@
|
||||
var Package = require('dgeni').Package;
|
||||
|
||||
module.exports = new Package('links', [])
|
||||
|
||||
.factory(require('./inline-tag-defs/link'))
|
||||
.factory(require('dgeni-packages/ngdoc/services/getAliases'))
|
||||
.factory(require('dgeni-packages/ngdoc/services/getDocFromAlias'))
|
||||
.factory(require('./services/getLinkInfo'))
|
||||
|
||||
.config(function(inlineTagProcessor, linkInlineTagDef) {
|
||||
inlineTagProcessor.inlineTagDefinitions.push(linkInlineTagDef);
|
||||
});
|
33
scripts/docs/links-package/inline-tag-defs/link.js
Normal file
33
scripts/docs/links-package/inline-tag-defs/link.js
Normal file
@ -0,0 +1,33 @@
|
||||
var INLINE_LINK = /(\S+)(?:\s+([\s\S]+))?/;
|
||||
|
||||
/**
|
||||
* @dgService linkInlineTagDef
|
||||
* @description
|
||||
* Process inline link tags (of the form {@link some/uri Some Title}), replacing them with HTML anchors
|
||||
* @kind function
|
||||
* @param {Object} url The url to match
|
||||
* @param {Function} docs error message
|
||||
* @return {String} The html link information
|
||||
*
|
||||
* @property {boolean} relativeLinks Whether we expect the links to be relative to the originating doc
|
||||
*/
|
||||
module.exports = function linkInlineTagDef(getLinkInfo, createDocMessage, log) {
|
||||
return {
|
||||
name: 'link',
|
||||
description: 'Process inline link tags (of the form {@link some/uri Some Title}), replacing them with HTML anchors',
|
||||
handler: function(doc, tagName, tagDescription) {
|
||||
|
||||
// Parse out the uri and title
|
||||
return tagDescription.replace(INLINE_LINK, function(match, uri, title) {
|
||||
|
||||
var linkInfo = getLinkInfo(uri, title, doc);
|
||||
|
||||
if ( !linkInfo.valid ) {
|
||||
log.warn(createDocMessage(linkInfo.error, doc));
|
||||
}
|
||||
|
||||
return "<a href='" + linkInfo.url + "'>" + linkInfo.title + "</a>";
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
72
scripts/docs/links-package/services/getLinkInfo.js
Normal file
72
scripts/docs/links-package/services/getLinkInfo.js
Normal file
@ -0,0 +1,72 @@
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
|
||||
/**
|
||||
* @dgService getLinkInfo
|
||||
* @description
|
||||
* Get link information to a document that matches the given url
|
||||
* @kind function
|
||||
* @param {String} url The url to match
|
||||
* @param {String} title An optional title to return in the link information
|
||||
* @return {Object} The link information
|
||||
*
|
||||
* @property {boolean} relativeLinks Whether we expect the links to be relative to the originating doc
|
||||
*/
|
||||
module.exports = function getLinkInfo(getDocFromAlias, encodeCodeBlock, log) {
|
||||
|
||||
return function getLinkInfoImpl(url, title, currentDoc) {
|
||||
var linkInfo = {
|
||||
url: url,
|
||||
type: 'url',
|
||||
valid: true,
|
||||
title: title || url
|
||||
};
|
||||
|
||||
if ( !url ) {
|
||||
throw new Error('Invalid url');
|
||||
}
|
||||
|
||||
var docs = getDocFromAlias(url, currentDoc);
|
||||
|
||||
if ( !getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1 ) {
|
||||
|
||||
linkInfo.valid = false;
|
||||
linkInfo.errorType = 'ambiguous';
|
||||
linkInfo.error = 'Ambiguous link: "' + url + '".\n' +
|
||||
docs.reduce(function(msg, doc) { return msg + '\n "' + doc.id + '" ('+ doc.docType + ') : (' + doc.path + ' / ' + doc.fileInfo.relativePath + ')'; }, 'Matching docs: ');
|
||||
|
||||
} else if ( docs.length >= 1 ) {
|
||||
|
||||
linkInfo.url = docs[0].path;
|
||||
linkInfo.title = title || encodeCodeBlock(docs[0].name, true);
|
||||
linkInfo.type = 'doc';
|
||||
|
||||
if ( getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path ) {
|
||||
var currentFolder = path.dirname(currentDoc.path);
|
||||
var docFolder = path.dirname(linkInfo.url);
|
||||
var relativeFolder = path.relative(path.join('/', currentFolder), path.join('/', docFolder));
|
||||
linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
|
||||
log.debug(currentDoc.path, docs[0].path, linkInfo.url);
|
||||
}
|
||||
|
||||
} else if ( url.indexOf('#') > 0 ) {
|
||||
var pathAndHash = url.split('#');
|
||||
linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
|
||||
linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
|
||||
return linkInfo;
|
||||
|
||||
} else if ( url.indexOf('/') === -1 && url.indexOf('#') !== 0 ) {
|
||||
|
||||
linkInfo.valid = false;
|
||||
linkInfo.errorType = 'missing';
|
||||
linkInfo.error = 'Invalid link (does not match any doc): "' + url + '"';
|
||||
|
||||
} else {
|
||||
|
||||
linkInfo.title = title || (( url.indexOf('#') === 0 ) ? url.substring(1) : path.basename(url, '.html'));
|
||||
|
||||
}
|
||||
|
||||
return linkInfo;
|
||||
};
|
||||
};
|
18
scripts/docs/processors/hide-private-api.js
Normal file
18
scripts/docs/processors/hide-private-api.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = function removePrivateApi() {
|
||||
return {
|
||||
name: 'remove-private-api',
|
||||
description: 'Prevent the private apis from being rendered',
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: function(docs) {
|
||||
var publicDocs = [];
|
||||
docs.forEach(function(doc){
|
||||
if(!doc.private){
|
||||
publicDocs.push(doc);
|
||||
return doc
|
||||
}
|
||||
})
|
||||
docs = publicDocs;
|
||||
return docs;
|
||||
}
|
||||
}
|
||||
};
|
35
scripts/docs/processors/jekyll.js
Normal file
35
scripts/docs/processors/jekyll.js
Normal file
@ -0,0 +1,35 @@
|
||||
module.exports = function jekyll(renderDocsProcessor) {
|
||||
return {
|
||||
name: 'jekyll',
|
||||
description: 'Create jekyll includes',
|
||||
$runAfter: ['paths-computed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: function(docs) {
|
||||
var currentVersion = renderDocsProcessor.extraData.version.current.name;
|
||||
|
||||
// pretty up and sort the docs object for menu generation
|
||||
docs = docs.filter(function(doc) {
|
||||
return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page';
|
||||
});
|
||||
docs.sort(function(a, b) {
|
||||
textA = a.name ? a.name.toUpperCase() : '';
|
||||
textB = b.name ? b.name.toUpperCase() : '';
|
||||
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
|
||||
});
|
||||
docs.forEach(function(doc, i) {
|
||||
docs[i].URL = doc.outputPath.replace('docs/v2//','docs/v2/')
|
||||
.replace('/index.md','');
|
||||
});
|
||||
|
||||
docs.push({
|
||||
docType: 'platform_menu-menu',
|
||||
id: 'platform_menu-menu',
|
||||
template: 'platform_menu.template.html',
|
||||
outputPath: '_includes/v2_fluid/platform_menu.html'
|
||||
});
|
||||
|
||||
// returning docs will replace docs object in the next process
|
||||
return docs;
|
||||
}
|
||||
};
|
||||
};
|
33
scripts/docs/processors/latest-version.js
Normal file
33
scripts/docs/processors/latest-version.js
Normal file
@ -0,0 +1,33 @@
|
||||
var copy = require('cpr').cpr;
|
||||
var mkdirp = require('mkdirp');
|
||||
var path = require('canonical-path');
|
||||
var q = require('q');
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function latestVersion(renderDocsProcessor) {
|
||||
return {
|
||||
name: 'latest-version',
|
||||
$runAfter: ['files-written'],
|
||||
description: 'Copy the latest version (that was compiled to docs/) into docs/versionName',
|
||||
$process: function(docs) {
|
||||
var versionData = renderDocsProcessor.extraData.version;
|
||||
|
||||
var docsBase = 'dist/ionic-site/docs/v2/';
|
||||
var versionDir = path.resolve(docsBase, versionData.latest.name);
|
||||
var latestDir = path.resolve(docsBase, 'api');
|
||||
|
||||
var deferred = q.defer();
|
||||
|
||||
mkdirp(versionDir, function() {
|
||||
copy(latestDir, path.join(versionDir, 'api'), {
|
||||
deleteFirst: true,
|
||||
overwrite: true
|
||||
}, function(err, files) {
|
||||
deferred.resolve(docs);
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
}
|
||||
};
|
19
scripts/docs/processors/remove-private-members.js
Normal file
19
scripts/docs/processors/remove-private-members.js
Normal file
@ -0,0 +1,19 @@
|
||||
module.exports = function removePrivateMembers() {
|
||||
return {
|
||||
name: 'remove-private-members',
|
||||
description: 'Remove member docs with @private tags',
|
||||
$runAfter: ['tags-parsed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: function(docs) {
|
||||
docs.forEach(function(doc){
|
||||
if (doc.members) {
|
||||
doc.members = doc.members.filter(function(member){
|
||||
return !member.tags.tagsByName.get("private");
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return docs;
|
||||
}
|
||||
}
|
||||
};
|
4
scripts/docs/tag-defs/tag-defs.js
Normal file
4
scripts/docs/tag-defs/tag-defs.js
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = [
|
||||
{'name': 'demo'},
|
||||
{'name': 'usage'}
|
||||
];
|
231
scripts/docs/templates/common.template.html
vendored
Normal file
231
scripts/docs/templates/common.template.html
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
---
|
||||
layout: "v2_fluid/docs_base"
|
||||
version: "<$ version.current.name $>"
|
||||
versionHref: "<$ version.current.href $>"
|
||||
path: "<$ doc.path $>"
|
||||
category: platform
|
||||
id: "{{<$ doc.name $> | slugify}}"
|
||||
title: "<@ if doc.docType == "directive" @><$ doc.name | dashCase $><@ else @><$ doc.name $><@ endif @>"
|
||||
header_sub_title: "<$ doc.docType | capital $> in module <$ doc.module $>"
|
||||
doc: "<$ doc.name $>"
|
||||
docType: "<$ doc.docType $>"
|
||||
---
|
||||
|
||||
<@ macro paramList(paramData) -@>
|
||||
<@- if paramData -@><span class="params">(
|
||||
<@- for param in paramData -@>
|
||||
<span class="param"><$ param | escape $><@ if not loop.last @>, <@ endif @></span>
|
||||
<@- endfor @>)</span>
|
||||
<@- endif @>
|
||||
<@- endmacro -@>
|
||||
|
||||
<@ macro githubViewLink(doc) -@>
|
||||
<a href="https://github.com/<$ versionInfo.gitRepoInfo.owner $>/<$ versionInfo.gitRepoInfo.repo $>/tree/master/<$ doc.fileInfo.relativePath $>#L<$ doc.location.start.line+1 $>-L<$ doc.location.end.line+1 $>"><$ doc.fileInfo.relativePath $> (line <$ doc.location.start.line+1 $>)</a>
|
||||
<@- endmacro -@>
|
||||
|
||||
<@ macro paramTable(params, isDirective) -@>
|
||||
<table class="table param-table" style="margin:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><@ if isDirective @>Attr<@ else @>Param<@ endif @></th>
|
||||
<th>Type</th>
|
||||
<th>Details</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<@ for param in params @>
|
||||
<tr>
|
||||
<td>
|
||||
<$ param.name $>
|
||||
<@ if param.alias @>| <$ param.alias $><@ endif @>
|
||||
<@ if param.type.optional @><div><em>(optional)</em></div><@ endif @>
|
||||
</td>
|
||||
<td>
|
||||
<$ typeList(param.typeList) $>
|
||||
</td>
|
||||
<td>
|
||||
<$ param.description | marked $>
|
||||
<@ if param.default @><p><em>(default: <$ param.default $>)</em></p><@ endif @>
|
||||
</td>
|
||||
</tr>
|
||||
<@ endfor @>
|
||||
</tbody>
|
||||
</table>
|
||||
<@- endmacro -@>
|
||||
|
||||
|
||||
<@- macro functionSyntax(fn) @>
|
||||
<@- set sep = joiner(', ') -@>
|
||||
<code><$ fn.name $>(<@- for param in fn.params @><$ sep() $>
|
||||
<@- if param.type.optional @>[<@ endif -@>
|
||||
<$ param.name $>
|
||||
<@- if param.type.optional @>]<@ endif -@>
|
||||
<@ endfor @>)</code>
|
||||
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
|
||||
<@ endmacro -@>
|
||||
|
||||
<@ macro typeList(types) -@>
|
||||
<@ set separator = joiner("|") @>
|
||||
<@ for type in types @><$ separator() $><$ type | code $><@ endfor @>
|
||||
<@- endmacro -@>
|
||||
|
||||
<@- macro typeInfo(fn) -@>
|
||||
<$ typeList(fn.typeList) $> <$ fn.description $>
|
||||
<@- endmacro -@>
|
||||
|
||||
<@ block body @>
|
||||
|
||||
|
||||
<@ block content @>
|
||||
|
||||
<@ block header @>
|
||||
|
||||
<h1 class="api-title">
|
||||
|
||||
<@ if doc.docType == "directive" @>
|
||||
<$ doc.name | dashCase $>
|
||||
<@ else @>
|
||||
<$ doc.name $>
|
||||
<@ endif @>
|
||||
|
||||
<@ if doc.parent @>
|
||||
<br />
|
||||
<small>
|
||||
Child of <$ doc.parent $>
|
||||
</small>
|
||||
<@ endif @>
|
||||
|
||||
<@ if doc.delegate @>
|
||||
<br/>
|
||||
<small>
|
||||
Delegate: <$ doc.delegate $>
|
||||
</small>
|
||||
<@ endif @>
|
||||
|
||||
</h1>
|
||||
|
||||
<a class="improve-v2-docs" href='http://github.com/driftyco/ionic/edit/2.0/<$ doc.fileInfo.relativePath $>#L<$ doc.location.start.line $>'>
|
||||
Improve this doc
|
||||
</a>
|
||||
|
||||
<@ if doc.codepen @>
|
||||
{% include codepen.html id="<$ doc.codepen $>" %}
|
||||
<@ endif @>
|
||||
|
||||
<@ endblock @>
|
||||
|
||||
|
||||
<!-- description -->
|
||||
<h2>Description</h2>
|
||||
<@ block description @>
|
||||
<$ doc.description | marked $>
|
||||
<@ endblock @>
|
||||
|
||||
|
||||
<@- if doc.directiveInfo @>
|
||||
<h2><$ doc.directiveInfo.type $></h2>
|
||||
<h3><$ doc.directiveInfo.properties[0].name $>: <code><$ doc.directiveInfo.properties[0].values $></code></h3>
|
||||
<@ endif -@>
|
||||
|
||||
<!-- @usage tag -->
|
||||
<@ if doc.usage @>
|
||||
<h2>Usage</h2>
|
||||
<@ block usage @>
|
||||
<$ doc.usage | marked $>
|
||||
<@ endblock @>
|
||||
<@ endif @>
|
||||
|
||||
<!-- @property tags -->
|
||||
<@ if doc.properties @>
|
||||
<h2>Attributes:</h2>
|
||||
<table class="table" style="margin:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attribute</th>
|
||||
|
||||
<@ set hasTypes = false @>
|
||||
<@ for prop in doc.properties @>
|
||||
<@ if prop.type @>
|
||||
<@ set hasTypes = true @>
|
||||
<@ endif @>
|
||||
<@ endfor @>
|
||||
<@ if hasTypes @>
|
||||
<th>Type</th>
|
||||
<@ endif @>
|
||||
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<@ for prop in doc.properties @>
|
||||
<tr>
|
||||
<td>
|
||||
<$ prop.name $>
|
||||
</td>
|
||||
|
||||
<@ if hasTypes @>
|
||||
<td>
|
||||
<$ prop.type.name $>
|
||||
</td>
|
||||
<@ endif @>
|
||||
|
||||
<td>
|
||||
<$ prop.description $>
|
||||
</td>
|
||||
</tr>
|
||||
<@ endfor @>
|
||||
</tbody>
|
||||
</table>
|
||||
<@ endif @>
|
||||
|
||||
<!-- methods on the class -->
|
||||
<@- if doc.members and doc.members.length @>
|
||||
|
||||
<h2>Methods</h2>
|
||||
<@- for method in doc.members @>
|
||||
|
||||
<div id="<$ method.name $>"></div>
|
||||
|
||||
<h3>
|
||||
<$ functionSyntax(method) $>
|
||||
</h3>
|
||||
|
||||
<$ method.description $>
|
||||
|
||||
<@ if method.params @>
|
||||
<$ paramTable(method.params) $>
|
||||
<@ endif @>
|
||||
|
||||
<@ if method.this @>
|
||||
<h4> Method's `this`
|
||||
<$ method.this $>
|
||||
</h4>
|
||||
<@ endif @>
|
||||
|
||||
<@ if method.returns @>
|
||||
<div class="return-value">
|
||||
<i class="icon ion-arrow-return-left"></i>
|
||||
<b>Returns:</b> <$ typeInfo(method.returns) $>
|
||||
</div>
|
||||
<@ endif @>
|
||||
|
||||
<@ endfor -@>
|
||||
|
||||
<@- endif -@>
|
||||
|
||||
<!-- related link -->
|
||||
<@- if doc.see @>
|
||||
|
||||
<h2>Related</h2>
|
||||
<@ for s in doc.see @>
|
||||
<$ s | safe $>
|
||||
<@- endfor -@>
|
||||
|
||||
<@- endif -@>
|
||||
|
||||
|
||||
<!-- end content block -->
|
||||
<@ endblock @>
|
||||
|
||||
<!-- end body block -->
|
||||
<@ endblock @>
|
4
scripts/docs/templates/platform_menu.template.html
vendored
Normal file
4
scripts/docs/templates/platform_menu.template.html
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<@ for doc in docs @><@ if doc.URL and doc.private != true @>
|
||||
<li class="capitalize {% if page.id == '{{<$ doc.name $> | slugify}}' %}active{% endif %}">
|
||||
<a href="/<$ doc.URL $>"><$ doc.name $></a>
|
||||
</li><@ endif @><@ endfor @>
|
100
scripts/docs/typescript-definition-package/index.js
Normal file
100
scripts/docs/typescript-definition-package/index.js
Normal file
@ -0,0 +1,100 @@
|
||||
var Package = require('dgeni').Package;
|
||||
var jsdocPackage = require('dgeni-packages/jsdoc');
|
||||
var nunjucksPackage = require('dgeni-packages/nunjucks');
|
||||
var typescriptPackage = require('../typescript-package');
|
||||
var gitPackage = require('dgeni-packages/git');
|
||||
var path = require('canonical-path');
|
||||
|
||||
// Define the dgeni package for generating the docs
|
||||
module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, gitPackage])
|
||||
|
||||
// Register the processors
|
||||
.processor(require('./processors/createTypeDefinitionFile'))
|
||||
|
||||
.config(function(readFilesProcessor, inlineTagProcessor) {
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
|
||||
// Don't run unwanted processors
|
||||
readFilesProcessor.$enabled = false;
|
||||
inlineTagProcessor.$enabled = false;
|
||||
})
|
||||
|
||||
|
||||
// Configure the log service
|
||||
.config(function(log) {
|
||||
log.level = 'info';
|
||||
})
|
||||
|
||||
|
||||
.config(function(renderDocsProcessor, versionInfo) {
|
||||
renderDocsProcessor.extraData.versionInfo = versionInfo;
|
||||
})
|
||||
|
||||
.config(function(readFilesProcessor, inlineTagProcessor, readTypeScriptModules, createTypeDefinitionFile) {
|
||||
|
||||
// Don't run unwanted processors
|
||||
readFilesProcessor.$enabled = false; // We are not using the normal file reading processor
|
||||
inlineTagProcessor.$enabled = false; // We are not actually processing the inline link tags
|
||||
|
||||
// Configure file reading
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
|
||||
readTypeScriptModules.sourceFiles = [
|
||||
'angular2/angular2.ts',
|
||||
'angular2/router.ts'
|
||||
];
|
||||
readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../../modules'));
|
||||
|
||||
createTypeDefinitionFile.typeDefinitions = [
|
||||
{
|
||||
id: 'angular2/angular2',
|
||||
modules: {
|
||||
'angular2/angular2': 'angular2/angular2',
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'angular2/router',
|
||||
modules: {
|
||||
'angular2/router': 'angular2/router'
|
||||
}
|
||||
}
|
||||
];
|
||||
})
|
||||
|
||||
|
||||
.config(function(parseTagsProcessor, getInjectables) {
|
||||
// We actually don't want to parse param docs in this package as we are getting the data out using TS
|
||||
parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
|
||||
if (tagDef.name === 'param') {
|
||||
tagDef.docProperty = 'paramData';
|
||||
tagDef.transforms = [];
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
|
||||
// Configure file writing
|
||||
.config(function(writeFilesProcessor) {
|
||||
writeFilesProcessor.outputFolder = 'dist/docs';
|
||||
})
|
||||
|
||||
|
||||
// Configure rendering
|
||||
.config(function(templateFinder, templateEngine) {
|
||||
|
||||
// Nunjucks and Angular conflict in their template bindings so change Nunjucks
|
||||
templateEngine.config.tags = {
|
||||
variableStart: '{$',
|
||||
variableEnd: '$}'
|
||||
};
|
||||
|
||||
templateFinder.templateFolders
|
||||
.unshift(path.resolve(__dirname, 'templates'));
|
||||
|
||||
templateFinder.templatePatterns = [
|
||||
'${ doc.template }',
|
||||
'${ doc.id }.${ doc.docType }.template.html',
|
||||
'${ doc.id }.template.html',
|
||||
'${ doc.docType }.template.html',
|
||||
'common.template.html'
|
||||
];
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
var Package = require('dgeni').Package;
|
||||
|
||||
module.exports = function mockPackage() {
|
||||
|
||||
return new Package('mockPackage', [require('../')])
|
||||
|
||||
// provide a mock log service
|
||||
.factory('log', function() { return require('dgeni/lib/mocks/log')(false); })
|
||||
// .factory('templateEngine', function() { return {}; });
|
||||
|
||||
};
|
@ -0,0 +1,86 @@
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
|
||||
module.exports = function createTypeDefinitionFile(log) {
|
||||
|
||||
return {
|
||||
$runAfter: ['processing-docs'],
|
||||
$runBefore: ['docs-processed'],
|
||||
$validate: {
|
||||
dtsPath: { presence: true },
|
||||
dtsExtension: { presence: true },
|
||||
typeDefinitions: { presence: true }
|
||||
},
|
||||
dtsPath: 'typings',
|
||||
dtsExtension: '.d.ts',
|
||||
typeDefinitions: [],
|
||||
$process: function(docs) {
|
||||
var dtsPath = this.dtsPath;
|
||||
var dtsExtension = this.dtsExtension;
|
||||
|
||||
// For each type definition that we wish to create we define a dgeni "doc" for it
|
||||
var typeDefDocs = _.map(this.typeDefinitions, function(def) {
|
||||
|
||||
var id = def.id + dtsExtension;
|
||||
var docPath = path.join(dtsPath, id);
|
||||
|
||||
return {
|
||||
docType: 'type-definition',
|
||||
id: id,
|
||||
aliases: [id],
|
||||
path: docPath,
|
||||
outputPath: docPath,
|
||||
// A type definition may include a number of top level modules
|
||||
// And those modules could be aliased (such as 'angular2/angular2.api' -> 'angular2/angular2')
|
||||
moduleDocs: _.transform(def.modules, function(moduleDocs, id, alias) {
|
||||
moduleDocs[id] = { id: alias, doc: null };
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
// Now add all the module docs to their corresponding type definition doc
|
||||
_.forEach(docs, function(doc) {
|
||||
_.forEach(typeDefDocs, function(typeDefDoc) {
|
||||
if(typeDefDoc.moduleDocs[doc.id]) {
|
||||
// Add a copy, because we are going to modify it
|
||||
typeDefDoc.moduleDocs[doc.id].doc = doc;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return _.filter(typeDefDocs, function(doc) {
|
||||
_.forEach(doc.moduleDocs, function(modDoc, alias) {
|
||||
if (!doc || !modDoc.doc) {
|
||||
log.error('createTypeDefinitionFile processor: no such module "' + alias + '" (Did you forget to add it to the modules to load?)');
|
||||
doc = null;
|
||||
return;
|
||||
}
|
||||
_.forEach(modDoc.doc.exports, function(exportDoc) {
|
||||
|
||||
// Search for classes with a constructor marked as `@private`
|
||||
if (exportDoc.docType === 'class' && exportDoc.constructorDoc && exportDoc.constructorDoc.private) {
|
||||
|
||||
// Convert this class to an interface with no constructor
|
||||
exportDoc.docType = 'interface';
|
||||
exportDoc.constructorDoc = null;
|
||||
|
||||
if (exportDoc.heritage) {
|
||||
// convert the heritage since interfaces use `extends` not `implements`
|
||||
exportDoc.heritage = exportDoc.heritage.replace('implements', 'extends');
|
||||
}
|
||||
|
||||
// Add the `declare var SomeClass extends InjectableReference` construct
|
||||
modDoc.doc.exports.push({
|
||||
docType: 'var',
|
||||
name: exportDoc.name,
|
||||
id: exportDoc.id,
|
||||
heritage: ': InjectableReference'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
return !!doc;
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,48 @@
|
||||
var mockPackage = require('../mocks/mockPackage');
|
||||
var Dgeni = require('dgeni');
|
||||
var path = require('canonical-path');
|
||||
var _ = require('lodash');
|
||||
|
||||
describe('createTypeDefinitionFile processor', function() {
|
||||
var dgeni, injector, processor;
|
||||
|
||||
beforeEach(function() {
|
||||
dgeni = new Dgeni([mockPackage()]);
|
||||
injector = dgeni.configureInjector();
|
||||
processor = injector.get('createTypeDefinitionFile');
|
||||
|
||||
// Initialize the processor
|
||||
processor.typeDefinitions = [{
|
||||
id: 'angular2/angular2',
|
||||
modules: { 'angular2/angular2': 'angular2/angular2' }
|
||||
}];
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe('classes with private constructors', function() {
|
||||
|
||||
it('should convert heritage from `implements` into `extends`', function() {
|
||||
|
||||
// Create some mock docs for testing
|
||||
var docs = [
|
||||
{
|
||||
id: 'angular2/angular2',
|
||||
exports: [
|
||||
{ docType: 'class', heritage: 'implements Xyz', constructorDoc: { private: true } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
docs = processor.$process(docs);
|
||||
|
||||
expect(docs.length).toEqual(1);
|
||||
expect(docs[0].docType).toEqual('type-definition');
|
||||
|
||||
var moduleDoc = docs[0].moduleDocs['angular2/angular2'].doc;
|
||||
expect(moduleDoc.exports.length).toEqual(2);
|
||||
expect(moduleDoc.exports[0].heritage).toEqual('extends Xyz');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
{% extends '../type-definition.template.html' %}
|
||||
{% block staticDeclarations %}
|
||||
|
||||
interface List<T> extends Array<T> {}
|
||||
interface Map<K,V> {}
|
||||
interface StringMap<K,V> extends Map<K,V> {}
|
||||
|
||||
declare module ng {
|
||||
// See https://github.com/Microsoft/TypeScript/issues/1168
|
||||
class BaseException /* extends Error */ {
|
||||
message: string;
|
||||
stack: string;
|
||||
toString(): string;
|
||||
}
|
||||
interface InjectableReference {}
|
||||
}
|
||||
{% endblock %}
|
@ -0,0 +1,72 @@
|
||||
|
||||
{%- macro commentBlock(doc, level) -%}
|
||||
{%- if doc.content | trim %}
|
||||
|
||||
{% if level > 1 %}{$ '/**' | indent(level-1, true) | replace(r/\n$/, "") $}{% else %}/**{% endif %}
|
||||
{$ doc.content | trim | replace(r/^/gm, "* ") | indent(level, true) | replace(r/\n$/, "") $}
|
||||
{$ '*/' | indent(level, true) | replace(r/\n$/, "") $}{% endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro memberInfo(member) -%}
|
||||
{$ commentBlock(member, 5) $}
|
||||
{$ member.name $}{% if member.optional %}?{% endif -%}
|
||||
{% if member.typeParameters %}<{% for typeParam in member.typeParameters %}{$ typeParam $}{% if not loop.last %}, {% endif %}{% endfor %}>{% endif -%}
|
||||
{%- if member.parameters -%}({% for param in member.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif -%}
|
||||
{%- if member.returnType == 'Directive' %}: DirectiveAnnotation{%- elif member.returnType -%}: {$ member.returnType $}{%- else -%}: void
|
||||
{%- endif -%};
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
// Type definitions for Angular v{$ versionInfo.currentVersion.full | replace(r/\+/, "_") $}
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ***********************************************************
|
||||
// This file is generated by the Angular build process.
|
||||
// Please do not create manual edits or send pull requests
|
||||
// modifying this file.
|
||||
// ***********************************************************
|
||||
{% block staticDeclarations %}{% endblock %}
|
||||
{% for alias, module in doc.moduleDocs %}
|
||||
{$ commentBlock(module.doc, 1) $}
|
||||
declare module ng {
|
||||
|
||||
{%- for export in module.doc.exports -%}
|
||||
{%- if export.content -%}
|
||||
{$ commentBlock(export, 3) $}
|
||||
{%- endif %}
|
||||
{$ export.docType $} {$ export.name $}{$ export.typeParams $}{%- if export.heritage == ' extends Directive' %} extends DirectiveAnnotation{% else %}{$ export.heritage $}{% endif %}
|
||||
{%- if export.docType == 'class' or export.docType == 'interface' %} {
|
||||
{%- if export.newMember %}
|
||||
{$ memberInfo(export.newMember) $}
|
||||
{% endif %}
|
||||
{%- if export.callMember %}
|
||||
{$ memberInfo(export.callMember) $}
|
||||
{% endif -%}
|
||||
{%- for member in export.members %}
|
||||
{$ memberInfo(member) $}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
{%- elif export.docType == 'enum' %} {
|
||||
{%- for member in export.members %}
|
||||
{$ member $}{% if not loop.last %},
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
{%- else -%}
|
||||
{% if export.parameters %}({% for param in export.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif %}
|
||||
{%- if export.returnType %} : {$ export.returnType $} {% endif -%}
|
||||
;
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
declare module "angular2/angular2" {
|
||||
export = ng;
|
||||
}
|
71
scripts/docs/typescript-package/index.js
Normal file
71
scripts/docs/typescript-package/index.js
Normal file
@ -0,0 +1,71 @@
|
||||
//require('../../tools/transpiler/index.js').init();
|
||||
|
||||
var basePackage = require('dgeni-packages/base');
|
||||
var Package = require('dgeni').Package;
|
||||
var path = require('canonical-path');
|
||||
|
||||
// Define the dgeni package for generating the docs
|
||||
module.exports = new Package('typescript-parsing', [basePackage])
|
||||
|
||||
// Register the services and file readers
|
||||
.factory(require('./services/modules'))
|
||||
.factory(require('./services/tsParser'))
|
||||
.factory(require('./services/tsParser/createCompilerHost'))
|
||||
.factory(require('./services/tsParser/getFileInfo'))
|
||||
.factory(require('./services/tsParser/getExportDocType'))
|
||||
.factory(require('./services/tsParser/getContent'))
|
||||
.factory(require('./services/tsParser/getDirectiveInfo'))
|
||||
|
||||
.factory('EXPORT_DOC_TYPES', function() {
|
||||
return [
|
||||
'class',
|
||||
'interface',
|
||||
'function',
|
||||
'var',
|
||||
'const',
|
||||
'enum',
|
||||
'type-alias'
|
||||
];
|
||||
})
|
||||
|
||||
|
||||
// Register the processors
|
||||
.processor(require('./processors/readTypeScriptModules'))
|
||||
|
||||
|
||||
// Configure the log service
|
||||
.config(function(log) {
|
||||
log.level = 'warn';
|
||||
})
|
||||
|
||||
|
||||
// Configure ids and paths
|
||||
.config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) {
|
||||
|
||||
computeIdsProcessor.idTemplates.push({
|
||||
docTypes: ['member'],
|
||||
idTemplate: '${classDoc.id}.${name}',
|
||||
getAliases: function(doc) { return [doc.id]; }
|
||||
});
|
||||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['member'],
|
||||
pathTemplate: '${classDoc.path}/${name}',
|
||||
getOutputPath: function() {} // These docs are not written to their own file, instead they are part of their class doc
|
||||
});
|
||||
|
||||
var MODULES_DOCS_PATH = 'docs';
|
||||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['module'],
|
||||
pathTemplate: '/${id}',
|
||||
outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.html'
|
||||
});
|
||||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: EXPORT_DOC_TYPES,
|
||||
pathTemplate: '${moduleDoc.path}/${name}',
|
||||
outputPathTemplate: MODULES_DOCS_PATH + '/${path}/index.html'
|
||||
});
|
||||
|
||||
});
|
11
scripts/docs/typescript-package/mocks/mockPackage.js
Normal file
11
scripts/docs/typescript-package/mocks/mockPackage.js
Normal file
@ -0,0 +1,11 @@
|
||||
var Package = require('dgeni').Package;
|
||||
|
||||
module.exports = function mockPackage() {
|
||||
|
||||
return new Package('mockPackage', [require('../')])
|
||||
|
||||
// provide a mock log service
|
||||
.factory('log', function() { return require('dgeni/lib/mocks/log')(false); })
|
||||
.factory('templateEngine', function() { return {}; });
|
||||
|
||||
};
|
@ -0,0 +1,4 @@
|
||||
export var __esModule = true;
|
||||
export class OKToExport {}
|
||||
export function _thisIsPrivate() {}
|
||||
export var thisIsOK = '!';
|
@ -0,0 +1,5 @@
|
||||
export interface MyInterface {
|
||||
optionalProperty? : string
|
||||
<T, U extends Findable<T>>(param: T) : U
|
||||
new (param: number) : MyInterface
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
export class Test {
|
||||
firstItem;
|
||||
constructor() { this.doStuff(); }
|
||||
otherMethod() {}
|
||||
doStuff() {}
|
||||
}
|
@ -0,0 +1 @@
|
||||
export var x = 100;
|
34
scripts/docs/typescript-package/mocks/tsParser/testSrc.ts
Normal file
34
scripts/docs/typescript-package/mocks/tsParser/testSrc.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* This is the module description
|
||||
*/
|
||||
|
||||
export * from 'importedSrc';
|
||||
|
||||
/**
|
||||
* This is some random other comment
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is MyClass
|
||||
*/
|
||||
export class MyClass {
|
||||
message: String;
|
||||
|
||||
/**
|
||||
* Create a new MyClass
|
||||
* @param {String} name The name to say hello to
|
||||
*/
|
||||
constructor(name) { this.message = 'hello ' + name; }
|
||||
|
||||
/**
|
||||
* Return a greeting message
|
||||
*/
|
||||
greet() { return this.message; }
|
||||
}
|
||||
|
||||
/**
|
||||
* An exported function
|
||||
*/
|
||||
export var myFn = (val: number) => return val * 2;
|
@ -0,0 +1,344 @@
|
||||
var glob = require('glob');
|
||||
var path = require('canonical-path');
|
||||
var _ = require('lodash');
|
||||
var ts = require('typescript');
|
||||
|
||||
module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||
getExportDocType, getContent,
|
||||
getDirectiveInfo, log) {
|
||||
|
||||
return {
|
||||
$runAfter: ['files-read'],
|
||||
$runBefore: ['parsing-tags'],
|
||||
|
||||
$validate: {
|
||||
sourceFiles: {presence: true},
|
||||
basePath: {presence: true},
|
||||
hidePrivateMembers: {inclusion: [true, false]},
|
||||
sortClassMembers: {inclusion: [true, false]},
|
||||
ignoreExportsMatching: {}
|
||||
},
|
||||
|
||||
// A collection of globs that identify those modules for which we should create docs
|
||||
sourceFiles: [],
|
||||
// The base path from which to load the source files
|
||||
basePath: '.',
|
||||
// We can ignore members of classes that are private
|
||||
hidePrivateMembers: true,
|
||||
// We leave class members sorted in order of declaration
|
||||
sortClassMembers: false,
|
||||
// We can provide a collection of strings or regexes to ignore exports whose export names match
|
||||
ignoreExportsMatching: ['___esModule'],
|
||||
|
||||
$process: function(docs) {
|
||||
|
||||
// Convert ignoreExportsMatching to an array of regexes
|
||||
var ignoreExportsMatching = convertToRegexCollection(this.ignoreExportsMatching);
|
||||
|
||||
var hidePrivateMembers = this.hidePrivateMembers;
|
||||
var sortClassMembers = this.sortClassMembers;
|
||||
|
||||
var basePath = path.resolve(this.basePath);
|
||||
var filesPaths = expandSourceFiles(this.sourceFiles, basePath);
|
||||
var parseInfo = tsParser.parse(filesPaths, this.basePath);
|
||||
var moduleSymbols = parseInfo.moduleSymbols;
|
||||
|
||||
// Iterate through each of the modules that were parsed and generate a module doc
|
||||
// as well as docs for each module's exports.
|
||||
moduleSymbols.forEach(function(moduleSymbol) {
|
||||
|
||||
var moduleDoc = createModuleDoc(moduleSymbol, basePath);
|
||||
|
||||
// Add this module doc to the module lookup collection and the docs collection
|
||||
modules[moduleDoc.id] = moduleDoc;
|
||||
docs.push(moduleDoc);
|
||||
|
||||
// Iterate through this module's exports and generate a doc for each
|
||||
moduleSymbol.exportArray.forEach(function(exportSymbol) {
|
||||
|
||||
// Ignore exports starting with an underscore
|
||||
if (anyMatches(ignoreExportsMatching, exportSymbol.name)) return;
|
||||
|
||||
// If the symbol is an Alias then for most things we want the original resolved symbol
|
||||
var resolvedExport = exportSymbol.resolvedSymbol || exportSymbol;
|
||||
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker);
|
||||
log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id);
|
||||
|
||||
// Generate docs for each of the export's members
|
||||
if (resolvedExport.flags & ts.SymbolFlags.HasMembers) {
|
||||
|
||||
exportDoc.members = [];
|
||||
for(var memberName in resolvedExport.members) {
|
||||
// FIXME(alexeagle): why do generic type params appear in members?
|
||||
if (memberName === 'T') {
|
||||
continue;
|
||||
}
|
||||
log.silly('>>>>>> member: ' + memberName + ' from ' + exportDoc.id + ' in ' + moduleDoc.id);
|
||||
var memberSymbol = resolvedExport.members[memberName];
|
||||
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
|
||||
|
||||
// We special case the constructor and sort the other members alphabetically
|
||||
if (memberSymbol.flags & ts.SymbolFlags.Constructor) {
|
||||
exportDoc.constructorDoc = memberDoc;
|
||||
docs.push(memberDoc);
|
||||
} else if (!hidePrivateMembers || memberSymbol.name.charAt(0) !== '_') {
|
||||
docs.push(memberDoc);
|
||||
exportDoc.members.push(memberDoc);
|
||||
} else if (memberSymbol.name === '__call' && memberSymbol.flags & ts.SymbolFlags.Signature) {
|
||||
docs.push(memberDoc);
|
||||
exportDoc.callMember = memberDoc;
|
||||
} else if (memberSymbol.name === '__new' && memberSymbol.flags & ts.SymbolFlags.Signature) {
|
||||
docs.push(memberDoc);
|
||||
exportDoc.newMember = memberDoc;
|
||||
}
|
||||
}
|
||||
|
||||
if (sortClassMembers) {
|
||||
exportDoc.members.sort(function(a, b) {
|
||||
if (a.name > b.name) return 1;
|
||||
if (a.name < b.name) return -1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (exportDoc.docType == 'enum') {
|
||||
exportDoc.members = [];
|
||||
for (var etype in resolvedExport.exports) {
|
||||
exportDoc.members.push(etype);
|
||||
}
|
||||
}
|
||||
|
||||
// Add this export doc to its module doc
|
||||
moduleDoc.exports.push(exportDoc);
|
||||
docs.push(exportDoc);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function createModuleDoc(moduleSymbol, basePath) {
|
||||
var id = moduleSymbol.name.replace(/^"|"$/g, '');
|
||||
var moduleDoc = {
|
||||
docType: 'module',
|
||||
id: id,
|
||||
aliases: [id],
|
||||
moduleTree: moduleSymbol,
|
||||
content: getContent(moduleSymbol),
|
||||
exports: [],
|
||||
fileInfo: getFileInfo(moduleSymbol, basePath),
|
||||
location: getLocation(moduleSymbol)
|
||||
};
|
||||
return moduleDoc;
|
||||
}
|
||||
|
||||
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
||||
var typeParamString = '';
|
||||
var heritageString = '';
|
||||
|
||||
exportSymbol.declarations.forEach(function(decl) {
|
||||
var sourceFile = ts.getSourceFileOfNode(decl);
|
||||
|
||||
if (decl.typeParameters) {
|
||||
typeParamString = '<' + getText(sourceFile, decl.typeParameters) + '>';
|
||||
}
|
||||
|
||||
if (decl.heritageClauses) {
|
||||
decl.heritageClauses.forEach(function(heritage) {
|
||||
|
||||
if (heritage.token == ts.SyntaxKind.ExtendsKeyword) {
|
||||
heritageString += " extends";
|
||||
heritage.types.forEach(function(typ, idx) {
|
||||
heritageString += (idx > 0 ? ',' : '') + typ.getFullText();
|
||||
});
|
||||
}
|
||||
|
||||
if (heritage.token == ts.SyntaxKind.ImplementsKeyword) {
|
||||
heritageString += " implements";
|
||||
heritage.types.forEach(function(typ, idx) {
|
||||
heritageString += (idx > 0 ? ', ' : '') + typ.getFullText();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Make sure duplicate aliases aren't created, so "Ambiguous link" warnings are prevented
|
||||
var aliasNames = [name, moduleDoc.id + '/' + name];
|
||||
if (typeParamString) {
|
||||
aliasNames.push(name + typeParamString);
|
||||
aliasNames.push(moduleDoc.id + '/' + name + typeParamString);
|
||||
}
|
||||
|
||||
var exportDoc = {
|
||||
docType: getExportDocType(exportSymbol),
|
||||
name: name,
|
||||
id: moduleDoc.id + '/' + name,
|
||||
typeParams: typeParamString,
|
||||
heritage: heritageString,
|
||||
aliases: aliasNames,
|
||||
moduleDoc: moduleDoc,
|
||||
content: getContent(exportSymbol),
|
||||
fileInfo: getFileInfo(exportSymbol, basePath),
|
||||
location: getLocation(exportSymbol),
|
||||
directiveInfo: getDirectiveInfo(exportSymbol)
|
||||
};
|
||||
|
||||
if(exportSymbol.flags & ts.SymbolFlags.Function) {
|
||||
exportDoc.parameters = getParameters(typeChecker, exportSymbol);
|
||||
}
|
||||
if(exportSymbol.flags & ts.SymbolFlags.Value) {
|
||||
exportDoc.returnType = getReturnType(typeChecker, exportSymbol);
|
||||
}
|
||||
return exportDoc;
|
||||
}
|
||||
|
||||
function createMemberDoc(memberSymbol, classDoc, basePath, typeChecker) {
|
||||
var memberDoc = {
|
||||
docType: 'member',
|
||||
classDoc: classDoc,
|
||||
name: memberSymbol.name,
|
||||
content: getContent(memberSymbol),
|
||||
fileInfo: getFileInfo(memberSymbol, basePath),
|
||||
location: getLocation(memberSymbol)
|
||||
};
|
||||
|
||||
memberDoc.typeParameters = getTypeParameters(typeChecker, memberSymbol);
|
||||
|
||||
if(memberSymbol.flags & (ts.SymbolFlags.Signature) ) {
|
||||
memberDoc.parameters = getParameters(typeChecker, memberSymbol);
|
||||
memberDoc.returnType = getReturnType(typeChecker, memberSymbol);
|
||||
switch(memberDoc.name) {
|
||||
case '__call':
|
||||
memberDoc.name = '';
|
||||
break;
|
||||
case '__new':
|
||||
memberDoc.name = 'new';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (memberSymbol.flags & ts.SymbolFlags.Method) {
|
||||
// NOTE: we use the property name `parameters` here so we don't conflict
|
||||
// with the `params` property that will be updated by dgeni reading the
|
||||
// `@param` tags from the docs
|
||||
memberDoc.parameters = getParameters(typeChecker, memberSymbol);
|
||||
}
|
||||
|
||||
if (memberSymbol.flags & ts.SymbolFlags.Constructor) {
|
||||
memberDoc.parameters = getParameters(typeChecker, memberSymbol);
|
||||
memberDoc.name = 'constructor';
|
||||
}
|
||||
|
||||
if(memberSymbol.flags & ts.SymbolFlags.Value) {
|
||||
memberDoc.returnType = getReturnType(typeChecker, memberSymbol);
|
||||
}
|
||||
|
||||
if(memberSymbol.flags & ts.SymbolFlags.Optional) {
|
||||
memberDoc.optional = true;
|
||||
}
|
||||
|
||||
return memberDoc;
|
||||
}
|
||||
|
||||
function getParameters(typeChecker, symbol) {
|
||||
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||
if (!declaration.parameters) {
|
||||
var location = getLocation(symbol);
|
||||
throw new Error('missing declaration parameters for "' + symbol.name +
|
||||
'" in ' + sourceFile.fileName +
|
||||
' at line ' + location.start.line);
|
||||
}
|
||||
return declaration.parameters.map(function(parameter) {
|
||||
var paramText = getText(sourceFile, parameter.name);
|
||||
if (parameter.questionToken || parameter.initializer) {
|
||||
paramText += '?';
|
||||
}
|
||||
if (parameter.type) {
|
||||
paramText += ':' + getType(sourceFile, parameter.type);
|
||||
} else {
|
||||
paramText += ': any';
|
||||
}
|
||||
return paramText.trim();
|
||||
});
|
||||
}
|
||||
|
||||
function getTypeParameters(typeChecker, symbol) {
|
||||
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||
if (!declaration.typeParameters) return;
|
||||
var typeParams = declaration.typeParameters.map(function(type) {
|
||||
return getText(sourceFile, type).trim();
|
||||
});
|
||||
return typeParams;
|
||||
}
|
||||
|
||||
function getReturnType(typeChecker, symbol) {
|
||||
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||
if (declaration.type) {
|
||||
return getType(sourceFile, declaration.type).trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function expandSourceFiles(sourceFiles, basePath) {
|
||||
var filePaths = [];
|
||||
sourceFiles.forEach(function(sourcePattern) {
|
||||
filePaths = filePaths.concat(glob.sync(sourcePattern, { cwd: basePath }));
|
||||
});
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
|
||||
function getText(sourceFile, node) {
|
||||
return sourceFile.text.substring(node.pos, node.end);
|
||||
}
|
||||
|
||||
|
||||
// Strip any local renamed imports from the front of types
|
||||
function getType(sourceFile, type) {
|
||||
var text = getText(sourceFile, type);
|
||||
while (text.indexOf(".") >= 0) {
|
||||
// Keep namespaced symbols in Rx
|
||||
if (text.match(/^\s*Rx\./)) break;
|
||||
// handle the case List<thing.stuff> -> List<stuff>
|
||||
text = text.replace(/([^.<]*)\.([^>]*)/, "$2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
function getLocation(symbol) {
|
||||
var node = symbol.valueDeclaration || symbol.declarations[0];
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
var location = {
|
||||
start: ts.getLineAndCharacterOfPosition(sourceFile, node.pos),
|
||||
end: ts.getLineAndCharacterOfPosition(sourceFile, node.end)
|
||||
};
|
||||
return location;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function convertToRegexCollection(items) {
|
||||
if (!items) return [];
|
||||
|
||||
// Must be an array
|
||||
if (!_.isArray(items)) {
|
||||
items = [items];
|
||||
}
|
||||
|
||||
// Convert string to exact matching regexes
|
||||
return items.map(function(item) {
|
||||
return _.isString(item) ? new RegExp('^' + item + '$') : item;
|
||||
});
|
||||
}
|
||||
|
||||
function anyMatches(regexes, item) {
|
||||
for(var i=0; i<regexes.length; ++i) {
|
||||
if ( item.match(regexes[i]) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
var mockPackage = require('../mocks/mockPackage');
|
||||
var Dgeni = require('dgeni');
|
||||
var path = require('canonical-path');
|
||||
var _ = require('lodash');
|
||||
|
||||
describe('readTypeScriptModules', function() {
|
||||
var dgeni, injector, processor;
|
||||
|
||||
beforeEach(function() {
|
||||
dgeni = new Dgeni([mockPackage()]);
|
||||
injector = dgeni.configureInjector();
|
||||
processor = injector.get('readTypeScriptModules');
|
||||
processor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
|
||||
});
|
||||
|
||||
|
||||
describe('ignoreExportsMatching', function() {
|
||||
it('should ignore exports that match items in the `ignoreExportsMatching` property', function() {
|
||||
processor.sourceFiles = [ 'ignoreExportsMatching.ts'];
|
||||
processor.ignoreExportsMatching = [/^_/];
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
|
||||
var moduleDoc = docs[0];
|
||||
expect(moduleDoc.docType).toEqual('module');
|
||||
expect(moduleDoc.exports).toEqual([
|
||||
jasmine.objectContaining({ name: 'OKToExport' }),
|
||||
jasmine.objectContaining({ name: 'thisIsOK' })
|
||||
]);
|
||||
});
|
||||
|
||||
it('should only ignore `___esModule` exports by default', function() {
|
||||
processor.sourceFiles = [ 'ignoreExportsMatching.ts'];
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
|
||||
var moduleDoc = docs[0];
|
||||
expect(moduleDoc.docType).toEqual('module');
|
||||
expect(getNames(moduleDoc.exports)).toEqual([
|
||||
'OKToExport',
|
||||
'_thisIsPrivate',
|
||||
'thisIsOK'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('interfaces', function() {
|
||||
|
||||
it('should mark optional properties', function() {
|
||||
processor.sourceFiles = [ 'interfaces.ts'];
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
|
||||
var moduleDoc = docs[0];
|
||||
var exportedInterface = moduleDoc.exports[0];
|
||||
var member = exportedInterface.members[0];
|
||||
expect(member.name).toEqual('optionalProperty');
|
||||
expect(member.optional).toEqual(true);
|
||||
});
|
||||
|
||||
|
||||
it('should handle "call" type interfaces', function() {
|
||||
processor.sourceFiles = [ 'interfaces.ts'];
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
|
||||
var moduleDoc = docs[0];
|
||||
var exportedInterface = moduleDoc.exports[0];
|
||||
|
||||
expect(exportedInterface.callMember).toBeDefined();
|
||||
expect(exportedInterface.callMember.parameters).toEqual(['param: T']);
|
||||
expect(exportedInterface.callMember.returnType).toEqual('U');
|
||||
expect(exportedInterface.callMember.typeParameters).toEqual(['T', 'U extends Findable<T>']);
|
||||
expect(exportedInterface.newMember).toBeDefined();
|
||||
expect(exportedInterface.newMember.parameters).toEqual(['param: number']);
|
||||
expect(exportedInterface.newMember.returnType).toEqual('MyInterface');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('ordering of members', function() {
|
||||
it('should order class members in order of appearance (by default)', function() {
|
||||
processor.sourceFiles = ['orderingOfMembers.ts'];
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
var classDoc = _.find(docs, { docType: 'class' });
|
||||
expect(classDoc.docType).toEqual('class');
|
||||
expect(getNames(classDoc.members)).toEqual([
|
||||
'firstItem',
|
||||
'otherMethod',
|
||||
'doStuff',
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
it('should not order class members if not sortClassMembers is false', function() {
|
||||
processor.sourceFiles = ['orderingOfMembers.ts'];
|
||||
processor.sortClassMembers = false;
|
||||
var docs = [];
|
||||
processor.$process(docs);
|
||||
var classDoc = _.find(docs, { docType: 'class' });
|
||||
expect(classDoc.docType).toEqual('class');
|
||||
expect(getNames(classDoc.members)).toEqual([
|
||||
'firstItem',
|
||||
'otherMethod',
|
||||
'doStuff'
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getNames(collection) {
|
||||
return collection.map(function(item) { return item.name; });
|
||||
}
|
3
scripts/docs/typescript-package/services/modules.js
Normal file
3
scripts/docs/typescript-package/services/modules.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function modules() {
|
||||
return {};
|
||||
};
|
@ -0,0 +1,75 @@
|
||||
var ts = require('typescript');
|
||||
var fs = require('fs');
|
||||
var path = require('canonical-path');
|
||||
|
||||
// We need to provide our own version of CompilerHost because we want to set the
|
||||
// base directory and specify what extensions to consider when trying to load a source
|
||||
// file
|
||||
module.exports = function createCompilerHost(log) {
|
||||
|
||||
return function createCompilerHost(options, baseDir, extensions) {
|
||||
|
||||
return {
|
||||
getSourceFile: function(fileName, languageVersion, onError) {
|
||||
var text, resolvedPath, resolvedPathWithExt;
|
||||
|
||||
// Strip off the extension and resolve relative to the baseDir
|
||||
baseFilePath = fileName.replace(/\.[^.]+$/, '');
|
||||
resolvedPath = path.resolve(baseDir, baseFilePath);
|
||||
|
||||
// Iterate through each possible extension and return the first source file that is actually found
|
||||
for(var i=0; i<extensions.length; i++) {
|
||||
|
||||
// Try reading the content from files using each of the given extensions
|
||||
try {
|
||||
resolvedPathWithExt = resolvedPath + extensions[i];
|
||||
log.silly('getSourceFile:', resolvedPathWithExt);
|
||||
text = fs.readFileSync(resolvedPathWithExt, { encoding: options.charset });
|
||||
log.debug('found source file:', fileName, resolvedPathWithExt);
|
||||
return ts.createSourceFile(baseFilePath + extensions[i], text, languageVersion);
|
||||
}
|
||||
catch(e) {
|
||||
// Try again if the file simply did not exist, otherwise report the error as a warning
|
||||
if(e.code !== 'ENOENT') {
|
||||
if (onError) onError(e.message);
|
||||
log.warn('Error reading ' + resolvedPathWithExt + ' : ' + e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getDefaultLibFileName: function(options) {
|
||||
return path.resolve(path.dirname(ts.sys.getExecutingFilePath()), ts.getDefaultLibFileName(options));
|
||||
},
|
||||
writeFile: function(fileName, data, writeByteOrderMark, onError) {
|
||||
// no-op
|
||||
},
|
||||
getCurrentDirectory: function() {
|
||||
return baseDir;
|
||||
},
|
||||
useCaseSensitiveFileNames: function() {
|
||||
return ts.sys.useCaseSensitiveFileNames;
|
||||
},
|
||||
getCanonicalFileName: function(fileName) {
|
||||
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
|
||||
// otherwise use toLowerCase as a canonical form.
|
||||
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
},
|
||||
getNewLine: function() {
|
||||
return ts.sys.newLine;
|
||||
},
|
||||
fileExists: function(fileName) {
|
||||
var resolvedPath = path.resolve(baseDir, fileName);
|
||||
try {
|
||||
fs.statSync(resolvedPath);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
readFile: function(fileName) {
|
||||
var resolvedPath = path.resolve(baseDir, fileName);
|
||||
return fs.readFileSync(resolvedPath, { encoding: options.charset });
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
@ -0,0 +1,80 @@
|
||||
var mockPackage = require('../../mocks/mockPackage');
|
||||
var Dgeni = require('dgeni');
|
||||
var path = require('canonical-path');
|
||||
var ts = require('typescript');
|
||||
|
||||
describe('createCompilerHost', function() {
|
||||
var dgeni, injector, options, host, baseDir, extensions;
|
||||
|
||||
beforeEach(function() {
|
||||
dgeni = new Dgeni([mockPackage()]);
|
||||
injector = dgeni.configureInjector();
|
||||
var createCompilerHost = injector.get('createCompilerHost');
|
||||
|
||||
options = { charset: 'utf8' };
|
||||
baseDir = path.resolve(__dirname, '../../mocks/tsParser');
|
||||
extensions = ['.ts', '.js'];
|
||||
|
||||
host = createCompilerHost(options, baseDir, extensions);
|
||||
});
|
||||
|
||||
describe('getSourceFile', function() {
|
||||
it('should return a SourceFile object for a given path, with fileName relative to baseDir', function() {
|
||||
var sourceFile = host.getSourceFile('testSrc.ts');
|
||||
expect(sourceFile.fileName).toEqual('testSrc.ts');
|
||||
expect(sourceFile.pos).toEqual(0);
|
||||
expect(sourceFile.text).toEqual(jasmine.any(String));
|
||||
});
|
||||
|
||||
it('should try each of the configured extensions and update the filename to the correct extension', function() {
|
||||
var sourceFile = host.getSourceFile('testSrc.js');
|
||||
expect(sourceFile.fileName).toEqual('testSrc.ts');
|
||||
|
||||
sourceFile = host.getSourceFile('../mockPackage.ts');
|
||||
expect(sourceFile.fileName).toEqual('../mockPackage.js');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getDefaultLibFileName', function() {
|
||||
it('should return a path to the default library', function() {
|
||||
expect(host.getDefaultLibFileName(options)).toContain('typescript/bin/lib.d.ts');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('writeFile', function() {
|
||||
it('should do nothing', function() {
|
||||
host.writeFile();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getCurrentDirectory', function() {
|
||||
it('should return the baseDir', function() {
|
||||
expect(host.getCurrentDirectory()).toEqual(baseDir);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('useCaseSensitiveFileNames', function() {
|
||||
it('should return true if the OS is case sensitive', function() {
|
||||
expect(host.useCaseSensitiveFileNames()).toBe(ts.sys.useCaseSensitiveFileNames);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getCanonicalFileName', function() {
|
||||
it('should lower case the filename', function() {
|
||||
var expectedFilePath = host.useCaseSensitiveFileNames() ? 'SomeFile.ts' : 'somefile.ts';
|
||||
expect(host.getCanonicalFileName('SomeFile.ts')).toEqual(expectedFilePath);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getNewLine', function() {
|
||||
it('should return the newline character for the OS', function() {
|
||||
expect(host.getNewLine()).toEqual(require('os').EOL);
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,49 @@
|
||||
var ts = require('typescript');
|
||||
var LEADING_STAR = /^[^\S\r\n]*\*[^\S\n\r]?/gm;
|
||||
|
||||
module.exports = function getContent() {
|
||||
return function(symbol) {
|
||||
|
||||
var content = "";
|
||||
|
||||
if (!symbol.declarations) return content;
|
||||
|
||||
symbol.declarations.forEach(function(declaration) {
|
||||
|
||||
// If this is left side of dotted module declaration, there is no doc comment associated with this declaration
|
||||
if (declaration.kind === ts.SyntaxKind.ModuleDeclaration && declaration.body.kind === ts.SyntaxKind.ModuleDeclaration) {
|
||||
return content;
|
||||
}
|
||||
|
||||
// If this is dotted module name, get the doc comments from the parent
|
||||
while (declaration.kind === ts.SyntaxKind.ModuleDeclaration && declaration.parent.kind === ts.SyntaxKind.ModuleDeclaration) {
|
||||
declaration = declaration.parent;
|
||||
}
|
||||
|
||||
// If this is a variable declaration then we get the doc comments from the grand parent
|
||||
if (declaration.kind === ts.SyntaxKind.VariableDeclaration) {
|
||||
declaration = declaration.parent.parent;
|
||||
}
|
||||
|
||||
// Get the source file of this declaration
|
||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||
var commentRanges = ts.getJsDocComments(declaration, sourceFile);
|
||||
|
||||
if (commentRanges) {
|
||||
commentRanges.forEach(function(commentRange) {
|
||||
content += sourceFile.text
|
||||
.substring(commentRange.pos+ '/**'.length, commentRange.end - '*/'.length)
|
||||
.replace(LEADING_STAR, '')
|
||||
.trim();
|
||||
if (commentRange.hasTrailingNewLine) {
|
||||
content += '\n';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
content += '\n';
|
||||
});
|
||||
|
||||
return content;
|
||||
};
|
||||
};
|
@ -0,0 +1,34 @@
|
||||
|
||||
module.exports = function getDirectiveInfo() {
|
||||
|
||||
return function (symbol) {
|
||||
var directiveInfo;
|
||||
if (symbol.valueDeclaration) {
|
||||
var decorators = symbol.valueDeclaration.decorators;
|
||||
decorators && decorators.forEach(function(decorator){
|
||||
try {
|
||||
var expr = decorator.expression;
|
||||
var type = expr.expression.text.match(/Component|Directive/);
|
||||
if (type) {
|
||||
// type is either Component or Directive
|
||||
// properties are selector, inputs and outputs
|
||||
directiveInfo = { type: type[0], properties: [] };
|
||||
|
||||
//Directive only takes one argument
|
||||
expr.arguments[0].properties.forEach(function(prop){
|
||||
var name = prop.name.text;
|
||||
if (name === "selector") {
|
||||
directiveInfo.properties.push({name: name, values: prop.initializer.text.split(",")});
|
||||
}
|
||||
if (name === "inputs" || name === "outputs") {
|
||||
var values = prop.initializer.elements.map(function(e){ return e.text });
|
||||
directiveInfo.properties.push({name: name, values: values });
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(e){}
|
||||
});
|
||||
}
|
||||
return directiveInfo;
|
||||
};
|
||||
};
|
@ -0,0 +1,56 @@
|
||||
var ts = require('typescript');
|
||||
|
||||
module.exports = function getExportDocType(log) {
|
||||
|
||||
return function(symbol) {
|
||||
if(symbol.flags & ts.SymbolFlags.FunctionScopedVariable) {
|
||||
return 'var';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.BlockScopedVariable) {
|
||||
return getBlockScopedVariableDocType(symbol);
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.Function) {
|
||||
return 'function';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.Class) {
|
||||
return 'class';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.Interface) {
|
||||
return 'interface';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.ConstEnum) {
|
||||
return 'enum';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.RegularEnum) {
|
||||
return 'enum';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.Property) {
|
||||
return 'module-property';
|
||||
}
|
||||
if(symbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||
return 'type-alias';
|
||||
}
|
||||
|
||||
log.warn('getExportDocType(): Unknown symbol type', {
|
||||
symbolName: symbol.name,
|
||||
symbolType: symbol.flags,
|
||||
symbolTarget: symbol.target,
|
||||
file: ts.getSourceFileOfNode(symbol.declarations[0]).fileName
|
||||
});
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
function getBlockScopedVariableDocType(symbol) {
|
||||
|
||||
var node = symbol.valueDeclaration;
|
||||
while(node) {
|
||||
if ( node.flags & 0x2000 /* const */) {
|
||||
// DefinitelyTyped is still TS 1.4 so const is not allowed.
|
||||
// https://github.com/borisyankov/DefinitelyTyped/issues/4564
|
||||
return 'var'; // change to const when targetting TS 1.5
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
return 'let';
|
||||
}
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
var path = require('canonical-path');
|
||||
var ts = require('typescript');
|
||||
|
||||
module.exports = function getFileInfo(log) {
|
||||
|
||||
return function (symbol, basePath) {
|
||||
var fileName = ts.getSourceFileOfNode(symbol.declarations[0]).fileName;
|
||||
|
||||
var file = path.resolve(basePath, fileName);
|
||||
var fileInfo = {
|
||||
filePath: file,
|
||||
baseName: path.basename(file, path.extname(file)),
|
||||
extension: path.extname(file).replace(/^\./, ''),
|
||||
basePath: basePath,
|
||||
relativePath: fileName,
|
||||
projectRelativePath: fileName
|
||||
};
|
||||
return fileInfo;
|
||||
};
|
||||
};
|
74
scripts/docs/typescript-package/services/tsParser/index.js
Normal file
74
scripts/docs/typescript-package/services/tsParser/index.js
Normal file
@ -0,0 +1,74 @@
|
||||
var ts = require('typescript');
|
||||
var path = require('canonical-path');
|
||||
|
||||
module.exports = function tsParser(createCompilerHost, log) {
|
||||
|
||||
return {
|
||||
|
||||
// These are the extension that we should consider when trying to load a module
|
||||
// During migration from Traceur, there is a mix of `.ts`, `.es6` and `.js` (atScript)
|
||||
// files in the project and the TypeScript compiler only looks for `.ts` files when trying
|
||||
// to load imports.
|
||||
extensions: ['.ts', '.js'],
|
||||
|
||||
// The options for the TS compiler
|
||||
options: {
|
||||
allowNonTsExtensions: true,
|
||||
charset: 'utf8'
|
||||
},
|
||||
|
||||
parse: function(fileNames, baseDir) {
|
||||
|
||||
// "Compile" a program from the given module filenames, to get hold of a
|
||||
// typeChecker that can be used to interrogate the modules, exports and so on.
|
||||
var host = createCompilerHost(this.options, baseDir, this.extensions);
|
||||
var program = ts.createProgram(fileNames, this.options, host);
|
||||
var typeChecker = program.getTypeChecker();
|
||||
|
||||
// Create an array of module symbols for each file we were given
|
||||
var moduleSymbols = [];
|
||||
fileNames.forEach(function(fileName) {
|
||||
var sourceFile = program.getSourceFile(fileName);
|
||||
|
||||
if (!sourceFile) {
|
||||
throw new Error('Invalid source file: ' + fileName);
|
||||
} else if (!sourceFile.symbol) {
|
||||
// Some files contain only a comment and no actual module code
|
||||
log.warn('No module code found in ' + fileName);
|
||||
} else {
|
||||
moduleSymbols.push(sourceFile.symbol);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
moduleSymbols.forEach(function(tsModule) {
|
||||
|
||||
// The type checker has a nice helper function that returns an array of Symbols
|
||||
// representing the exports for a given module
|
||||
tsModule.exportArray = typeChecker.getExportsOfModule(tsModule);
|
||||
|
||||
// Although 'star' imports (e.g. `export * from 'some/module';) get resolved automatically
|
||||
// by the compiler/binder, it seems that explicit imports (e.g. `export {SomeClass} from 'some/module'`)
|
||||
// do not so we have to do a little work.
|
||||
tsModule.exportArray.forEach(function(moduleExport) {
|
||||
if (moduleExport.flags & ts.SymbolFlags.Alias) {
|
||||
// To maintain the alias information (particularly the alias name)
|
||||
// we just attach the original "resolved" symbol to the alias symbol
|
||||
moduleExport.resolvedSymbol = typeChecker.getAliasedSymbol(moduleExport);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
moduleSymbols.typeChecker = typeChecker;
|
||||
|
||||
return {
|
||||
moduleSymbols: moduleSymbols,
|
||||
typeChecker: typeChecker,
|
||||
program: program,
|
||||
host: host
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
var mockPackage = require('../../mocks/mockPackage');
|
||||
var Dgeni = require('dgeni');
|
||||
var path = require('canonical-path');
|
||||
|
||||
describe('tsParser', function() {
|
||||
var dgeni, injector, parser;
|
||||
|
||||
beforeEach(function() {
|
||||
dgeni = new Dgeni([mockPackage()]);
|
||||
injector = dgeni.configureInjector();
|
||||
parser = injector.get('tsParser');
|
||||
});
|
||||
|
||||
it("should parse a TS file", function() {
|
||||
var parseInfo = parser.parse(['testSrc.ts'], path.resolve(__dirname, '../../mocks/tsParser'));
|
||||
var tsModules = parseInfo.moduleSymbols;
|
||||
expect(tsModules.length).toEqual(1);
|
||||
expect(tsModules[0].exportArray.length).toEqual(3);
|
||||
expect(tsModules[0].exportArray.map(function(i) { return i.name; })).toEqual(['MyClass', 'myFn', 'x']);
|
||||
});
|
||||
});
|
44
scripts/docs/update_docs.sh
Normal file
44
scripts/docs/update_docs.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "##### "
|
||||
echo "##### ci/deploy.sh"
|
||||
echo "#####"
|
||||
|
||||
|
||||
function init {
|
||||
cd ..
|
||||
SITE_PATH=$(readJsonProp "config.json" "sitePath")
|
||||
cd ..
|
||||
export IONIC_DIR=$PWD
|
||||
SITE_DIR=$IONIC_DIR/$SITE_PATH
|
||||
}
|
||||
|
||||
function run {
|
||||
./git/clone.sh --repository="driftyco/ionic-site" \
|
||||
--directory="$SITE_DIR" \
|
||||
--branch="master"
|
||||
cd ..
|
||||
VERSION=$(readJsonProp "package.json" "version")
|
||||
|
||||
# process new docs
|
||||
gulp docs
|
||||
|
||||
# CD in to the site dir to commit updated docs
|
||||
cd $SITE_DIR
|
||||
|
||||
CHANGES=$(git status --porcelain)
|
||||
|
||||
# if no changes, don't commit
|
||||
if [[ "$CHANGES" == "" ]]; then
|
||||
ls
|
||||
echo "-- No changes detected in docs for $VERSION_NAME; docs not updated."
|
||||
else
|
||||
git add -A
|
||||
git commit -am "docs: update for $VERSION"
|
||||
git push origin master
|
||||
|
||||
echo "-- Updated docs for $VERSION_NAME succesfully!"
|
||||
fi
|
||||
}
|
||||
|
||||
source $(dirname $0)/../utils.sh.inc
|
244
scripts/utils.sh.inc
Executable file
244
scripts/utils.sh.inc
Executable file
@ -0,0 +1,244 @@
|
||||
# bash utils from angularjs
|
||||
|
||||
# This file provides:
|
||||
# - a default control flow
|
||||
# * initializes the environment
|
||||
# * call a function in your script based on the arguments
|
||||
# - named argument parsing and automatic generation of the "usage" for your script
|
||||
# - utility functions
|
||||
#
|
||||
# Usage:
|
||||
# - define the variable ARGS_DEF (see below) with the arguments for your script
|
||||
# - include this file using `source utils.inc` at the end of your script.
|
||||
#
|
||||
# Default control flow:
|
||||
# 0. Set the current directory to the directory of the script. By this
|
||||
# the script can be called from anywhere.
|
||||
# 1. Parse the named arguments
|
||||
# 2. [Redacted]
|
||||
# 3. If the parameter "verbose" is set, the `-x` flag will be set in bash.
|
||||
# 4. The function "init" will be called if it exists
|
||||
# 5. If the parameter "action" is set, it will call the function with the name of that parameter.
|
||||
# Otherwise the function "run" will be called.
|
||||
#
|
||||
# Named Argument Parsing:
|
||||
# - The variable ARGS_DEF defines the valid command arguments
|
||||
# * Required args syntax: --paramName=paramRegex
|
||||
# * Optional args syntax: [--paramName=paramRegex]
|
||||
# * e.g. ARG_DEFS=("--required_param=(.+)" "[--optional_param=(.+)]")
|
||||
# - Checks that:
|
||||
# * all arguments match to an entry in ARGS_DEF
|
||||
# * all required arguments are present
|
||||
# * all arguments match their regex
|
||||
# - Afterwards, every paramter value will be stored in a variable
|
||||
# with the name of the parameter in upper case (with dash converted to underscore).
|
||||
#
|
||||
# Special arguments that are always available:
|
||||
# - "--action=.*": This parameter will be used to dispatch to a function with that name when the
|
||||
# script is started
|
||||
|
||||
# - "--verbose=true": This will set the `-x` flag in bash so that all calls will be logged
|
||||
#
|
||||
# Utility functions:
|
||||
# - readJsonProp
|
||||
# - replaceJsonProp
|
||||
# - resolveDir
|
||||
# - getVar
|
||||
# - serVar
|
||||
# - isFunction
|
||||
|
||||
# always stop on errors
|
||||
set -e
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} ${ARG_DEFS[@]}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
function parseArgs {
|
||||
local REQUIRED_ARG_NAMES=()
|
||||
|
||||
# -- helper functions
|
||||
function varName {
|
||||
# everything to upper case and dash to underscore
|
||||
echo ${1//-/_} | tr '[:lower:]' '[:upper:]'
|
||||
}
|
||||
|
||||
function readArgDefs {
|
||||
local ARG_DEF
|
||||
local AD_OPTIONAL
|
||||
local AD_NAME
|
||||
local AD_RE
|
||||
|
||||
# -- helper functions
|
||||
function parseArgDef {
|
||||
local ARG_DEF_REGEX="(\[?)--([^=]+)=(.*)"
|
||||
if [[ ! $1 =~ $ARG_DEF_REGEX ]]; then
|
||||
echo "Internal error: arg def has wrong format: $ARG_DEF"
|
||||
exit 1
|
||||
fi
|
||||
AD_OPTIONAL="${BASH_REMATCH[1]}"
|
||||
AD_NAME="${BASH_REMATCH[2]}"
|
||||
AD_RE="${BASH_REMATCH[3]}"
|
||||
if [[ $AD_OPTIONAL ]]; then
|
||||
# Remove last bracket for optional args.
|
||||
# Can't put this into the ARG_DEF_REGEX somehow...
|
||||
AD_RE=${AD_RE%?}
|
||||
fi
|
||||
}
|
||||
|
||||
# -- run
|
||||
for ARG_DEF in "${ARG_DEFS[@]}"
|
||||
do
|
||||
parseArgDef $ARG_DEF
|
||||
|
||||
local AD_NAME_UPPER=$(varName $AD_NAME)
|
||||
setVar "${AD_NAME_UPPER}_OPTIONAL" "$AD_OPTIONAL"
|
||||
setVar "${AD_NAME_UPPER}_RE" "$AD_RE"
|
||||
if [[ ! $AD_OPTIONAL ]]; then
|
||||
REQUIRED_ARG_NAMES+=($AD_NAME)
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function readAndValidateArgs {
|
||||
local ARG_NAME
|
||||
local ARG_VALUE
|
||||
local ARG_NAME_UPPER
|
||||
|
||||
# -- helper functions
|
||||
function parseArg {
|
||||
local ARG_REGEX="--([^=]+)=?(.*)"
|
||||
|
||||
if [[ ! $1 =~ $ARG_REGEX ]]; then
|
||||
echo "Can't parse argument $i"
|
||||
usage
|
||||
fi
|
||||
|
||||
ARG_NAME="${BASH_REMATCH[1]}"
|
||||
ARG_VALUE="${BASH_REMATCH[2]}"
|
||||
ARG_NAME_UPPER=$(varName $ARG_NAME)
|
||||
}
|
||||
|
||||
function validateArg {
|
||||
local AD_RE=$(getVar ${ARG_NAME_UPPER}_RE)
|
||||
|
||||
if [[ ! $AD_RE ]]; then
|
||||
echo "Unknown option: $ARG_NAME"
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ! $ARG_VALUE =~ ^${AD_RE}$ ]]; then
|
||||
echo "Wrong format: $ARG_NAME"
|
||||
usage;
|
||||
fi
|
||||
|
||||
# validate that the "action" option points to a valid function
|
||||
if [[ $ARG_NAME == "action" ]] && ! isFunction $ARG_VALUE; then
|
||||
echo "No action $ARG_VALUE defined in this script"
|
||||
usage;
|
||||
fi
|
||||
}
|
||||
|
||||
# -- run
|
||||
for i in "$@"
|
||||
do
|
||||
parseArg $i
|
||||
validateArg
|
||||
setVar "${ARG_NAME_UPPER}" "$ARG_VALUE"
|
||||
done
|
||||
}
|
||||
|
||||
function checkMissingArgs {
|
||||
local ARG_NAME
|
||||
for ARG_NAME in "${REQUIRED_ARG_NAMES[@]}"
|
||||
do
|
||||
ARG_VALUE=$(getVar $(varName $ARG_NAME))
|
||||
|
||||
if [[ ! $ARG_VALUE ]]; then
|
||||
echo "Missing: $ARG_NAME"
|
||||
usage;
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# -- run
|
||||
readArgDefs
|
||||
readAndValidateArgs "$@"
|
||||
checkMissingArgs
|
||||
|
||||
}
|
||||
|
||||
# getVar(varName)
|
||||
function getVar {
|
||||
echo ${!1}
|
||||
}
|
||||
|
||||
# setVar(varName, varValue)
|
||||
function setVar {
|
||||
eval "$1=\"$2\""
|
||||
}
|
||||
|
||||
# isFunction(name)
|
||||
# - to be used in an if, so return 0 if successful and 1 if not!
|
||||
function isFunction {
|
||||
if [[ $(type -t $1) == "function" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# readJsonProp(jsonFile, property)
|
||||
# - restriction: property needs to be on an own line!
|
||||
function readJsonProp {
|
||||
echo $(sed -En 's/.*"'$2'"[ ]*:[ ]*"(.*)".*/\1/p' $1)
|
||||
}
|
||||
|
||||
# replaceJsonProp(jsonFile, property, newValue)
|
||||
# - note: propertyRegex will be automatically placed into a
|
||||
# capturing group! -> all other groups start at index 2!
|
||||
function replaceJsonProp {
|
||||
replaceInFile $1 "\"$2\": \".*?\"" "\"$2\": \"$3\""
|
||||
}
|
||||
|
||||
# replaceInFile(file, findPattern, replacePattern)
|
||||
function replaceInFile {
|
||||
perl -pi -e "s/$2/$3/g;" $1
|
||||
}
|
||||
|
||||
# resolveDir(relativeDir)
|
||||
# - resolves a directory relative to the current script
|
||||
function resolveDir {
|
||||
echo $(cd $SCRIPT_DIR; cd $1; pwd)
|
||||
}
|
||||
|
||||
function main {
|
||||
# normalize the working dir to the directory of the script
|
||||
cd $(dirname $0);SCRIPT_DIR=$(pwd)
|
||||
|
||||
ARG_DEFS+=("[--verbose=(true|false)]")
|
||||
parseArgs "$@"
|
||||
|
||||
|
||||
# --verbose argument
|
||||
if [[ $VERBOSE == "true" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if isFunction init; then
|
||||
init "$@"
|
||||
fi
|
||||
|
||||
# jump to the function denoted by the --action argument,
|
||||
# otherwise call the "run" function
|
||||
if [[ $ACTION ]]; then
|
||||
$ACTION "$@"
|
||||
else
|
||||
run "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main "$@"
|
@ -1,5 +1,20 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
/**
|
||||
* Take a photo or capture video.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
|
||||
*
|
||||
* @usage
|
||||
* ```js
|
||||
* Camera.getPicture(options).then((imageData) => {
|
||||
* // imageData is either a base64 encoded string or a file URI
|
||||
* // If it's base64:
|
||||
* let base64Image = "data:image/jpeg;base64," + imageData;
|
||||
* }, (err) => {
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
name: 'Camera',
|
||||
plugin: 'cordova-plugin-camera',
|
||||
|
@ -1,5 +1,23 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
/**
|
||||
* Access and manage Contacts on the device.
|
||||
*
|
||||
* Requires plugin: `cordova-plugin-contacts`
|
||||
* For full info, please see the [Cordova Contacts Docs](https://github.com/apache/cordova-plugin-contacts)
|
||||
*
|
||||
* @usage
|
||||
*
|
||||
* ```js
|
||||
* Contacts.save({
|
||||
* displayName: "Mr. Ionitron"
|
||||
* }).then((contact) => {}, (err) => {})
|
||||
* ```
|
||||
*
|
||||
* See the `save()` docs for a full list of fields.
|
||||
*
|
||||
*/
|
||||
|
||||
@Plugin({
|
||||
name: 'Contacts',
|
||||
plugin: 'cordova-plugin-contacts',
|
||||
@ -11,6 +29,32 @@ export class Contacts {
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
|
||||
/**
|
||||
* Save a contact into the contacts database.
|
||||
*
|
||||
* Valid fields:
|
||||
* {
|
||||
* id: A globally unique identifier. (DOMString)
|
||||
* displayName: The name of this Contact, suitable for display to end-users. (DOMString)
|
||||
* name: An object containing all components of a persons name. (ContactName)
|
||||
* nickname: A casual name by which to address the contact. (DOMString)
|
||||
* phoneNumbers: An array of all the contact's phone numbers. (ContactField[])
|
||||
* emails: An array of all the contact's email addresses. (ContactField[])
|
||||
* addresses: An array of all the contact's addresses. (ContactAddress[])
|
||||
* ims: An array of all the contact's IM addresses. (ContactField[])
|
||||
* organizations: An array of all the contact's organizations. (ContactOrganization[])
|
||||
* birthday: The birthday of the contact. (Date)
|
||||
* note: A note about the contact. (DOMString)
|
||||
* photos: An array of the contact's photos. (ContactField[])
|
||||
* categories: An array of all the user-defined categories associated with the contact. (ContactField[])
|
||||
* urls: An array of web pages associated with the contact. (ContactField[])
|
||||
* }
|
||||
*
|
||||
* @param contact {object} the contact to save.
|
||||
* @return {Promise} that resolves with the created and saved contact
|
||||
*/
|
||||
|
||||
// This method is create(fields, success, error, options) :/
|
||||
static create(fields:string[], options:any){};
|
||||
|
||||
@ -18,6 +62,21 @@ export class Contacts {
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
|
||||
/**
|
||||
* Search for contacts in the Contacts list.
|
||||
*
|
||||
* Example: Contacts.find({ filter: 'Max' }) // will search for a displayName of 'Max'
|
||||
*
|
||||
* @param options the options to query with
|
||||
*
|
||||
* filter: The search string used to find navigator.contacts. (DOMString) (Default: "")
|
||||
* multiple: Determines if the find operation returns multiple navigator.contacts. (Boolean) (Default: false)
|
||||
* desiredFields: Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. (DOMString[]) [Optional]
|
||||
* hasPhoneNumber(Android only): Filters the search to only return contacts with a phone number informed. (Boolean) (Default: false)
|
||||
*
|
||||
* @return {Promise} that resolves with the search results
|
||||
*/
|
||||
static find(fields:string[], options:any){};
|
||||
|
||||
@Cordova()
|
||||
|
@ -2,13 +2,29 @@ import {Plugin, RequiresPlugin} from './plugin';
|
||||
|
||||
declare var window;
|
||||
|
||||
|
||||
/**
|
||||
* Access information about the underlying device and platform.
|
||||
*
|
||||
* @usage
|
||||
* ```js
|
||||
* let info = Device.getDevice();
|
||||
* // Device sits below
|
||||
* ```
|
||||
*/
|
||||
|
||||
@Plugin({
|
||||
name: 'Device',
|
||||
plugin: 'cordova-plugin-device',
|
||||
pluginRef: 'device'
|
||||
})
|
||||
export class Device {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the whole device object.
|
||||
* @see https://github.com/apache/cordova-plugin-device
|
||||
* @returns {Object} The device object.
|
||||
*/
|
||||
@RequiresPlugin
|
||||
static getDevice() {
|
||||
return window.device;
|
||||
|
@ -4,6 +4,24 @@ declare var Promise;
|
||||
|
||||
declare var window;
|
||||
|
||||
|
||||
/**
|
||||
* Get geolocation data.
|
||||
*
|
||||
* @usage
|
||||
* ```js
|
||||
* Geolocation.getCurrentPosition().then((resp) => {
|
||||
* //resp.coords.latitude
|
||||
* //resp.coords.longitude
|
||||
* })
|
||||
*
|
||||
* let watch = Geolocation.watchPosition();
|
||||
* watch.source.subscribe((data) => {
|
||||
* //data.coords.latitude
|
||||
* //data.coords.longitude
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
name: 'Geolocation',
|
||||
plugin: 'cordova-plugin-geolocation',
|
||||
|
@ -1,27 +1,82 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
|
||||
/**
|
||||
* Manage the appearance of the native status bar.
|
||||
*
|
||||
* @usage
|
||||
* ```js
|
||||
* StatusBar.hide(); // Hide the bar
|
||||
*
|
||||
* StatusBar.setStyle(StatusBar.LIGHT_CONTENT) // Good for dark backgrounds
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
name: 'StatusBar',
|
||||
plugin: 'cordova-plugin-statusbar',
|
||||
pluginRef: 'StatusBar'
|
||||
})
|
||||
export class StatusBar {
|
||||
/**
|
||||
* Set whether the status bar overlays the main app view. The default
|
||||
* is true.
|
||||
*
|
||||
* @param doesOverlay whether the status bar overlays the main app view.
|
||||
*/
|
||||
@Cordova()
|
||||
static overlaysWebView(doOverlay:boolean){};
|
||||
|
||||
@Cordova()
|
||||
static styleDefault(){};
|
||||
|
||||
@Cordova()
|
||||
static styleLightContent(){};
|
||||
|
||||
@Cordova()
|
||||
static styleBlackTranslucent(){};
|
||||
|
||||
@Cordova()
|
||||
static styleBlackOpaque(){};
|
||||
|
||||
/**
|
||||
* Set the status bar to a specific named color. Valid options:
|
||||
* black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown.
|
||||
*
|
||||
* iOS note: you must call StatusBar.setOverlay(false) to enable color changing.
|
||||
*
|
||||
* @param name the name of the color (from above)
|
||||
*/
|
||||
@Cordova()
|
||||
static backgroundColorByName(colorName:string){};
|
||||
|
||||
/**
|
||||
* Set the status bar to a specific hex color (CSS shorthand supported!).
|
||||
*
|
||||
* iOS note: you must call StatusBar.setOverlay(false) to enable color changing.
|
||||
*
|
||||
* @param hex the hex value of the color.
|
||||
*/
|
||||
@Cordova()
|
||||
static backgroundColorByHexString(hexString:string){};
|
||||
|
||||
/**
|
||||
* Hide the StatusBar
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* StatusBar.DEFAULT
|
||||
* StatusBar.LIGHT_CONTENT
|
||||
* StatusBar.BLACK_TRANSLUCENT
|
||||
* StatusBar.BLACK_OPAQUE
|
||||
*
|
||||
* @param style the style from above
|
||||
*/
|
||||
@Cordova()
|
||||
static hide(){};
|
||||
|
||||
/**
|
||||
* Show the StatusBar
|
||||
*/
|
||||
@Cordova()
|
||||
static show(){};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user