diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..782bf010 --- /dev/null +++ b/circle.yml @@ -0,0 +1,9 @@ +test: + override: + - echo "Skipping tests for now" + +deployment: + staging: + branch: master + commands: + - ./scripts/docs/update_docs.sh diff --git a/dist/src/plugins/actionsheet.js b/dist/src/plugins/actionsheet.js index d638c129..012678da 100644 --- a/dist/src/plugins/actionsheet.js +++ b/dist/src/plugins/actionsheet.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/actionsheet.js.map b/dist/src/plugins/actionsheet.js.map index 3c8c16b2..69c1314f 100644 --- a/dist/src/plugins/actionsheet.js.map +++ b/dist/src/plugins/actionsheet.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/plugins/camera.js b/dist/src/plugins/camera.js index f6072b2e..d7f7880c 100644 --- a/dist/src/plugins/camera.js +++ b/dist/src/plugins/camera.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/camera.js.map b/dist/src/plugins/camera.js.map index e651bb48..3cdfed5c 100644 --- a/dist/src/plugins/camera.js.map +++ b/dist/src/plugins/camera.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/plugins/contacts.js b/dist/src/plugins/contacts.js index 6c472824..93df3e69 100644 --- a/dist/src/plugins/contacts.js +++ b/dist/src/plugins/contacts.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/contacts.js.map b/dist/src/plugins/contacts.js.map index 01b1423f..17be0d52 100644 --- a/dist/src/plugins/contacts.js.map +++ b/dist/src/plugins/contacts.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/plugins/device.js b/dist/src/plugins/device.js index fef6fb92..987fc238 100644 --- a/dist/src/plugins/device.js +++ b/dist/src/plugins/device.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/device.js.map b/dist/src/plugins/device.js.map index c989c738..c8f71afd 100644 --- a/dist/src/plugins/device.js.map +++ b/dist/src/plugins/device.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/plugins/geolocation.js b/dist/src/plugins/geolocation.js index 50d5703a..bc84658b 100644 --- a/dist/src/plugins/geolocation.js +++ b/dist/src/plugins/geolocation.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/geolocation.js.map b/dist/src/plugins/geolocation.js.map index 8ad75cb6..c72aa7b5 100644 --- a/dist/src/plugins/geolocation.js.map +++ b/dist/src/plugins/geolocation.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/plugins/statusbar.js b/dist/src/plugins/statusbar.js index 956f413b..ce4cf528 100644 --- a/dist/src/plugins/statusbar.js +++ b/dist/src/plugins/statusbar.js @@ -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 \ No newline at end of file diff --git a/dist/src/plugins/statusbar.js.map b/dist/src/plugins/statusbar.js.map index 7ca3d12f..3d5e0cd3 100644 --- a/dist/src/plugins/statusbar.js.map +++ b/dist/src/plugins/statusbar.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..55d9f4af --- /dev/null +++ b/gulpfile.js @@ -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); diff --git a/package.json b/package.json index 12dc7c83..466f606a 100644 --- a/package.json +++ b/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", diff --git a/scripts/config.json b/scripts/config.json new file mode 100644 index 00000000..7e6e9ff4 --- /dev/null +++ b/scripts/config.json @@ -0,0 +1,5 @@ +{ + "sitePath": "../ionic-site", + "v2DocsDir": "docs/v2/platform", + "docsDest": "../ionic-site/docs/v2/platform" +} diff --git a/scripts/docs/deploy.sh b/scripts/docs/deploy.sh new file mode 100755 index 00000000..855cc1dd --- /dev/null +++ b/scripts/docs/deploy.sh @@ -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 diff --git a/scripts/docs/dgeni-config.js b/scripts/docs/dgeni-config.js new file mode 100644 index 00000000..2281a052 --- /dev/null +++ b/scripts/docs/dgeni-config.js @@ -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' + ]; +}); + +}; diff --git a/scripts/docs/filters/capital.js b/scripts/docs/filters/capital.js new file mode 100644 index 00000000..f63edd91 --- /dev/null +++ b/scripts/docs/filters/capital.js @@ -0,0 +1,7 @@ +module.exports = { + name: 'capital', + process: function(str) { + str || (str = ''); + return str.charAt(0).toUpperCase() + str.substring(1); + } +}; diff --git a/scripts/docs/filters/code.js b/scripts/docs/filters/code.js new file mode 100644 index 00000000..d0eaee27 --- /dev/null +++ b/scripts/docs/filters/code.js @@ -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 = '' + str + ''; + + // If not inline then wrap the code element in a pre element + if ( !inline ) { + str = '
' + str + '
'; + } + + return str; +}; + +module.exports = { + name: 'code', + process: function(str, lang) { + return code(str, true, lang); + } +}; diff --git a/scripts/docs/filters/dump.js b/scripts/docs/filters/dump.js new file mode 100644 index 00000000..155a01e8 --- /dev/null +++ b/scripts/docs/filters/dump.js @@ -0,0 +1,6 @@ +module.exports = { + name: 'dump', + process: function(obj) { + console.log(obj); + } +}; \ No newline at end of file diff --git a/scripts/docs/gulp-tasks.js b/scripts/docs/gulp-tasks.js new file mode 100644 index 00000000..19d24658 --- /dev/null +++ b/scripts/docs/gulp-tasks.js @@ -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); + } + }); +} diff --git a/scripts/docs/links-package/index.js b/scripts/docs/links-package/index.js new file mode 100644 index 00000000..a3ffc719 --- /dev/null +++ b/scripts/docs/links-package/index.js @@ -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); +}); diff --git a/scripts/docs/links-package/inline-tag-defs/link.js b/scripts/docs/links-package/inline-tag-defs/link.js new file mode 100644 index 00000000..89272c63 --- /dev/null +++ b/scripts/docs/links-package/inline-tag-defs/link.js @@ -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 "" + linkInfo.title + ""; + }); + } + }; +}; \ No newline at end of file diff --git a/scripts/docs/links-package/services/getLinkInfo.js b/scripts/docs/links-package/services/getLinkInfo.js new file mode 100644 index 00000000..787ff043 --- /dev/null +++ b/scripts/docs/links-package/services/getLinkInfo.js @@ -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; + }; +}; \ No newline at end of file diff --git a/scripts/docs/processors/hide-private-api.js b/scripts/docs/processors/hide-private-api.js new file mode 100644 index 00000000..15e2b6eb --- /dev/null +++ b/scripts/docs/processors/hide-private-api.js @@ -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; + } + } +}; diff --git a/scripts/docs/processors/jekyll.js b/scripts/docs/processors/jekyll.js new file mode 100644 index 00000000..e0e02000 --- /dev/null +++ b/scripts/docs/processors/jekyll.js @@ -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; + } + }; +}; diff --git a/scripts/docs/processors/latest-version.js b/scripts/docs/processors/latest-version.js new file mode 100644 index 00000000..ca10b460 --- /dev/null +++ b/scripts/docs/processors/latest-version.js @@ -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; + } + } +}; diff --git a/scripts/docs/processors/remove-private-members.js b/scripts/docs/processors/remove-private-members.js new file mode 100644 index 00000000..1762c11e --- /dev/null +++ b/scripts/docs/processors/remove-private-members.js @@ -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; + } + } +}; diff --git a/scripts/docs/tag-defs/tag-defs.js b/scripts/docs/tag-defs/tag-defs.js new file mode 100644 index 00000000..ca0dabb3 --- /dev/null +++ b/scripts/docs/tag-defs/tag-defs.js @@ -0,0 +1,4 @@ +module.exports = [ + {'name': 'demo'}, + {'name': 'usage'} +]; diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html new file mode 100644 index 00000000..aa71fe04 --- /dev/null +++ b/scripts/docs/templates/common.template.html @@ -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 -@>( + <@- for param in paramData -@> + <$ param | escape $><@ if not loop.last @>, <@ endif @> + <@- endfor @>) + <@- endif @> +<@- endmacro -@> + +<@ macro githubViewLink(doc) -@> + <$ doc.fileInfo.relativePath $> (line <$ doc.location.start.line+1 $>) +<@- endmacro -@> + +<@ macro paramTable(params, isDirective) -@> + + + + + + + + + + <@ for param in params @> + + + + + + <@ endfor @> + +
<@ if isDirective @>Attr<@ else @>Param<@ endif @>TypeDetails
+ <$ param.name $> + <@ if param.alias @>| <$ param.alias $><@ endif @> + <@ if param.type.optional @>
(optional)
<@ endif @> +
+ <$ typeList(param.typeList) $> + + <$ param.description | marked $> + <@ if param.default @>

