Merge pull request #1243 from driftyco/es6-docs

chore(docs): cleanup and enhancements
This commit is contained in:
Perry Govier 2017-03-24 11:11:48 -05:00 committed by GitHub
commit e4fc01a23c
30 changed files with 346 additions and 683 deletions

View File

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

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,79 @@
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/mark-properties'))
.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'
];
});
};

View File

@ -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.

View File

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

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

View File

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

View File

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

View File

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

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

View File

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

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

@ -0,0 +1,15 @@
"use strict";
module.exports = function markProperties() {
return {
name: 'mark-properties',
$runBefore: ['rendering-docs'],
$process: docs => docs.map(doc => {
for (let i in doc.members) {
if (doc.members.hasOwnProperty(i) && typeof doc.members[i].parameters === 'undefined') {
doc.members[i].isProperty = true;
}
}
return doc;
})
}
};

View File

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

View File

@ -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 += '<strong class="tag">Optional</strong>';
}
}

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ doc: "<$ doc.name $>"
docType: "<$ doc.docType $>"
---
<@ macro interfaceTable(interface) @>
<@- macro interfaceTable(interface) -@>
<@ for export in doc.moduleDoc.exports -@>
<@ if export.name == interface @>
<table class="table param-table" style="margin:0;">
@ -39,24 +39,15 @@ docType: "<$ doc.docType $>"
<@ endfor @>
</tbody>
</table>
<@ endif @>
<@- 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 -@>
<@ 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>
<@- endmacro -@>
<@ macro paramTable(params, isDirective) -@>
<@- macro paramTable(params, isDirective) -@>
<table class="table param-table" style="margin:0;">
<thead>
<tr>
@ -66,139 +57,93 @@ docType: "<$ doc.docType $>"
</tr>
</thead>
<tbody>
<@ for param in params @>
<@- for param in params @>
<tr>
<td>
<$ param.name $>
<@ if param.alias @>| <$ param.alias $><@ endif @>
<@- if param.alias @>| <$ param.alias $><@ endif -@>
</td>
<td>
<$ typeList(param.typeList) $>
</td>
<td>
<$ 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>
</tr>
<@ endfor @>
<@ endfor -@>
</tbody>
</table>
<@- endmacro -@>
<@- macro functionSyntax(fn) @>
<@- set sep = joiner(',&nbsp;') -@>
<code><$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $>
<@- if param.type.optional @>[<@ endif -@>
<@- if param.type.optional @>[<@- endif -@>
<$ param.name $>
<@- if param.type.optional @>]<@ endif -@>
<@ endfor @><@- if not fn.isProperty @>)<@ endif -@></code>
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
<@ endmacro -@>
<@- if param.type.optional -@>]<@- endif -@>
<@- endfor -@><@- if not fn.isProperty @>)<@- endif -@></code>
<@- 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 -@>
<h2>Static Members</h2>
<@ for method in doc.statics -@>
<@ if not method.internal @>
<div id="<$ method.name $>"></div>
<h3><$ functionSyntax(method) $></h3>
<@- macro documentPlatforms(method) -@>
<@- if method.decorators @>
<@ for prop in method.decorators[0].argumentInfo @>
<@ if prop.platforms @>
<p>
<b>Platforms:</b>
<@- for platform in prop.platforms @>
<code><$ platform $></code>&nbsp;
<@ endfor -@>
<strong>Platforms:</strong>
<@- for platform in prop.platforms -@>
<strong class="tag"><$ platform $></strong>&nbsp;
<@- endfor -@>
</p>
<@ endif @>
<@ endfor @>
<@- endif @>
<@- endmacro -@>
<$ method.description $>
<@ if method.params @>
<$ paramTable(method.params) $>
<@ endif @>
<@ if method.this -@>
<h4> Method's `this`
<$ method.this $>
</h4>
<@- endif @>
<@ if method.returns @>
<div class="return-value" 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>
<@ macro documentMethod(method) -@>
<h3><a class="anchor" name="<$ method.name $>" href="#<$ method.name $>"></a><$ functionSyntax(method) $></h3>
<$ documentPlatforms(method) $>
<$ method.description $>
<@ if method.params -@>
<$ paramTable(method.params) $>
<@- endif @>
<@ if method.this -@>
<h4> Method's `this`
<$ method.this $>
</h4>
<@- endif @>
<@ if method.returns -@>
<div class="return-value" markdown="1">
<i class="icon ion-arrow-return-left"></i>
<b>Returns:</b> <$ typeInfo(method.returns) $>
</div>
<@- 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 @>
<@- endif -@>
<@ endmacro @>
<@ block body @>
<@ block content @>
<@ block header @>
<h1 class="api-title">
<@ if doc.docType == "directive" @>
<$ doc.name | dashCase $>
<@ else @>
<$ doc.name $>
<@ endif @>
<@ if doc.parent @>
<br />
<small>
Child of <$ doc.parent $>
</small>
<@ endif @>
<@ if doc.delegate @>
<br/>
<small>
Delegate: <$ doc.delegate $>
</small>
<@ endif @>
<h1 class="api-title"><$ doc.name $>
<@- if doc.beta == true -@>
<span class="beta" title="beta">&beta;</span>
<@- endif -@>
@ -208,13 +153,9 @@ docType: "<$ doc.docType $>"
Improve this doc
</a>
<@ endblock @>
<!-- decorators -->
<# --- Decorators --- #>
<@- if doc.decorators @>
<@ for prop in doc.decorators[0].argumentInfo @>
<@ if doc.beta == true @>
<p class="beta-notice">
This plugin is still in beta stage and may not work as expected. Please
@ -223,6 +164,7 @@ docType: "<$ doc.docType $>"
</p>
<@ endif @>
<# --- Install commands --- #>
<pre><code class="nohighlight">$ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @>
$ npm install --save @ionic-native/<$ doc.npmId $>
</code></pre>
@ -232,48 +174,34 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
</a>
</p>
<!-- description -->
<@ block description @>
<# --- Plugin description --- #>
<$ doc.description | marked $>
<@ endblock @>
<@- if doc.directiveInfo @>
<h2><$ doc.directiveInfo.type $></h2>
<h3><$ doc.directiveInfo.properties[0].name $>: <code><$ doc.directiveInfo.properties[0].values $></code></h3>
<@ endif -@>
<# --- Plugin supported platforms --- #>
<@ if prop.platforms @>
<!-- @platforms tag -->
<h2>Supported platforms</h2>
<@ block platforms @>
<ul>
<@ for platform in prop.platforms -@>
<li><$ platform $></li>
<@- endfor @>
</ul>
<@ endblock @>
<!-- @platforms tag end -->
<@ endif @>
<@ endfor @>
<@ endif -@><!-- if doc.decorators -->
<@ endif -@> <# --- end of: if doc.decorators --- #>
<!-- @usage tag -->
<# --- Plugin usage --- #>
<@ if doc.usage @>
<h2>Usage</h2>
<@ block usage @>
<$ doc.usage | marked $>
<@ endblock @>
<@ endif @>
<!-- @property tags -->
<@ if doc.properties @>
<# --- Plugin attributes --- #>
<@- if doc.properties -@>
<h2>Attributes:</h2>
<table class="table" style="margin:0;">
<thead>
<tr>
<th>Attribute</th>
<@ set hasTypes = false @>
<@ for prop in doc.properties @>
<@ if prop.type @>
@ -283,12 +211,11 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@ if hasTypes @>
<th>Type</th>
<@ endif @>
<th>Description</th>
</tr>
</thead>
<tbody>
<@ for prop in doc.properties -@>
<@- for prop in doc.properties -@>
<tr>
<td>
<$ prop.name $>
@ -298,48 +225,44 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<$ prop.type.name $>
</td>
<@ endif @>
<td>
<$ prop.description $>
</td>
</tr>
<@- endfor @>
<@ endfor -@>
</tbody>
</table>
<@ endif @>
<@- endif -@>
<# --- Plugin class documentation --- #>
<$ documentClass(doc) $>
<@ block advanced @>
<# --- Advanced usage --- #>
<@- if doc.advanced -@>
<h2><a class="anchor" name="advanced" href="#advanced"></a>Advanced</h2>
<$ doc.advanced | marked $>
<@- endif -@>
<@ endblock @>
<!-- other classes -->
<@ for tag in doc.tags.tags -@>
<@ if tag.tagName == 'classes' -@>
<!--<h2><a class="anchor" name="related-classes" href="#related-classes"></a>Related Classes</h2>-->
<@ 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 -@>
<h2><a class="anchor" name="<$ item $>" href="#<$ item $>"></a><$ item $></h2>
<$ documentClass(export) $>
<@ endif @>
<@- endfor @>
<@ endif @>
<@- endfor @>
<@- endif @>
<@- endfor @>
<!-- end other classes -->
<@- endif -@>
<@- endfor -@>
<@- endif -@>
<@- endfor -@>
<@- endif -@>
<@- endfor -@>
<!-- interfaces -->
<# --- Other interfaces --- #>
<@ for tag in doc.tags.tags -@>
<@ if tag.tagName == 'interfaces' @>
<!--<h2><a class="anchor" name="interfaces" href="#interfaces"></a>Interfaces</h2>-->
<@ set interfaces = tag.description.split('\n') @>
<@ for item in interfaces -@>
<@ if item.length > 1 @>
@ -349,21 +272,12 @@ $ npm install --save @ionic-native/<$ doc.npmId $>
<@- endfor @>
<@ endif @>
<@- endfor @>
<!-- end interfaces -->
<!-- related link -->
<# --- Related links --- #>
<@- if doc.see @>
<h2>Related</h2>
<h2><a class="anchor" name="related" href="#related"></a>Related</h2>
<@ for s in doc.see @>
<$ s | safe $>
<@- endfor -@>
<@- endif -@>
<!-- end content block -->
<@ endblock @>
<!-- end body block -->
<@ endblock @>

