chore(docs): cleanup + es6

This commit is contained in:
Ibby 2017-03-23 22:07:59 -04:00
parent cd5ff68bc1
commit ead99b1a4f
24 changed files with 321 additions and 656 deletions

View File

@ -1,32 +1,35 @@
var gulp = require('gulp'); "use strict";
var minimist = require('minimist');
var rename = require("gulp-rename");
var tslint = require('gulp-tslint');
var decamelize = require('decamelize');
var replace = require('gulp-replace');
var flagConfig = { const gulp = require('gulp'),
string: ['port', 'version', 'ngVersion', 'animations'], minimist = require('minimist'),
boolean: ['dry-run'], rename = require("gulp-rename"),
alias: {'p': 'port', 'v': 'version', 'a': 'ngVersion'}, tslint = require('gulp-tslint'),
default: { port: 8000 } decamelize = require('decamelize'),
}; replace = require('gulp-replace');
var flags = minimist(process.argv.slice(2), flagConfig);
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 */ /* Docs tasks */
require('./scripts/docs/gulp-tasks')(gulp, flags); require('./scripts/docs/gulp-tasks')(gulp, flags);
gulp.task('lint', function() { gulp.task('lint', () => {
gulp.src('src/**/*.ts') return gulp.src('src/**/*.ts')
.pipe(tslint({ .pipe(tslint({
formatter: "verbose", formatter: "verbose",
configuration: 'tslint.json' configuration: 'tslint.json'
})) }))
.pipe(tslint.report()) .pipe(tslint.report());
}); });
gulp.task('plugin:create', function(){ gulp.task('plugin:create', () => {
if(flags.n && flags.n !== ''){ if (flags.n && flags.n !== ''){
const src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl', const src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl',
pluginName = flags.n, pluginName = flags.n,
@ -40,8 +43,6 @@ gulp.task('plugin:create', function(){
.pipe(gulp.dest('./src/@ionic-native/plugins/' + pluginPackageName)); .pipe(gulp.dest('./src/@ionic-native/plugins/' + pluginPackageName));
} else { } else {
console.log("Usage is: gulp plugin:create -n PluginName"); console.log("Usage is: gulp plugin:create -n PluginName");
} }
}); });

View File

@ -0,0 +1,3 @@
module.exports = function(getLinkInfo) {
getLinkInfo.useFirstAmbiguousLink = false;
};

View File

@ -0,0 +1,3 @@
module.exports = function(log) {
log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
};

View File

@ -0,0 +1,4 @@
module.exports = function(parseTagsProcessor) {
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions
.concat(require('../tag-defs/tag-defs'));
};

View File

@ -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: '#>'
};
};

View File

@ -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')
);
};

View File