(default: <$ param.default $>)

<@ endif @> +
+<@- endmacro -@> + + +<@- macro functionSyntax(fn) @> + <@- set sep = joiner(', ') -@> + <$ fn.name $>(<@- for param in fn.params @><$ sep() $> + <@- if param.type.optional @>[<@ endif -@> + <$ param.name $> + <@- if param.type.optional @>]<@ endif -@> + <@ endfor @>) + <@ if fn.alias @>(alias: <$ fn.alias $>)<@ 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 @> + +

+ +<@ if doc.docType == "directive" @> +<$ doc.name | dashCase $> +<@ else @> +<$ doc.name $> +<@ endif @> + +<@ if doc.parent @> +
+ +Child of <$ doc.parent $> + +<@ endif @> + +<@ if doc.delegate @> +
+ +Delegate: <$ doc.delegate $> + +<@ endif @> + +

+ + +Improve this doc + + +<@ if doc.codepen @> +{% include codepen.html id="<$ doc.codepen $>" %} +<@ endif @> + +<@ endblock @> + + + +

Description

+<@ block description @> +<$ doc.description | marked $> +<@ endblock @> + + +<@- if doc.directiveInfo @> +

<$ doc.directiveInfo.type $>

+

<$ doc.directiveInfo.properties[0].name $>: <$ doc.directiveInfo.properties[0].values $>