View File

@ -90,7 +90,7 @@ export interface CameraPopoverOptions {
* @description
* Take a photo or capture video.
*
* Requires {@link module:driftyco/ionic-native} and the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
* Requires and the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
*
* @usage
* ```typescript
@ -120,7 +120,6 @@ export interface CameraPopoverOptions {
* CameraOptions
* CameraPopoverOptions
*/
@Injectable()
@Plugin({
pluginName: 'Camera',
plugin: 'cordova-plugin-camera',
@ -128,6 +127,7 @@ export interface CameraPopoverOptions {
repo: 'https://github.com/apache/cordova-plugin-camera',
platforms: ['Android', 'BlackBerry', 'Browser', 'Firefox', 'FireOS', 'iOS', 'Windows', 'Windows Phone 8', 'Ubuntu']
})
@Injectable()
export class Camera {
/**

View File

@ -82,7 +82,6 @@ declare var window: any;
repo: 'https://github.com/cowbell/cordova-plugin-geofence/',
platforms: ['Android', 'iOS', 'Windows Phone 8', 'Windows Phone']
})
@Injectable()
export class Geofence {

View File

@ -167,13 +167,13 @@ export interface HealthData {
* HealthStoreOptions
* HealthData
*/
@Injectable()
@Plugin({
pluginName: 'Health',
plugin: 'cordova-plugin-health',
pluginRef: 'navigator.health',
repo: 'https://github.com/dariosalvi78/cordova-plugin-health'
})
@Injectable()
export class Health {
/**

View File

@ -109,12 +109,12 @@ export class Mixpanel {
/**
* @hidden
*/
@Injectable()
@Plugin({
plugin: 'cordova-plugin-mixpanel',
pluginRef: 'mixpanel.people',
pluginName: 'Mixpanel'
})
@Injectable()
export class MixpanelPeople {
/**

View File

@ -184,12 +184,12 @@ export class NFC {
/**
* @hidden
*/
@Injectable()
@Plugin({
pluginName: 'NFC',
plugin: 'phonegap-nfc',
pluginRef: 'ndef'
})
@Injectable()
export class Ndef {
@Cordova({ sync: true })