@ -1,183 +1,78 @@
var Package = require('dgeni').Package; "use strict";
var jsdocPackage = require('dgeni-packages/jsdoc'); const Package = require('dgeni').Package,
var nunjucksPackage = require('dgeni-packages/nunjucks'); jsdocPackage = require('dgeni-packages/jsdoc'),
var typescriptPackage = require('dgeni-packages/typescript'); nunjucksPackage = require('dgeni-packages/nunjucks'),
var linksPackage = require('dgeni-packages/links'); typescriptPackage = require('dgeni-packages/typescript'),
var path = require('path'); linksPackage = require('dgeni-packages/links'),
var semver = require('semver'); path = require('path'),
var fs = require('fs'); config = require('../config.json');
var _ = require('lodash');
var config = require('../config.json');
var projectPackage = require('../../package.json');
// Define the dgeni package for generating the docs module.exports = currentVersion => {
module.exports = function(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/remove-private-members'))
.processor(require('./processors/hide-private-api')) .processor(require('./processors/hide-private-api'))
// .processor(require('./processors/collect-inputs-outputs'))
.processor(require('./processors/parse-optional')) .processor(require('./processors/parse-optional'))
.processor(require('./processors/npm-id')) .processor(require('./processors/npm-id'))
.processor(require('./processors/jekyll')) .processor(require('./processors/jekyll'))
// for debugging docs .config(require('./configs/log'))
// .processor(function test(){ .config(require('./configs/template-filters'))
// return { .config(require('./configs/template-tags'))
// .config(require('./configs/tag-defs'))
// $runBefore: ['rendering-docs'], .config(require('./configs/links'))
// $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) { .config(function(renderDocsProcessor, computePathsProcessor) {
log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
})
.config(function(renderDocsProcessor, computePathsProcessor) { currentVersion = {
href: '/' + config.v2DocsDir.replace('content/', ''),
folder: '',
name: currentVersion
};
versions = []; renderDocsProcessor.extraData.version = {
// new version, add it to the versions list list: [currentVersion],
if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) { current: currentVersion,
versions.unshift(currentVersion); latest: 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 = { computePathsProcessor.pathTemplates = [{
list: versions, docTypes: ['class'],
current: _.find(versions, {name: currentVersion}), getOutputPath: doc => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md'
latest: _.find(versions, {name: latestVersion}) || _.first(versions) }];
};
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 // Don't run unwanted processors since we are not using the normal file reading processor
.config(function(readFilesProcessor, readTypeScriptModules) { readFilesProcessor.$enabled = false;
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
// Don't run unwanted processors since we are not using the normal file reading processor readTypeScriptModules.basePath = path.resolve(__dirname, '../..');
readFilesProcessor.$enabled = false; readTypeScriptModules.sourceFiles = [
readFilesProcessor.basePath = path.resolve(__dirname, '../..'); './src/@ionic-native/plugins/**/*.ts'
];
})
readTypeScriptModules.basePath = path.resolve(__dirname, '../..'); // Configure file writing
readTypeScriptModules.sourceFiles = [ .config(function(writeFilesProcessor) {
'./src/@ionic-native/plugins/**/*.ts' writeFilesProcessor.outputFolder = '../ionic-site/';
]; })
})
.config(function(parseTagsProcessor) { // Configure rendering
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions .config(function(templateFinder) {
.concat(require('./tag-defs/tag-defs'));
})
// .config(function(parseTagsProcessor) { templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
// // 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 // Specify how to match docs to templates.
.config(function(getLinkInfo) { templateFinder.templatePatterns = [
getLinkInfo.useFirstAmbiguousLink = false; '${ doc.template }',
}) '${ doc.docType }.template.html',
'common.template.html'
// 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'
];
});
}; };

View File