+<@ endif -@> + + +<@ if doc.usage @> +

Usage

+<@ block usage @> +<$ doc.usage | marked $> +<@ endblock @> +<@ endif @> + + +<@ if doc.properties @> +

Attributes:

+ + + + + +<@ set hasTypes = false @> +<@ for prop in doc.properties @> +<@ if prop.type @> +<@ set hasTypes = true @> +<@ endif @> +<@ endfor @> +<@ if hasTypes @> + +<@ endif @> + + + + + +<@ for prop in doc.properties @> + + + +<@ if hasTypes @> + +<@ endif @> + + + +<@ endfor @> + +
AttributeTypeDescription
+<$ prop.name $> + +<$ prop.type.name $> + +<$ prop.description $> +
+<@ endif @> + + +<@- if doc.members and doc.members.length @> + +

Methods

+<@- for method in doc.members @> + +
+ +

+<$ functionSyntax(method) $> +

+ +<$ method.description $> + +<@ if method.params @> +<$ paramTable(method.params) $> +<@ endif @> + +<@ if method.this @> +

Method's `this` +<$ method.this $> +

+<@ endif @> + +<@ if method.returns @> +
+ +Returns: <$ typeInfo(method.returns) $> +
+<@ endif @> + +<@ endfor -@> + +<@- endif -@> + + +<@- if doc.see @> + +

Related

