From f3eb5fd3f2ef007b2c0432a7e81bde9be580c131 Mon Sep 17 00:00:00 2001 From: Brian Dennis Date: Mon, 25 Jul 2016 11:33:13 -0500 Subject: [PATCH] docs(optional): add syntax to flag params as optional --- scripts/docs/dgeni-config.js | 1 + scripts/docs/processors/parse-optional.js | 21 +++++++++++++++++++++ src/components/slides/slides.ts | 12 ++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 scripts/docs/processors/parse-optional.js diff --git a/scripts/docs/dgeni-config.js b/scripts/docs/dgeni-config.js index 492021a22c4..fb6b5570c8b 100644 --- a/scripts/docs/dgeni-config.js +++ b/scripts/docs/dgeni-config.js @@ -24,6 +24,7 @@ module.exports = function(currentVersion, initialVersionBuild) { .processor(require('./processors/hide-private-api')) .processor(require('./processors/collect-inputs-outputs')) .processor(require('./processors/parse-returns-object')) +.processor(require('./processors/parse-optional')) // for debugging docs // .processor(function test(){ diff --git a/scripts/docs/processors/parse-optional.js b/scripts/docs/processors/parse-optional.js new file mode 100644 index 00000000000..1cb50ebdcea --- /dev/null +++ b/scripts/docs/processors/parse-optional.js @@ -0,0 +1,21 @@ +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){ + doc.members[i].params[ii].description += 'Optional'; + } + } + } + } + } + }); + return docs; + } + } +}; diff --git a/src/components/slides/slides.ts b/src/components/slides/slides.ts index 405473357af..5cd060efdde 100644 --- a/src/components/slides/slides.ts +++ b/src/components/slides/slides.ts @@ -743,8 +743,8 @@ export class Slides extends Ion { * Transition to the specified slide. * * @param {number} index The index number of the slide. - * @param {number} speed Transition duration (in ms). Optional. - * @param {boolean} runCallbacks Whether or not to emit the `ionWillChange`/`ionDidChange` events. Optional. Default true. + * @param {number} [speed] Transition duration (in ms). + * @param {boolean} [runCallbacks] Whether or not to emit the `ionWillChange`/`ionDidChange` events. Default true. */ slideTo(index: number, speed?: number, runCallbacks?: boolean) { this.slider.slideTo(index, speed, runCallbacks); @@ -753,8 +753,8 @@ export class Slides extends Ion { /** * Transition to the next slide. * - * @param {number} speed Transition duration (in ms). Optional. - * @param {boolean} runCallbacks Whether or not to emit the `ionWillChange`/`ionDidChange` events. Optional. Default true. + * @param {number} [speed] Transition duration (in ms). + * @param {boolean} [runCallbacks] Whether or not to emit the `ionWillChange`/`ionDidChange` events. Default true. */ slideNext(speed?: number, runCallbacks?: boolean) { this.slider.slideNext(runCallbacks, speed); @@ -763,8 +763,8 @@ export class Slides extends Ion { /** * Transition to the previous slide. * - * @param {number} speed Transition duration (in ms). Optional. - * @param {boolean} runCallbacks Whether or not to emit the `ionWillChange`/`ionDidChange` events. Optional. Default true. + * @param {number} [speed] Transition duration (in ms). + * @param {boolean} [runCallbacks] Whether or not to emit the `ionWillChange`/`ionDidChange` events. Default true. */ slidePrev(speed?: number, runCallbacks?: boolean) { this.slider.slidePrev(runCallbacks, speed);