@ -1,116 +1,53 @@
var Package = require('dgeni').Package; "use strict";
var jsdocPackage = require('dgeni-packages/jsdoc'); const Package = require('dgeni').Package,
var nunjucksPackage = require('dgeni-packages/nunjucks'); jsdocPackage = require('dgeni-packages/jsdoc'),
var typescriptPackage = require('dgeni-packages/typescript'); nunjucksPackage = require('dgeni-packages/nunjucks'),
var linksPackage = require('dgeni-packages/links'); typescriptPackage = require('dgeni-packages/typescript'),
var path = require('path'); linksPackage = require('dgeni-packages/links'),
var semver = require('semver'); path = require('path'),
var fs = require('fs'); config = require('../config.json');
var _ = require('lodash');
var config = require('../config.json');
var projectPackage = require('../../package.json');
// jscs:disable validateIndentation module.exports = currentVersion => {
// Define the dgeni package for generating the docs return new Package('ionic-native-readmes', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
module.exports = function(currentVersion) {
return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
// .processor(require('./processors/latest-version'))
.processor(require('./processors/readmes')) .processor(require('./processors/readmes'))
.processor(require('./processors/remove-private-members')) .processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api')) .processor(require('./processors/hide-private-api'))
.processor(require('./processors/npm-id')) .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) { .config(function(renderDocsProcessor, computePathsProcessor) {
versions = []; currentVersion = {
// new version, add it to the versions list href: '/' + config.v2DocsDir.replace('content/', ''),
if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) { folder: '',
versions.unshift(currentVersion); name: currentVersion
} };
//First semver valid version is latest
var latestVersion = _.find(versions, semver.valid); renderDocsProcessor.extraData.version = {
versions = versions.map(function(version) { list: [currentVersion],
// We don't separate by versions so always put the docs in the root current: currentVersion,
var folder = ''; latest: currentVersion
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)
}; };
renderDocsProcessor.extraData.version = versionData;
computePathsProcessor.pathTemplates = [{ computePathsProcessor.pathTemplates = [{
docTypes: ['class'], docTypes: ['class'],
getOutputPath: function(doc) { getOutputPath: doc => doc.originalModule.replace(config.pluginDir + '/', '')
return doc.originalModule.replace(config.pluginDir + '/', '') .replace('/plugins', '')
.replace('/plugins', '') .replace('/index', '/README.md')
.replace('/index', '') + '/README.md';
}
}]; }];
}) })
//configure file reading //configure file reading
.config(function(readFilesProcessor, readTypeScriptModules) { .config(function(readFilesProcessor, readTypeScriptModules) {
// Don't run unwanted processors since we are not using the normal file reading processor // Don't run unwanted processors since we are not using the normal file reading processor
readFilesProcessor.$enabled = false; readFilesProcessor.$enabled = false;
readFilesProcessor.basePath = path.resolve(__dirname, '../..'); readFilesProcessor.basePath = path.resolve(__dirname, '../..');
@ -119,54 +56,13 @@ module.exports = function(currentVersion) {
readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts']; 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 // Configure file writing
.config(function(writeFilesProcessor) { .config(function(writeFilesProcessor) {
writeFilesProcessor.outputFolder = './dist/'; writeFilesProcessor.outputFolder = './dist/';
}) })
// Configure rendering // Configure rendering
.config(function(templateFinder, templateEngine) { .config(function(templateFinder) {
// 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')); templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
// Specify how to match docs to templates. // Specify how to match docs to templates.

View File

@ -1,7 +1,5 @@
"use strict";
module.exports = { module.exports = {
name: 'capital', name: 'capital',
process: function(str) { process: str => str? str.charAt(0).toUpperCase() + str.substring(1) : ''
str || (str = '');
return str.charAt(0).toUpperCase() + str.substring(1);
}
}; };

View File

@ -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) { function code(str, inline, lang) {
// Encode any HTML entities in the code string // Encode any HTML entities in the code string
@ -10,16 +11,14 @@ function code(str, inline, lang) {
str = '<code' + lang + '>' + str + '</code>'; str = '<code' + lang + '>' + str + '</code>';
// If not inline then wrap the code element in a pre element // If not inline then wrap the code element in a pre element
if ( !inline ) { if (!inline) {
str = '<pre>' + str + '</pre>'; str = '<pre>' + str + '</pre>';
} }
return str; return str;
}; }
module.exports = { module.exports = {
name: 'code', name: 'code',
process: function(str, lang) { process: (str, lang) => code(str, true, lang)
return code(str, true, lang);
}
}; };

View File

@ -1,7 +1,5 @@
"use strict";
module.exports = { module.exports = {
name: 'dashify', name: 'dashify',
process: function(str) { process: str => str? str.replace(/\s/g, '-') : ''
str || (str = '');
return str.replace(/\s/g, '-');
}
}; };

View File

@ -1,6 +1,5 @@
"use strict";
module.exports = { module.exports = {
name: 'dump', name: 'dump',
process: function(obj) { process: obj => console.log(obj)
console.log(obj);
}
}; };

View File

@ -1,37 +1,39 @@
var config = require('../config.json'); "use strict";
var projectPackage = require('../../package.json'); const config = require('../config.json'),
var path = require('path'); projectPackage = require('../../package.json'),
var fs = require('fs-extra-promise').useFs(require('fs-extra')); 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 { try {
var ionicPackage = require('./dgeni-config')(projectPackage.version);
var dgeni = new Dgeni([ionicPackage]); const ionicPackage = require('./dgeni-config')(projectPackage.version),
return dgeni.generate().then(function(docs) { dgeni = new Dgeni([ionicPackage]);
console.log(docs.length + ' docs generated');
}); return dgeni.generate().then(docs => console.log(docs.length + ' docs generated'));
} catch (err) { } catch (err) {
console.log(err.stack); console.log(err.stack);
} }
}); });
gulp.task('readmes', [], function() { 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')); fs.copySync(path.resolve(__dirname, '..', '..', 'README.md'), path.resolve(__dirname, '..', '..', config.pluginDir, 'core', 'README.md'));
try { try {
var ionicPackage = require('./dgeni-readmes-config')(projectPackage.version);
var dgeni = new Dgeni([ionicPackage]); const ionicPackage = require('./dgeni-readmes-config')(projectPackage.version),
return dgeni.generate().then(function(docs) { dgeni = new Dgeni([ionicPackage]);
console.log(docs.length + ' README files generated'); return dgeni.generate().then(docs => console.log(docs.length + ' README files generated'));
});
} catch (err) { } catch (err) {
console.log(err.stack); console.log(err.stack);
} }
}); });
} };

View File

@ -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;
}
});
}
};
};