+<@ for s in doc.see @> +<$ s | safe $> +<@- endfor -@> + +<@- endif -@> + + + +<@ endblock @> + + +<@ endblock @> diff --git a/scripts/docs/templates/platform_menu.template.html b/scripts/docs/templates/platform_menu.template.html new file mode 100644 index 00000000..b91368ad --- /dev/null +++ b/scripts/docs/templates/platform_menu.template.html @@ -0,0 +1,4 @@ +<@ for doc in docs @><@ if doc.URL and doc.private != true @> +
  • + <$ doc.name $> +
  • <@ endif @><@ endfor @> diff --git a/scripts/docs/typescript-definition-package/index.js b/scripts/docs/typescript-definition-package/index.js new file mode 100644 index 00000000..532cfe5d --- /dev/null +++ b/scripts/docs/typescript-definition-package/index.js @@ -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' + ]; +}); \ No newline at end of file diff --git a/scripts/docs/typescript-definition-package/mocks/mockPackage.js b/scripts/docs/typescript-definition-package/mocks/mockPackage.js new file mode 100644 index 00000000..69230910 --- /dev/null +++ b/scripts/docs/typescript-definition-package/mocks/mockPackage.js @@ -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 {}; }); + +}; diff --git a/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.js b/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.js new file mode 100644 index 00000000..f3bc002c --- /dev/null +++ b/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.js @@ -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; + }); + } + }; +}; diff --git a/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.spec.js b/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.spec.js new file mode 100644 index 00000000..1bf15092 --- /dev/null +++ b/scripts/docs/typescript-definition-package/processors/createTypeDefinitionFile.spec.js @@ -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'); + }); + }); + +}); \ No newline at end of file diff --git a/scripts/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html b/scripts/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html new file mode 100644 index 00000000..ce9778bf --- /dev/null +++ b/scripts/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html @@ -0,0 +1,17 @@ +{% extends '../type-definition.template.html' %} +{% block staticDeclarations %} + +interface List extends Array {} +interface Map {} +interface StringMap extends Map {} + +declare module ng { + // See https://github.com/Microsoft/TypeScript/issues/1168 + class BaseException /* extends Error */ { + message: string; + stack: string; + toString(): string; + } + interface InjectableReference {} +} +{% endblock %} diff --git a/scripts/docs/typescript-definition-package/templates/type-definition.template.html b/scripts/docs/typescript-definition-package/templates/type-definition.template.html new file mode 100644 index 00000000..4ebceffa --- /dev/null +++ b/scripts/docs/typescript-definition-package/templates/type-definition.template.html @@ -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 +// 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; +} diff --git a/scripts/docs/typescript-package/index.js b/scripts/docs/typescript-package/index.js new file mode 100644 index 00000000..d31dc774 --- /dev/null +++ b/scripts/docs/typescript-package/index.js @@ -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' + }); + +}); diff --git a/scripts/docs/typescript-package/mocks/mockPackage.js b/scripts/docs/typescript-package/mocks/mockPackage.js new file mode 100644 index 00000000..834d53c9 --- /dev/null +++ b/scripts/docs/typescript-package/mocks/mockPackage.js @@ -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 {}; }); + +}; diff --git a/scripts/docs/typescript-package/mocks/readTypeScriptModules/ignoreExportsMatching.ts b/scripts/docs/typescript-package/mocks/readTypeScriptModules/ignoreExportsMatching.ts new file mode 100644 index 00000000..476d4cc4 --- /dev/null +++ b/scripts/docs/typescript-package/mocks/readTypeScriptModules/ignoreExportsMatching.ts @@ -0,0 +1,4 @@ +export var __esModule = true; +export class OKToExport {} +export function _thisIsPrivate() {} +export var thisIsOK = '!'; \ No newline at end of file diff --git a/scripts/docs/typescript-package/mocks/readTypeScriptModules/interfaces.ts b/scripts/docs/typescript-package/mocks/readTypeScriptModules/interfaces.ts new file mode 100644 index 00000000..a2d4be4f --- /dev/null +++ b/scripts/docs/typescript-package/mocks/readTypeScriptModules/interfaces.ts @@ -0,0 +1,5 @@ +export interface MyInterface { + optionalProperty? : string + >(param: T) : U + new (param: number) : MyInterface +} \ No newline at end of file diff --git a/scripts/docs/typescript-package/mocks/readTypeScriptModules/orderingOfMembers.ts b/scripts/docs/typescript-package/mocks/readTypeScriptModules/orderingOfMembers.ts new file mode 100644 index 00000000..2020ec7f --- /dev/null +++ b/scripts/docs/typescript-package/mocks/readTypeScriptModules/orderingOfMembers.ts @@ -0,0 +1,6 @@ +export class Test { + firstItem; + constructor() { this.doStuff(); } + otherMethod() {} + doStuff() {} +} \ No newline at end of file diff --git a/scripts/docs/typescript-package/mocks/tsParser/importedSrc.ts b/scripts/docs/typescript-package/mocks/tsParser/importedSrc.ts new file mode 100644 index 00000000..74a115e5 --- /dev/null +++ b/scripts/docs/typescript-package/mocks/tsParser/importedSrc.ts @@ -0,0 +1 @@ +export var x = 100; \ No newline at end of file diff --git a/scripts/docs/typescript-package/mocks/tsParser/testSrc.ts b/scripts/docs/typescript-package/mocks/tsParser/testSrc.ts new file mode 100644 index 00000000..7b6d3f18 --- /dev/null +++ b/scripts/docs/typescript-package/mocks/tsParser/testSrc.ts @@ -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; \ No newline at end of file diff --git a/scripts/docs/typescript-package/processors/readTypeScriptModules.js b/scripts/docs/typescript-package/processors/readTypeScriptModules.js new file mode 100644 index 00000000..b8243b98 --- /dev/null +++ b/scripts/docs/typescript-package/processors/readTypeScriptModules.js @@ -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 -> List + 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']); + 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; }); +} \ No newline at end of file diff --git a/scripts/docs/typescript-package/services/modules.js b/scripts/docs/typescript-package/services/modules.js new file mode 100644 index 00000000..76013902 --- /dev/null +++ b/scripts/docs/typescript-package/services/modules.js @@ -0,0 +1,3 @@ +module.exports = function modules() { + return {}; +}; diff --git a/scripts/docs/typescript-package/services/tsParser/createCompilerHost.js b/scripts/docs/typescript-package/services/tsParser/createCompilerHost.js new file mode 100644 index 00000000..0dc488b0 --- /dev/null +++ b/scripts/docs/typescript-package/services/tsParser/createCompilerHost.js @@ -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 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 "$@" diff --git a/src/plugins/camera.ts b/src/plugins/camera.ts index a79c76f6..8a4e7305 100644 --- a/src/plugins/camera.ts +++ b/src/plugins/camera.ts @@ -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', diff --git a/src/plugins/contacts.ts b/src/plugins/contacts.ts index 1393716f..e81487ff 100644 --- a/src/plugins/contacts.ts +++ b/src/plugins/contacts.ts @@ -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() diff --git a/src/plugins/device.ts b/src/plugins/device.ts index b29fe901..b4974db7 100644 --- a/src/plugins/device.ts +++ b/src/plugins/device.ts @@ -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; diff --git a/src/plugins/geolocation.ts b/src/plugins/geolocation.ts index 3cd08094..96845905 100644 --- a/src/plugins/geolocation.ts +++ b/src/plugins/geolocation.ts @@ -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', diff --git a/src/plugins/statusbar.ts b/src/plugins/statusbar.ts index c1a2154d..e50e23e4 100644 --- a/src/plugins/statusbar.ts +++ b/src/plugins/statusbar.ts @@ -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(){}; }