From ead99b1a4fc89130fb6e59963f0903c96349085f Mon Sep 17 00:00:00 2001
From: Ibby
Date: Thu, 23 Mar 2017 22:07:59 -0400
Subject: [PATCH] chore(docs): cleanup + es6
---
gulpfile.js | 41 ++--
scripts/docs/configs/links.js | 3 +
scripts/docs/configs/log.js | 3 +
scripts/docs/configs/tag-defs.js | 4 +
scripts/docs/configs/template-filters.js | 12 +
scripts/docs/configs/template-tags.js | 9 +
scripts/docs/dgeni-config.js | 215 +++++-------------
scripts/docs/dgeni-readmes-config.js | 164 +++----------
scripts/docs/filters/capital.js | 6 +-
scripts/docs/filters/code.js | 11 +-
scripts/docs/filters/dashify.js | 6 +-
scripts/docs/filters/dump.js | 7 +-
scripts/docs/gulp-tasks.js | 44 ++--
.../docs/processors/collect-inputs-outputs.js | 71 ------
scripts/docs/processors/debug.js | 43 ++++
scripts/docs/processors/hide-private-api.js | 15 +-
scripts/docs/processors/jekyll.js | 32 ++-
scripts/docs/processors/latest-version.js | 33 ---
scripts/docs/processors/npm-id.js | 9 +-
scripts/docs/processors/parse-optional.js | 15 +-
scripts/docs/processors/readmes.js | 12 +-
.../docs/processors/remove-private-members.js | 13 +-
scripts/docs/tag-defs/tag-defs.js | 6 +-
scripts/docs/templates/common.template.html | 203 ++++++-----------
24 files changed, 321 insertions(+), 656 deletions(-)
create mode 100644 scripts/docs/configs/links.js
create mode 100644 scripts/docs/configs/log.js
create mode 100644 scripts/docs/configs/tag-defs.js
create mode 100644 scripts/docs/configs/template-filters.js
create mode 100644 scripts/docs/configs/template-tags.js
delete mode 100644 scripts/docs/processors/collect-inputs-outputs.js
create mode 100644 scripts/docs/processors/debug.js
delete mode 100644 scripts/docs/processors/latest-version.js
diff --git a/gulpfile.js b/gulpfile.js
index 3cd607b11..82bb2d2be 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,32 +1,35 @@
-var gulp = require('gulp');
-var minimist = require('minimist');
-var rename = require("gulp-rename");
-var tslint = require('gulp-tslint');
-var decamelize = require('decamelize');
-var replace = require('gulp-replace');
+"use strict";
-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);
+const gulp = require('gulp'),
+ minimist = require('minimist'),
+ rename = require("gulp-rename"),
+ tslint = require('gulp-tslint'),
+ decamelize = require('decamelize'),
+ replace = require('gulp-replace');
+
+const flagConfig = {
+ string: ['port', 'version', 'ngVersion', 'animations'],
+ boolean: ['dry-run'],
+ alias: {'p': 'port', 'v': 'version', 'a': 'ngVersion'},
+ default: { port: 8000 }
+ },
+
+ flags = minimist(process.argv.slice(2), flagConfig);
/* Docs tasks */
require('./scripts/docs/gulp-tasks')(gulp, flags);
-gulp.task('lint', function() {
- gulp.src('src/**/*.ts')
+gulp.task('lint', () => {
+ return gulp.src('src/**/*.ts')
.pipe(tslint({
formatter: "verbose",
configuration: 'tslint.json'
}))
- .pipe(tslint.report())
+ .pipe(tslint.report());
});
-gulp.task('plugin:create', function(){
- if(flags.n && flags.n !== ''){
+gulp.task('plugin:create', () => {
+ if (flags.n && flags.n !== ''){
const src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl',
pluginName = flags.n,
@@ -40,8 +43,6 @@ gulp.task('plugin:create', function(){
.pipe(gulp.dest('./src/@ionic-native/plugins/' + pluginPackageName));
} else {
-
console.log("Usage is: gulp plugin:create -n PluginName");
-
}
});
diff --git a/scripts/docs/configs/links.js b/scripts/docs/configs/links.js
new file mode 100644
index 000000000..65c8aa897
--- /dev/null
+++ b/scripts/docs/configs/links.js
@@ -0,0 +1,3 @@
+module.exports = function(getLinkInfo) {
+ getLinkInfo.useFirstAmbiguousLink = false;
+};
diff --git a/scripts/docs/configs/log.js b/scripts/docs/configs/log.js
new file mode 100644
index 000000000..91d24552f
--- /dev/null
+++ b/scripts/docs/configs/log.js
@@ -0,0 +1,3 @@
+module.exports = function(log) {
+ log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
+};
diff --git a/scripts/docs/configs/tag-defs.js b/scripts/docs/configs/tag-defs.js
new file mode 100644
index 000000000..b7a49c6d9
--- /dev/null
+++ b/scripts/docs/configs/tag-defs.js
@@ -0,0 +1,4 @@
+module.exports = function(parseTagsProcessor) {
+ parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions
+ .concat(require('../tag-defs/tag-defs'));
+};
diff --git a/scripts/docs/configs/template-filters.js b/scripts/docs/configs/template-filters.js
new file mode 100644
index 000000000..6d5ea1c11
--- /dev/null
+++ b/scripts/docs/configs/template-filters.js
@@ -0,0 +1,12 @@
+module.exports = function(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: '#>'
+ };
+};
diff --git a/scripts/docs/configs/template-tags.js b/scripts/docs/configs/template-tags.js
new file mode 100644
index 000000000..e2297158c
--- /dev/null
+++ b/scripts/docs/configs/template-tags.js
@@ -0,0 +1,9 @@
+module.exports = function(templateEngine) {
+ // add custom filters to nunjucks
+ templateEngine.filters.push(
+ require('../filters/capital'),
+ require('../filters/code'),
+ require('../filters/dump'),
+ require('../filters/dashify')
+ );
+};
diff --git a/scripts/docs/dgeni-config.js b/scripts/docs/dgeni-config.js
index fabc0ae21..992094914 100644
--- a/scripts/docs/dgeni-config.js
+++ b/scripts/docs/dgeni-config.js
@@ -1,183 +1,78 @@
-var Package = require('dgeni').Package;
-var jsdocPackage = require('dgeni-packages/jsdoc');
-var nunjucksPackage = require('dgeni-packages/nunjucks');
-var typescriptPackage = require('dgeni-packages/typescript');
-var linksPackage = require('dgeni-packages/links');
-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');
+"use strict";
+const Package = require('dgeni').Package,
+ jsdocPackage = require('dgeni-packages/jsdoc'),
+ nunjucksPackage = require('dgeni-packages/nunjucks'),
+ typescriptPackage = require('dgeni-packages/typescript'),
+ linksPackage = require('dgeni-packages/links'),
+ path = require('path'),
+ config = require('../config.json');
-// Define the dgeni package for generating the docs
-module.exports = function(currentVersion) {
+module.exports = currentVersion => {
- return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
+ return new Package('ionic-native-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
-// .processor(require('./processors/latest-version'))
.processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api'))
- // .processor(require('./processors/collect-inputs-outputs'))
.processor(require('./processors/parse-optional'))
.processor(require('./processors/npm-id'))
.processor(require('./processors/jekyll'))
- // for debugging docs
-// .processor(function test(){
-// return {
-//
-// $runBefore: ['rendering-docs'],
-// $process: function(docs){
-// docs.forEach(function(doc){
-// if (doc.name == "Camera"){
-//
-// // console.log(doc.tags);
-// // doc.tags.forEach(function(tag){
-// // if(tag.tagName == 'classes'){
-// //
-// // }
-// // });
-//
-// // doc.moduleDoc.exports.forEach(function(d,i){
-// // if(d.name === 'CameraOptions') {
-// // console.log('Name: ' + d.name);
-// // console.log('Type: ' + d.docType);
-// // console.log('First member: ', d.members[0]);
-// // }
-// // });
-//
-//
-// // var exports = doc.exportSymbol.parent.exports;
-// // for(var p in exports) {
-// // if(p == 'CameraOptions')
-// // {
-// // var x = exports[p];
-// // console.log(x.members.quality);
-// // }
-// // }
-// // doc.members.forEach(function(method){
-// // if (method.name === "getPicture") {
-// // console.log(method);
-// // }
-// // })
-// }
-// })
-// }
-// }
-// })
+ .config(require('./configs/log'))
+ .config(require('./configs/template-filters'))
+ .config(require('./configs/template-tags'))
+ .config(require('./configs/tag-defs'))
+ .config(require('./configs/links'))
-.config(function(log) {
- log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
-})
+ .config(function(renderDocsProcessor, computePathsProcessor) {
-.config(function(renderDocsProcessor, computePathsProcessor) {
+ currentVersion = {
+ href: '/' + config.v2DocsDir.replace('content/', ''),
+ folder: '',
+ name: currentVersion
+ };
- versions = [];
- // new version, add it to the versions list
- if (currentVersion != 'nightly' && !_.includes(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: '/' + config.v2DocsDir.replace('content/',''),
- folder: folder,
- name: version
- };
- });
+ renderDocsProcessor.extraData.version = {
+ list: [currentVersion],
+ current: currentVersion,
+ latest: currentVersion
+ };
- var versionData = {
- list: versions,
- current: _.find(versions, {name: currentVersion}),
- latest: _.find(versions, {name: latestVersion}) || _.first(versions)
- };
+ computePathsProcessor.pathTemplates = [{
+ docTypes: ['class'],
+ getOutputPath: doc => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md'
+ }];
- renderDocsProcessor.extraData.version = versionData;
- computePathsProcessor.pathTemplates = [{
- docTypes: ['class', 'var', 'function', 'let'],
- getOutputPath: function(doc) {
- var docPath = doc.name + '/index.md';
- var path = 'content/' + config.v2DocsDir + '/' + docPath;
+ })
- return path;
- }
- }];
-})
+ //configure file reading
+ .config(function(readFilesProcessor, readTypeScriptModules) {
-//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, '../..');
- // 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(__dirname, '../..');
+ readTypeScriptModules.sourceFiles = [
+ './src/@ionic-native/plugins/**/*.ts'
+ ];
+ })
- readTypeScriptModules.basePath = path.resolve(__dirname, '../..');
- readTypeScriptModules.sourceFiles = [
- './src/@ionic-native/plugins/**/*.ts'
- ];
-})
+ // Configure file writing
+ .config(function(writeFilesProcessor) {
+ writeFilesProcessor.outputFolder = '../ionic-site/';
+ })
-.config(function(parseTagsProcessor) {
- parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions
- .concat(require('./tag-defs/tag-defs'));
-})
+ // Configure rendering
+ .config(function(templateFinder) {
-// .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 = [];
-// }
-// });
-// })
+ templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
-// Configure links
-.config(function(getLinkInfo) {
- getLinkInfo.useFirstAmbiguousLink = false;
-})
-
-// Configure file writing
-.config(function(writeFilesProcessor) {
- writeFilesProcessor.outputFolder = '../ionic-site/';
-})
-
-// 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'),
- require('./filters/dashify')
- );
-
- 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'
- ];
-});
+ // Specify how to match docs to templates.
+ templateFinder.templatePatterns = [
+ '${ doc.template }',
+ '${ doc.docType }.template.html',
+ 'common.template.html'
+ ];
+ });
};
diff --git a/scripts/docs/dgeni-readmes-config.js b/scripts/docs/dgeni-readmes-config.js
index 58d55f86d..c3a4c1487 100644
--- a/scripts/docs/dgeni-readmes-config.js
+++ b/scripts/docs/dgeni-readmes-config.js
@@ -1,116 +1,53 @@
-var Package = require('dgeni').Package;
-var jsdocPackage = require('dgeni-packages/jsdoc');
-var nunjucksPackage = require('dgeni-packages/nunjucks');
-var typescriptPackage = require('dgeni-packages/typescript');
-var linksPackage = require('dgeni-packages/links');
-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');
+"use strict";
+const Package = require('dgeni').Package,
+ jsdocPackage = require('dgeni-packages/jsdoc'),
+ nunjucksPackage = require('dgeni-packages/nunjucks'),
+ typescriptPackage = require('dgeni-packages/typescript'),
+ linksPackage = require('dgeni-packages/links'),
+ path = require('path'),
+ config = require('../config.json');
-// jscs:disable validateIndentation
+module.exports = currentVersion => {
-// Define the dgeni package for generating the docs
-module.exports = function(currentVersion) {
+ return new Package('ionic-native-readmes', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
- return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
-
- // .processor(require('./processors/latest-version'))
.processor(require('./processors/readmes'))
.processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api'))
.processor(require('./processors/npm-id'))
- // .processor(require('./processors/collect-inputs-outputs'))
+ .config(require('./configs/log'))
+ .config(require('./configs/template-filters'))
+ .config(require('./configs/template-tags'))
+ .config(require('./configs/tag-defs'))
+ .config(require('./configs/links'))
- // for debugging docs
- // .processor(function test(){
- // return {
- //
- // $runBefore: ['rendering-docs'],
- // $process: function(docs){
- // docs.forEach(function(doc){
- // if (doc.name == "Camera"){
- //
- // // console.log(doc.tags);
- // // doc.tags.forEach(function(tag){
- // // if(tag.tagName == 'classes'){
- // //
- // // }
- // // });
- //
- // // doc.moduleDoc.exports.forEach(function(d,i){
- // // if(d.name === 'CameraOptions') {
- // // console.log('Name: ' + d.name);
- // // console.log('Type: ' + d.docType);
- // // console.log('First member: ', d.members[0]);
- // // }
- // // });
- //
- //
- // // var exports = doc.exportSymbol.parent.exports;
- // // for(var p in exports) {
- // // if(p == 'CameraOptions')
- // // {
- // // var x = exports[p];
- // // console.log(x.members.quality);
- // // }
- // // }
- // // doc.members.forEach(function(method){
- // // if (method.name === "getPicture") {
- // // console.log(method);
- // // }
- // // })
- // }
- // })
- // }
- // }
- // })
- .config(function(log) {
- log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
- })
.config(function(renderDocsProcessor, computePathsProcessor) {
- versions = [];
- // new version, add it to the versions list
- if (currentVersion != 'nightly' && !_.includes(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: '/' + config.v2DocsDir.replace('content/', ''),
- folder: folder,
- name: version
- };
- });
-
- var versionData = {
- list: versions,
- current: _.find(versions, {name: currentVersion}),
- latest: _.find(versions, {name: latestVersion}) || _.first(versions)
+ currentVersion = {
+ href: '/' + config.v2DocsDir.replace('content/', ''),
+ folder: '',
+ name: currentVersion
+ };
+
+ renderDocsProcessor.extraData.version = {
+ list: [currentVersion],
+ current: currentVersion,
+ latest: currentVersion
};
- renderDocsProcessor.extraData.version = versionData;
computePathsProcessor.pathTemplates = [{
docTypes: ['class'],
- getOutputPath: function(doc) {
- return doc.originalModule.replace(config.pluginDir + '/', '')
- .replace('/plugins', '')
- .replace('/index', '') + '/README.md';
- }
+ getOutputPath: doc => doc.originalModule.replace(config.pluginDir + '/', '')
+ .replace('/plugins', '')
+ .replace('/index', '/README.md')
}];
+
})
//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, '../..');
@@ -119,54 +56,13 @@ module.exports = function(currentVersion) {
readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.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 = './dist/';
})
// 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')
- );
-
+ .config(function(templateFinder) {
templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
// Specify how to match docs to templates.
diff --git a/scripts/docs/filters/capital.js b/scripts/docs/filters/capital.js
index f63edd91f..d9eec85bd 100644
--- a/scripts/docs/filters/capital.js
+++ b/scripts/docs/filters/capital.js
@@ -1,7 +1,5 @@
+"use strict";
module.exports = {
name: 'capital',
- process: function(str) {
- str || (str = '');
- return str.charAt(0).toUpperCase() + str.substring(1);
- }
+ process: str => str? str.charAt(0).toUpperCase() + str.substring(1) : ''
};
diff --git a/scripts/docs/filters/code.js b/scripts/docs/filters/code.js
index d0eaee273..6c95af580 100644
--- a/scripts/docs/filters/code.js
+++ b/scripts/docs/filters/code.js
@@ -1,4 +1,5 @@
-var encoder = new require('node-html-encoder').Encoder();
+"use strict";
+const encoder = new require('node-html-encoder').Encoder();
function code(str, inline, lang) {
// Encode any HTML entities in the code string
@@ -10,16 +11,14 @@ function code(str, inline, lang) {
str = '' + str + '
';
// If not inline then wrap the code element in a pre element
- if ( !inline ) {
+ if (!inline) {
str = '' + str + '
';
}
return str;
-};
+}
module.exports = {
name: 'code',
- process: function(str, lang) {
- return code(str, true, lang);
- }
+ process: (str, lang) => code(str, true, lang)
};
diff --git a/scripts/docs/filters/dashify.js b/scripts/docs/filters/dashify.js
index 85cc7663c..4feee6936 100644
--- a/scripts/docs/filters/dashify.js
+++ b/scripts/docs/filters/dashify.js
@@ -1,7 +1,5 @@
+"use strict";
module.exports = {
name: 'dashify',
- process: function(str) {
- str || (str = '');
- return str.replace(/\s/g, '-');
- }
+ process: str => str? str.replace(/\s/g, '-') : ''
};
diff --git a/scripts/docs/filters/dump.js b/scripts/docs/filters/dump.js
index 155a01e8b..aaefa0567 100644
--- a/scripts/docs/filters/dump.js
+++ b/scripts/docs/filters/dump.js
@@ -1,6 +1,5 @@
+"use strict";
module.exports = {
name: 'dump',
- process: function(obj) {
- console.log(obj);
- }
-};
\ No newline at end of file
+ process: obj => console.log(obj)
+};
diff --git a/scripts/docs/gulp-tasks.js b/scripts/docs/gulp-tasks.js
index cf44602f5..81a10aa45 100644
--- a/scripts/docs/gulp-tasks.js
+++ b/scripts/docs/gulp-tasks.js
@@ -1,37 +1,39 @@
-var config = require('../config.json');
-var projectPackage = require('../../package.json');
-var path = require('path');
-var fs = require('fs-extra-promise').useFs(require('fs-extra'));
+"use strict";
+const config = require('../config.json'),
+ projectPackage = require('../../package.json'),
+ path = require('path'),
+ fs = require('fs-extra-promise').useFs(require('fs-extra')),
+ Dgeni = require('dgeni');
+
+module.exports = gulp => {
+ gulp.task('docs', [], () => {
-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().then(function(docs) {
- console.log(docs.length + ' docs generated');
- });
+
+ const ionicPackage = require('./dgeni-config')(projectPackage.version),
+ dgeni = new Dgeni([ionicPackage]);
+
+ return dgeni.generate().then(docs => console.log(docs.length + ' docs generated'));
+
} catch (err) {
console.log(err.stack);
}
+
});
gulp.task('readmes', [], function() {
- var Dgeni = require('dgeni');
- var semver = require('semver');
fs.copySync(path.resolve(__dirname, '..', '..', 'README.md'), path.resolve(__dirname, '..', '..', config.pluginDir, 'core', 'README.md'));
try {
- var ionicPackage = require('./dgeni-readmes-config')(projectPackage.version);
- var dgeni = new Dgeni([ionicPackage]);
- return dgeni.generate().then(function(docs) {
- console.log(docs.length + ' README files generated');
- });
+
+ const ionicPackage = require('./dgeni-readmes-config')(projectPackage.version),
+ dgeni = new Dgeni([ionicPackage]);
+ return dgeni.generate().then(docs => console.log(docs.length + ' README files generated'));
+
} catch (err) {
console.log(err.stack);
}
+
});
-}
+};
diff --git a/scripts/docs/processors/collect-inputs-outputs.js b/scripts/docs/processors/collect-inputs-outputs.js
deleted file mode 100644
index 68224dc2f..000000000
--- a/scripts/docs/processors/collect-inputs-outputs.js
+++ /dev/null
@@ -1,71 +0,0 @@
-module.exports = function collectInputsOutputs() {
- return {
-
- $runBefore: ['rendering-docs'],
- $process: function(docs) {
- docs.forEach(function(doc) {
-
- if (doc.statics && doc.statics.length) {
- for (var i in doc.statics) {
- // identify properties to differentiate from methods
- if (typeof doc.statics[i].parameters == 'undefined') {
- doc.statics[i].isProperty = true;
- }
- }
- }
-
- if (doc.members && doc.members.length) {
- var members = [];
- var inputs = [];
- var outputs = [];
-
- memberLoop:
- for (var i in doc.members) {
-
- // identify properties to differentiate from methods
- if (typeof doc.members[i].parameters == 'undefined') {
- doc.members[i].isProperty = true;
- }
-
- if (doc.members[i].decorators && doc.members[i].decorators.length) {
-
- decoratorLoop:
- for (var ii in doc.members[i].decorators) {
-
- if (doc.members[i].decorators[ii].name == 'Input') {
- inputs.push(parseMember(doc.members[i]));
- continue memberLoop;
- }
- if (doc.members[i].decorators[ii].name == 'Output') {
- outputs.push(parseMember(doc.members[i]));
- continue memberLoop;
- }
- }
- // not an input or output, must be a plain member
- members.push(doc.members[i]);
- } else {
- members.push(doc.members[i]);
- };
- }
-
- // update doc with pruned members list and add inputs and outputs
- doc.members = members;
- doc.inputs = inputs;
- doc.outputs = outputs;
- }
-
- function parseMember(member) {
- member.type = member.content.substring(
- member.content.indexOf('{') + 1,
- member.content.indexOf('}')
- );
- member.description = member.content.substring(
- member.content.indexOf('}') + 1,
- member.content.length
- );
- return member;
- }
- });
- }
- };
-};
diff --git a/scripts/docs/processors/debug.js b/scripts/docs/processors/debug.js
new file mode 100644
index 000000000..ebf0bf45f
--- /dev/null
+++ b/scripts/docs/processors/debug.js
@@ -0,0 +1,43 @@
+"use strict";
+module.exports = function test(){
+ return {
+ name: 'debug',
+ $runBefore: ['rendering-docs'],
+ $process: function(docs){
+ docs.forEach(function(doc){
+ if (doc.name == "Camera"){
+
+ console.log(doc.tags);
+ doc.tags.forEach(function(tag){
+ if(tag.tagName == 'classes'){
+
+ }
+ });
+
+ doc.moduleDoc.exports.forEach(function(d,i){
+ if(d.name === 'CameraOptions') {
+ console.log('Name: ' + d.name);
+ console.log('Type: ' + d.docType);
+ console.log('First member: ', d.members[0]);
+ }
+ });
+
+
+ var exports = doc.exportSymbol.parent.exports;
+ for(var p in exports) {
+ if(p == 'CameraOptions')
+ {
+ var x = exports[p];
+ console.log(x.members.quality);
+ }
+ }
+ doc.members.forEach(function(method){
+ if (method.name === "getPicture") {
+ console.log(method);
+ }
+ })
+ }
+ })
+ }
+ }
+}
diff --git a/scripts/docs/processors/hide-private-api.js b/scripts/docs/processors/hide-private-api.js
index bd475a46a..80809bad3 100644
--- a/scripts/docs/processors/hide-private-api.js
+++ b/scripts/docs/processors/hide-private-api.js
@@ -1,18 +1,9 @@
+"use strict";
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 && (!doc.tags || !doc.tags.tagsByName.get('hidden'))){
- publicDocs.push(doc);
- return doc
- }
- });
- docs = publicDocs;
- return docs;
- }
- }
+ $process: docs => docs.filter(doc => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden')))
+ };
};
diff --git a/scripts/docs/processors/jekyll.js b/scripts/docs/processors/jekyll.js
index da030f77b..5c3db7bf6 100644
--- a/scripts/docs/processors/jekyll.js
+++ b/scripts/docs/processors/jekyll.js
@@ -1,33 +1,30 @@
+"use strict";
module.exports = function jekyll(renderDocsProcessor) {
return {
name: 'jekyll',
description: 'Create jekyll includes',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
- $process: function(docs) {
-
- console.log('jekyll running');
-
- var currentVersion = renderDocsProcessor.extraData.version.current.name;
+ $process: docs => {
// 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() : '';
+ docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
+
+ docs.sort((a, b) => {
+ const 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) {
- doc.outputPath = doc.outputPath.toLowerCase().replace(/\s/g, '-');
- docs[i].URL = doc.outputPath.replace('docs/v2//', 'docs/v2/')
- .replace('/index.md', '')
- .replace('content/', '');
- docs[i].demo = !!docs[i].demo;
+ docs.forEach(doc => {
+ doc.outputPath = doc.outputPath.toLowerCase().replace(/\s/g, '-');
+ doc.URL = doc.outputPath.replace('docs/v2//', 'docs/v2/')
+ .replace('/index.md', '')
+ .replace('content/', '');
});
+ // add side menu
docs.push({
docType: 'nativeMenu',
id: 'native_menu',
@@ -35,7 +32,6 @@ module.exports = function jekyll(renderDocsProcessor) {
outputPath: 'content/_includes/v2_fluid/native_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
deleted file mode 100644
index 43d39fca2..000000000
--- a/scripts/docs/processors/latest-version.js
+++ /dev/null
@@ -1,33 +0,0 @@
-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/content/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/npm-id.js b/scripts/docs/processors/npm-id.js
index 223e49eb5..e1be42db1 100644
--- a/scripts/docs/processors/npm-id.js
+++ b/scripts/docs/processors/npm-id.js
@@ -1,22 +1,19 @@
+"use strict";
module.exports = function npmId(renderDocsProcessor) {
return {
name: 'npm-id',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
- $process: function(docs) {
- var currentVersion = renderDocsProcessor.extraData.version.current.name;
-
+ $process: docs => {
// 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.forEach(function(doc, i) {
+ docs.forEach(doc => {
doc.npmId = doc.id.match(/plugins\/(.*)\/index/)[1];
- console.log('@ionic-native/' + doc.npmId);
});
- // returning docs will replace docs object in the next process
return docs;
}
};
diff --git a/scripts/docs/processors/parse-optional.js b/scripts/docs/processors/parse-optional.js
index 1cb50ebdc..28f9f4581 100644
--- a/scripts/docs/processors/parse-optional.js
+++ b/scripts/docs/processors/parse-optional.js
@@ -1,13 +1,14 @@
+"use strict";
module.exports = function parseOptional() {
return {
$runBefore: ['rendering-docs'],
- $process: function(docs) {
- docs.forEach(function(doc) {
- if(doc.members && doc.members.length) {
- for (var i in doc.members) {
- if(doc.members[i].params && doc.members[i].params.length) {
- for (var ii in doc.members[i].params) {
- if(doc.members[i].params[ii].optional){
+ $process: docs => {
+ docs.forEach(doc => {
+ if (doc.members && doc.members.length) {
+ for (let i in doc.members) {
+ if (doc.members[i].params && doc.members[i].params.length) {
+ for (let ii in doc.members[i].params) {
+ if (doc.members[i].params[ii].optional) {
doc.members[i].params[ii].description += 'Optional';
}
}
diff --git a/scripts/docs/processors/readmes.js b/scripts/docs/processors/readmes.js
index dde2001bf..a3d2b8c45 100644
--- a/scripts/docs/processors/readmes.js
+++ b/scripts/docs/processors/readmes.js
@@ -1,22 +1,18 @@
+"use strict";
module.exports = function readmes(renderDocsProcessor) {
return {
name: 'readmes',
description: 'Create jekyll includes',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
- $process: function(docs) {
- var currentVersion = renderDocsProcessor.extraData.version.current.name;
-
+ $process: docs => {
// 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 = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
- docs.forEach(function(doc, i) {
+ docs.forEach(doc => {
doc.outputPath = doc.outputPath.replace('src/', '');
});
- // returning docs will replace docs object in the next process
return docs;
}
};
diff --git a/scripts/docs/processors/remove-private-members.js b/scripts/docs/processors/remove-private-members.js
index 36fdd3303..2c360d9e6 100644
--- a/scripts/docs/processors/remove-private-members.js
+++ b/scripts/docs/processors/remove-private-members.js
@@ -1,22 +1,19 @@
+"use strict";
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) {
+ $process: docs => {
+ docs.forEach(doc => {
if (doc.members) {
- doc.members = doc.members.filter(function(member) {
- return !member.tags.tagsByName.get('hidden');
- });
+ doc.members = doc.members.filter(member => !member.tags.tagsByName.get('hidden'));
}
if (doc.statics) {
- doc.statics = doc.statics.filter(function(staticMethod) {
- return !staticMethod.tags.tagsByName.get('hidden');
- });
+ doc.statics = doc.statics.filter(staticMethod => !staticMethod.tags.tagsByName.get('hidden'));
}
});
diff --git a/scripts/docs/tag-defs/tag-defs.js b/scripts/docs/tag-defs/tag-defs.js
index 98a043ac8..5a40ba412 100644
--- a/scripts/docs/tag-defs/tag-defs.js
+++ b/scripts/docs/tag-defs/tag-defs.js
@@ -1,10 +1,8 @@
+"use strict";
module.exports = [
{'name': 'advanced'},
{'name': 'demo'},
- {'name': 'beta', transforms: function(doc, tag, value) {
- // make the value true or undefined instead of '' or undefined
- return typeof value !== 'undefined';
- }},
+ {'name': 'beta', transforms: (doc, tag, value) => typeof value !== 'undefined'}, // make the value true or undefined instead of '' or undefined
{'name': 'usage'},
{'name': 'hidden'}, // hide from docs
{'name': 'classes'}, // related classes
diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html
index 493b28e40..282a4239b 100644
--- a/scripts/docs/templates/common.template.html
+++ b/scripts/docs/templates/common.template.html
@@ -10,8 +10,7 @@ header_sub_title: "<$ doc.docType | capital $> in module <$ doc.module $>"
doc: "<$ doc.name $>"
docType: "<$ doc.docType $>"
---
-
-<@ macro interfaceTable(interface) @>
+<@- macro interfaceTable(interface) -@>
<@ for export in doc.moduleDoc.exports -@>
<@ if export.name == interface @>
@@ -39,24 +38,15 @@ docType: "<$ doc.docType $>"
<@ endfor @>
-
<@ endif @>
<@- endfor @>
-<@ endmacro @>
-
-<@ macro paramList(paramData) -@>
-<@- if paramData -@>(
- <@- for param in paramData -@>
- <$ param | escape $><@ if not loop.last @>, <@ endif @>
- <@- endfor @>)
-<@- endif @>
<@- endmacro -@>
-<@ macro githubViewLink(doc) -@>
+<@- macro githubViewLink(doc) -@>
<$ doc.fileInfo.relativePath $> (line <$ doc.location.start.line+1 $>)
<@- endmacro -@>
-<@ macro paramTable(params, isDirective) -@>
+<@- macro paramTable(params, isDirective) -@>
@@ -66,26 +56,25 @@ docType: "<$ doc.docType $>"
- <@ for param in params @>
+ <@- for param in params @>
<$ param.name $>
- <@ if param.alias @>| <$ param.alias $><@ endif @>
+ <@- if param.alias @>| <$ param.alias $><@ endif -@>
|
<$ typeList(param.typeList) $>
|
<$ param.description | marked $>
- <@ if param.defaultValue @> (default: <$ param.defaultValue $>) <@ endif @>
+ <@- if param.defaultValue @>(default: <$ param.defaultValue $>) <@ endif -@>
|
- <@ endfor @>
+ <@ endfor -@>
<@- endmacro -@>
-
<@- macro functionSyntax(fn) @>
<@- set sep = joiner(', ') -@>
<$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $>
@@ -96,89 +85,64 @@ docType: "<$ doc.docType $>"
<@ if fn.alias @>(alias: <$ fn.alias $>)<@ endif @>
<@ endmacro -@>
-<@ macro typeList(types) -@>
+<@- macro typeList(types) -@>
<@ set separator = joiner("|") @>
-<@ for type in types @><$ separator() $><$ type | code $><@ endfor @>
+<@- for type in types @><$ separator() $><$ type | code $><@ endfor -@>
<@- endmacro -@>
<@- macro typeInfo(fn) -@>
<$ typeList(fn.typeList) $> <$ fn.description $>
<@- endmacro -@>
-
-
-<@ macro documentClass(doc) @>
-<@- if doc.statics.length -@>
-Static Members
-<@ for method in doc.statics -@>
-<@ if not method.internal @>
-
-<$ functionSyntax(method) $>
+<@- macro documentPlatforms(method) -@>
<@- if method.decorators @>
<@ for prop in method.decorators[0].argumentInfo @>
<@ if prop.platforms @>
- Platforms:
- <@- for platform in prop.platforms @>
- <$ platform $>
- <@ endfor -@>
+ Platforms:
+ <@- for platform in prop.platforms -@>
+ <$ platform $>
+ <@- endfor -@>
<@ endif @>
<@ endfor @>
<@- endif @>
+<@- endmacro -@>
-<$ 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 @>
-<@ endif @>
-<@ endfor -@>
-<@ endif @>
-
-
-<@- if doc.members and doc.members.length @>
-
-Instance Members
-<@ for method in doc.members -@>
-
-
- <$ functionSyntax(method) $>
-
+<@- macro documentMethod(method) -@>
+<$ functionSyntax(method) $>
+<$ documentPlatforms(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 @>
+<@- endmacro -@>
+
+<@- macro documentClass(doc) @>
+<@- if doc.statics.length -@>
+Static Members
+<@ for method in doc.statics -@>
+<$ documentMethod(method) $>
+<@ endfor -@>
+<@ endif @>
+
+<# --- methods in class --- #>
+<@- if doc.members and doc.members.length @>
+
+Instance Members
+<@ for method in doc.members -@>
+<$ documentMethod(method) $>
<@- endfor @>
<@- endif -@>
-<@ endmacro @>
-<@ block body @>
-<@ block content @>
-<@ block header @>
+<@- endmacro -@>
+
<@ if doc.docType == "directive" @>
<$ doc.name | dashCase $>
@@ -208,13 +172,9 @@ docType: "<$ doc.docType $>"
Improve this doc
-<@ endblock @>
-
-
+<# --- Decorators --- #>
<@- if doc.decorators @>
-
<@ for prop in doc.decorators[0].argumentInfo @>
-
<@ if doc.beta == true @>
This plugin is still in beta stage and may not work as expected. Please
@@ -222,7 +182,6 @@ docType: "<$ doc.docType $>"
href="<$ prop.repo $>/issues">plugin repo.
<@ endif @>
-
$ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @>
$ npm install --save @ionic-native/<$ doc.npmId $>
@@ -232,48 +191,34 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
-
-<@ block description @>
+<# --- Plugin description --- #>
<$ doc.description | marked $>
-<@ endblock @>
-
-
-<@- if doc.directiveInfo @>
-<$ doc.directiveInfo.type $>
-<$ doc.directiveInfo.properties[0].name $>: <$ doc.directiveInfo.properties[0].values $>
-<@ endif -@>
+<# --- Plugin supported platforms --- #>
<@ if prop.platforms @>
-
Supported platforms
-<@ block platforms @>
<@ for platform in prop.platforms -@>
- <$ platform $>
<@- endfor @>
-<@ endblock @>
-
<@ endif @>
<@ endfor @>
-<@ endif -@>
+<@ endif -@> <# --- end of: if doc.decorators --- #>
-
+<# --- Plugin usage --- #>
<@ if doc.usage @>
Usage
-<@ block usage @>
<$ doc.usage | marked $>
-<@ endblock @>
<@ endif @>
-
-<@ if doc.properties @>
+<# --- Plugin attributes --- #>
+<@- if doc.properties -@>
Attributes:
Attribute |
-
<@ set hasTypes = false @>
<@ for prop in doc.properties @>
<@ if prop.type @>
@@ -283,12 +228,11 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@ if hasTypes @>
Type |
<@ endif @>
-
Description |
- <@ for prop in doc.properties -@>
+ <@- for prop in doc.properties -@>
<$ prop.name $>
@@ -298,48 +242,44 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<$ prop.type.name $>
|
<@ endif @>
-
<$ prop.description $>
|
- <@- endfor @>
+ <@ endfor -@>
-<@ endif @>
+<@- endif -@>
+<# --- Plugin class documentation --- #>
<$ documentClass(doc) $>
-<@ block advanced @>
+<# --- Advanced usage --- #>
<@- if doc.advanced -@>
Advanced
<$ doc.advanced | marked $>
<@- endif -@>
-<@ endblock @>
-
-<@ for tag in doc.tags.tags -@>
-<@ if tag.tagName == 'classes' -@>
-
-<@ set classes = tag.description.split('\n') @>
-<@ for item in classes -@>
-<@ if item.length > 1 @>
-<@ for export in doc.moduleDoc.exports -@>
-<@ if export.name == item @>
+<# --- Other classes --- #>
+<@- for tag in doc.tags.tags -@>
+<@- if tag.tagName == 'classes' -@>
+<@- set classes = tag.description.split('\n') -@>
+<@- for item in classes -@>
+<@- if item.length > 1 -@>
+<@- for export in doc.moduleDoc.exports -@>
+<@- if export.name == item -@>
<$ item $>
<$ documentClass(export) $>
-<@ endif @>
-<@- endfor @>
-<@ endif @>
-<@- endfor @>
-<@- endif @>
-<@- endfor @>
-
+<@- endif -@>
+<@- endfor -@>
+<@- endif -@>
+<@- endfor -@>
+<@- endif -@>
+<@- endfor -@>
-
+<# --- Other interfaces --- #>
<@ for tag in doc.tags.tags -@>
<@ if tag.tagName == 'interfaces' @>
-
<@ set interfaces = tag.description.split('\n') @>
<@ for item in interfaces -@>
<@ if item.length > 1 @>
@@ -349,21 +289,12 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@- endfor @>
<@ endif @>
<@- endfor @>
-
-
+
+<# --- Related links --- #>
<@- if doc.see @>
-
-Related
+Related
<@ for s in doc.see @>
<$ s | safe $>
<@- endfor -@>
-
<@- endif -@>
-
-
-
-<@ endblock @>
-
-
-<@ endblock @>