View File

@ -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);
}
})
}
})
}
}
}

View File

@ -1,18 +1,9 @@
"use strict";
module.exports = function removePrivateApi() { module.exports = function removePrivateApi() {
return { return {
name: 'remove-private-api', name: 'remove-private-api',
description: 'Prevent the private apis from being rendered', description: 'Prevent the private apis from being rendered',
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => docs.filter(doc => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden')))
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;
}
}
}; };

View File

@ -1,33 +1,30 @@
"use strict";
module.exports = function jekyll(renderDocsProcessor) { module.exports = function jekyll(renderDocsProcessor) {
return { return {
name: 'jekyll', name: 'jekyll',
description: 'Create jekyll includes', description: 'Create jekyll includes',
$runAfter: ['paths-computed'], $runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => {
console.log('jekyll running');
var currentVersion = renderDocsProcessor.extraData.version.current.name;
// pretty up and sort the docs object for menu generation // pretty up and sort the docs object for menu generation
docs = docs.filter(function(doc) { docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page';
}); docs.sort((a, b) => {
docs.sort(function(a, b) { const textA = a.name ? a.name.toUpperCase() : '',
textA = a.name ? a.name.toUpperCase() : ''; textB = b.name ? b.name.toUpperCase() : '';
textB = b.name ? b.name.toUpperCase() : '';
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; 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({ docs.push({
docType: 'nativeMenu', docType: 'nativeMenu',
id: 'native_menu', id: 'native_menu',
@ -35,7 +32,6 @@ module.exports = function jekyll(renderDocsProcessor) {
outputPath: 'content/_includes/v2_fluid/native_menu.html' outputPath: 'content/_includes/v2_fluid/native_menu.html'
}); });
// returning docs will replace docs object in the next process
return docs; return docs;
} }
}; };

View File

@ -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;
}
}
};

View File

@ -1,22 +1,19 @@
"use strict";
module.exports = function npmId(renderDocsProcessor) { module.exports = function npmId(renderDocsProcessor) {
return { return {
name: 'npm-id', name: 'npm-id',
$runAfter: ['paths-computed'], $runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => {
var currentVersion = renderDocsProcessor.extraData.version.current.name;
// pretty up and sort the docs object for menu generation // pretty up and sort the docs object for menu generation
docs = docs.filter(function(doc) { docs = docs.filter(function(doc) {
return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'; 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]; 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; return docs;
} }
}; };

View File

@ -1,13 +1,14 @@
"use strict";
module.exports = function parseOptional() { module.exports = function parseOptional() {
return { return {
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => {
docs.forEach(function(doc) { docs.forEach(doc => {
if(doc.members && doc.members.length) { if (doc.members && doc.members.length) {
for (var i in doc.members) { for (let i in doc.members) {
if(doc.members[i].params && doc.members[i].params.length) { if (doc.members[i].params && doc.members[i].params.length) {
for (var ii in doc.members[i].params) { for (let ii in doc.members[i].params) {
if(doc.members[i].params[ii].optional){ if (doc.members[i].params[ii].optional) {
doc.members[i].params[ii].description += '<strong class="tag">Optional</strong>'; doc.members[i].params[ii].description += '<strong class="tag">Optional</strong>';
} }
} }

View File

@ -1,22 +1,18 @@
"use strict";
module.exports = function readmes(renderDocsProcessor) { module.exports = function readmes(renderDocsProcessor) {
return { return {
name: 'readmes', name: 'readmes',
description: 'Create jekyll includes', description: 'Create jekyll includes',
$runAfter: ['paths-computed'], $runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => {
var currentVersion = renderDocsProcessor.extraData.version.current.name;
// pretty up and sort the docs object for menu generation // pretty up and sort the docs object for menu generation
docs = docs.filter(function(doc) { docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page';
});
docs.forEach(function(doc, i) { docs.forEach(doc => {
doc.outputPath = doc.outputPath.replace('src/', ''); doc.outputPath = doc.outputPath.replace('src/', '');
}); });
// returning docs will replace docs object in the next process
return docs; return docs;
} }
}; };

View File

@ -1,22 +1,19 @@
"use strict";
module.exports = function removePrivateMembers() { module.exports = function removePrivateMembers() {
return { return {
name: 'remove-private-members', name: 'remove-private-members',
description: 'Remove member docs with @private tags', description: 'Remove member docs with @private tags',
$runAfter: ['tags-parsed'], $runAfter: ['tags-parsed'],
$runBefore: ['rendering-docs'], $runBefore: ['rendering-docs'],
$process: function(docs) { $process: docs => {
docs.forEach(function(doc) { docs.forEach(doc => {
if (doc.members) { if (doc.members) {
doc.members = doc.members.filter(function(member) { doc.members = doc.members.filter(member => !member.tags.tagsByName.get('hidden'));
return !member.tags.tagsByName.get('hidden');
});
} }
if (doc.statics) { if (doc.statics) {
doc.statics = doc.statics.filter(function(staticMethod) { doc.statics = doc.statics.filter(staticMethod => !staticMethod.tags.tagsByName.get('hidden'));
return !staticMethod.tags.tagsByName.get('hidden');
});
} }
}); });

View File

@ -1,10 +1,8 @@
"use strict";
module.exports = [ module.exports = [
{'name': 'advanced'}, {'name': 'advanced'},
{'name': 'demo'}, {'name': 'demo'},
{'name': 'beta', transforms: function(doc, tag, value) { {'name': 'beta', transforms: (doc, tag, value) => typeof value !== 'undefined'}, // make the value true or undefined instead of '' or undefined
// make the value true or undefined instead of '' or undefined
return typeof value !== 'undefined';
}},
{'name': 'usage'}, {'name': 'usage'},
{'name': 'hidden'}, // hide from docs {'name': 'hidden'}, // hide from docs
{'name': 'classes'}, // related classes {'name': 'classes'}, // related classes

View File

@ -10,8 +10,7 @@ header_sub_title: "<$ doc.docType | capital $> in module <$ doc.module $>"
doc: "<$ doc.name $>" doc: "<$ doc.name $>"
docType: "<$ doc.docType $>" docType: "<$ doc.docType $>"
--- ---
<@- macro interfaceTable(interface) -@>
<@ macro interfaceTable(interface) @>
<@ for export in doc.moduleDoc.exports -@> <@ for export in doc.moduleDoc.exports -@>
<@ if export.name == interface @> <@ if export.name == interface @>
<table class="table param-table" style="margin:0;"> <table class="table param-table" style="margin:0;">
@ -39,24 +38,15 @@ docType: "<$ doc.docType $>"
<@ endfor @> <@ endfor @>
</tbody> </tbody>
</table> </table>
<@ endif @> <@ endif @>
<@- endfor @> <@- endfor @>
<@ endmacro @>
<@ macro paramList(paramData) -@>
<@- if paramData -@><span class="params">(
<@- for param in paramData -@>
<span class="param"><$ param | escape $><@ if not loop.last @>, <@ endif @></span>
<@- endfor @>)</span>
<@- endif @>
<@- endmacro -@> <@- endmacro -@>
<@ macro githubViewLink(doc) -@> <@- macro githubViewLink(doc) -@>
<a href="https://github.com/driftyco/ionic-native/tree/master/<$ doc.fileInfo.relativePath $>#L<$ doc.location.start.line+1 $>-L<$ doc.location.end.line+1 $>"><$ doc.fileInfo.relativePath $> (line <$ doc.location.start.line+1 $>)</a> <a href="https://github.com/driftyco/ionic-native/tree/master/<$ doc.fileInfo.relativePath $>#L<$ doc.location.start.line+1 $>-L<$ doc.location.end.line+1 $>"><$ doc.fileInfo.relativePath $> (line <$ doc.location.start.line+1 $>)</a>
<@- endmacro -@> <@- endmacro -@>
<@ macro paramTable(params, isDirective) -@> <@- macro paramTable(params, isDirective) -@>
<table class="table param-table" style="margin:0;"> <table class="table param-table" style="margin:0;">
<thead> <thead>
<tr> <tr>
@ -66,26 +56,25 @@ docType: "<$ doc.docType $>"
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<@ for param in params @> <@- for param in params @>
<tr> <tr>
<td> <td>
<$ param.name $> <$ param.name $>
<@ if param.alias @>| <$ param.alias $><@ endif @> <@- if param.alias @>| <$ param.alias $><@ endif -@>
</td> </td>
<td> <td>
<$ typeList(param.typeList) $> <$ typeList(param.typeList) $>
</td> </td>
<td> <td>
<$ param.description | marked $> <$ param.description | marked $>
<@ if param.defaultValue @><p><em>(default: <$ param.defaultValue $>)</em></p><@ endif @> <@- if param.defaultValue @><p><em>(default: <$ param.defaultValue $>)</em></p><@ endif -@>
</td> </td>
</tr> </tr>
<@ endfor @> <@ endfor -@>
</tbody> </tbody>
</table> </table>
<@- endmacro -@> <@- endmacro -@>
<@- macro functionSyntax(fn) @> <@- macro functionSyntax(fn) @>
<@- set sep = joiner(',&nbsp;') -@> <@- set sep = joiner(',&nbsp;') -@>
<code><$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $> <code><$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $>
@ -96,89 +85,64 @@ docType: "<$ doc.docType $>"
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @> <@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
<@ endmacro -@> <@ endmacro -@>
<@ macro typeList(types) -@> <@- macro typeList(types) -@>
<@ set separator = joiner("|") @> <@ set separator = joiner("|") @>
<@ for type in types @><$ separator() $><$ type | code $><@ endfor @> <@- for type in types @><$ separator() $><$ type | code $><@ endfor -@>
<@- endmacro -@> <@- endmacro -@>
<@- macro typeInfo(fn) -@> <@- macro typeInfo(fn) -@>
<$ typeList(fn.typeList) $> <$ fn.description $> <$ typeList(fn.typeList) $> <$ fn.description $>
<@- endmacro -@> <@- endmacro -@>
<@- macro documentPlatforms(method) -@>
<@ macro documentClass(doc) @>
<@- if doc.statics.length -@>
<h2>Static Members</h2>
<@ for method in doc.statics -@>
<@ if not method.internal @>
<div id="<$ method.name $>"></div>
<h3><$ functionSyntax(method) $></h3>
<@- if method.decorators @> <@- if method.decorators @>
<@ for prop in method.decorators[0].argumentInfo @> <@ for prop in method.decorators[0].argumentInfo @>
<@ if prop.platforms @> <@ if prop.platforms @>
<p> <p>
<b>Platforms:</b> <strong>Platforms:</strong>
<@- for platform in prop.platforms @> <@- for platform in prop.platforms -@>
<code><$ platform $></code>&nbsp; <strong class="tag"><$ platform $></strong>&nbsp;
<@ endfor -@> <@- endfor -@>
</p> </p>
<@ endif @> <@ endif @>
<@ endfor @> <@ endfor @>
<@- endif @> <@- endif @>
<@- endmacro -@>
<$ method.description $> <@- macro documentMethod(method) -@>
<h3><a class="anchor" name="<$ method.name $>" href="#<$ method.name $>"></a><$ functionSyntax(method) $></h3>
<@ if method.params @> <$ documentPlatforms(method) $>
<$ paramTable(method.params) $>
<@ endif @>
<@ if method.this -@>
<h4> Method's `this`
<$ method.this $>
</h4>
<@- endif @>
<@ if method.returns @>
<div class="return-value" markdown="1">
<i class="icon ion-arrow-return-left"></i>
<b>Returns:</b> <$ typeInfo(method.returns) $>
</div>
<@ endif @>
<@ endif @>
<@ endfor -@>
<@ endif @>
<!-- methods on the class -->
<@- if doc.members and doc.members.length @>
<h2>Instance Members</h2>
<@ for method in doc.members -@>
<div id="<$ method.name $>"></div>
<h3>
<$ functionSyntax(method) $>
</h3>
<$ method.description $> <$ method.description $>
<@ if method.params -@> <@ if method.params -@>
<$ paramTable(method.params) $> <$ paramTable(method.params) $>
<@- endif @> <@- endif @>
<@ if method.this -@>
<h4> Method's `this`
<$ method.this $>
</h4>
<@- endif @>
<@ if method.returns -@> <@ if method.returns -@>
<div class="return-value" markdown="1"> <div class="return-value" markdown="1">
<i class="icon ion-arrow-return-left"></i> <i class="icon ion-arrow-return-left"></i>
<b>Returns:</b> <$ typeInfo(method.returns) $> <b>Returns:</b> <$ typeInfo(method.returns) $>
</div> </div>
<@- endif @> <@- endif @>
<@- endmacro -@>
<@- macro documentClass(doc) @>
<@- if doc.statics.length -@>
<h2>Static Members</h2>
<@ for method in doc.statics -@>
<$ documentMethod(method) $>
<@ endfor -@>
<@ endif @>
<# --- methods in class --- #>
<@- if doc.members and doc.members.length @>
<h2>Instance Members</h2>
<@ for method in doc.members -@>
<$ documentMethod(method) $>
<@- endfor @> <@- endfor @>
<@- endif -@> <@- endif -@>
<@ endmacro @> <@- endmacro -@>
<@ block body @>
<@ block content @>
<@ block header @>
<h1 class="api-title"> <h1 class="api-title">
<@ if doc.docType == "directive" @> <@ if doc.docType == "directive" @>
<$ doc.name | dashCase $> <$ doc.name | dashCase $>
@ -208,13 +172,9 @@ docType: "<$ doc.docType $>"
Improve this doc Improve this doc
</a> </a>
<@ endblock @> <# --- Decorators --- #>
<!-- decorators -->
<@- if doc.decorators @> <@- if doc.decorators @>
<@ for prop in doc.decorators[0].argumentInfo @> <@ for prop in doc.decorators[0].argumentInfo @>
<@ if doc.beta == true @> <@ if doc.beta == true @>
<p class="beta-notice"> <p class="beta-notice">
This plugin is still in beta stage and may not work as expected. Please 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</a>. href="<$ prop.repo $>/issues">plugin repo</a>.
</p> </p>
<@ endif @> <@ endif @>
<pre><code class="nohighlight">$ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @> <pre><code class="nohighlight">$ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @>
$ npm install --save @ionic-native/<$ doc.npmId $> $ npm install --save @ionic-native/<$ doc.npmId $>
</code></pre> </code></pre>
@ -232,48 +191,34 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
</a> </a>
</p> </p>
<!-- description --> <# --- Plugin description --- #>
<@ block description @>
<$ doc.description | marked $> <$ doc.description | marked $>
<@ endblock @>
<@- if doc.directiveInfo @>
<h2><$ doc.directiveInfo.type $></h2>
<h3><$ doc.directiveInfo.properties[0].name $>: <code><$ doc.directiveInfo.properties[0].values $></code></h3>
<@ endif -@>
<# --- Plugin supported platforms --- #>
<@ if prop.platforms @> <@ if prop.platforms @>
<!-- @platforms tag -->
<h2>Supported platforms</h2> <h2>Supported platforms</h2>
<@ block platforms @>
<ul> <ul>
<@ for platform in prop.platforms -@> <@ for platform in prop.platforms -@>
<li><$ platform $></li> <li><$ platform $></li>
<@- endfor @> <@- endfor @>
</ul> </ul>
<@ endblock @>
<!-- @platforms tag end -->
<@ endif @> <@ endif @>
<@ endfor @> <@ endfor @>
<@ endif -@><!-- if doc.decorators --> <@ endif -@> <# --- end of: if doc.decorators --- #>
<!-- @usage tag --> <# --- Plugin usage --- #>
<@ if doc.usage @> <@ if doc.usage @>
<h2>Usage</h2> <h2>Usage</h2>
<@ block usage @>
<$ doc.usage | marked $> <$ doc.usage | marked $>
<@ endblock @>
<@ endif @> <@ endif @>
<!-- @property tags --> <# --- Plugin attributes --- #>
<@ if doc.properties @> <@- if doc.properties -@>
<h2>Attributes:</h2> <h2>Attributes:</h2>
<table class="table" style="margin:0;"> <table class="table" style="margin:0;">
<thead> <thead>
<tr> <tr>
<th>Attribute</th> <th>Attribute</th>
<@ set hasTypes = false @> <@ set hasTypes = false @>
<@ for prop in doc.properties @> <@ for prop in doc.properties @>
<@ if prop.type @> <@ if prop.type @>
@ -283,12 +228,11 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@ if hasTypes @> <@ if hasTypes @>
<th>Type</th> <th>Type</th>
<@ endif @> <@ endif @>
<th>Description</th> <th>Description</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<@ for prop in doc.properties -@> <@- for prop in doc.properties -@>
<tr> <tr>
<td> <td>
<$ prop.name $> <$ prop.name $>
@ -298,48 +242,44 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<$ prop.type.name $> <$ prop.type.name $>
</td> </td>
<@ endif @> <@ endif @>
<td> <td>
<$ prop.description $> <$ prop.description $>
</td> </td>
</tr> </tr>
<@- endfor @> <@ endfor -@>
</tbody> </tbody>
</table> </table>
<@ endif @> <@- endif -@>
<# --- Plugin class documentation --- #>
<$ documentClass(doc) $> <$ documentClass(doc) $>
<@ block advanced @> <# --- Advanced usage --- #>
<@- if doc.advanced -@> <@- if doc.advanced -@>
<h2><a class="anchor" name="advanced" href="#advanced"></a>Advanced</h2> <h2><a class="anchor" name="advanced" href="#advanced"></a>Advanced</h2>
<$ doc.advanced | marked $> <$ doc.advanced | marked $>
<@- endif -@> <@- endif -@>
<@ endblock @>
<!-- other classes --> <# --- Other classes --- #>
<@ for tag in doc.tags.tags -@> <@- for tag in doc.tags.tags -@>
<@ if tag.tagName == 'classes' -@> <@- if tag.tagName == 'classes' -@>
<!--<h2><a class="anchor" name="related-classes" href="#related-classes"></a>Related Classes</h2>--> <@- set classes = tag.description.split('\n') -@>
<@ set classes = tag.description.split('\n') @> <@- for item in classes -@>
<@ for item in classes -@> <@- if item.length > 1 -@>
<@ if item.length > 1 @> <@- for export in doc.moduleDoc.exports -@>
<@ for export in doc.moduleDoc.exports -@> <@- if export.name == item -@>
<@ if export.name == item @>
<h2><a class="anchor" name="<$ item $>" href="#<$ item $>"></a><$ item $></h2> <h2><a class="anchor" name="<$ item $>" href="#<$ item $>"></a><$ item $></h2>
<$ documentClass(export) $> <$ documentClass(export) $>
<@ endif @> <@- endif -@>
<@- endfor @> <@- endfor -@>
<@ endif @> <@- endif -@>
<@- endfor @> <@- endfor -@>
<@- endif @> <@- endif -@>
<@- endfor @> <@- endfor -@>
<!-- end other classes -->
<!-- interfaces --> <# --- Other interfaces --- #>
<@ for tag in doc.tags.tags -@> <@ for tag in doc.tags.tags -@>
<@ if tag.tagName == 'interfaces' @> <@ if tag.tagName == 'interfaces' @>
<!--<h2><a class="anchor" name="interfaces" href="#interfaces"></a>Interfaces</h2>-->
<@ set interfaces = tag.description.split('\n') @> <@ set interfaces = tag.description.split('\n') @>
<@ for item in interfaces -@> <@ for item in interfaces -@>
<@ if item.length > 1 @> <@ if item.length > 1 @>
@ -349,21 +289,12 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@- endfor @> <@- endfor @>
<@ endif @> <@ endif @>
<@- endfor @> <@- endfor @>
<!-- end interfaces -->
<!-- related link -->
<# --- Related links --- #>
<@- if doc.see @> <@- if doc.see @>
<h2><a class="anchor" name="related" href="#related"></a>Related</h2>
<h2>Related</h2>
<@ for s in doc.see @> <@ for s in doc.see @>
<$ s | safe $> <$ s | safe $>
<@- endfor -@> <@- endfor -@>
<@- endif -@> <@- endif -@>
<!-- end content block -->
<@ endblock @>
<!-- end body block -->
<@ endblock @>