From da109514ae4a91da5d9c992bbe193a0f3d7860b3 Mon Sep 17 00:00:00 2001 From: perry Date: Mon, 20 Mar 2017 17:13:47 -0500 Subject: [PATCH] chore(dgeni): fixing npm install instructions --- scripts/docs/dgeni-config.js | 1 + scripts/docs/dgeni-readmes-config.js | 1 + scripts/docs/processors/npm-id.js | 24 +++++++++++++++++++++ scripts/docs/processors/readmes.js | 4 +--- scripts/docs/templates/common.template.html | 5 ++--- 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 scripts/docs/processors/npm-id.js diff --git a/scripts/docs/dgeni-config.js b/scripts/docs/dgeni-config.js index 5b47e9f78..a317be29e 100644 --- a/scripts/docs/dgeni-config.js +++ b/scripts/docs/dgeni-config.js @@ -20,6 +20,7 @@ module.exports = function(currentVersion) { .processor(require('./processors/remove-private-members')) .processor(require('./processors/hide-private-api')) .processor(require('./processors/collect-inputs-outputs')) +.processor(require('./processors/npm-id')) // for debugging docs // .processor(function test(){ diff --git a/scripts/docs/dgeni-readmes-config.js b/scripts/docs/dgeni-readmes-config.js index 2a58f85ea..77cbe300b 100644 --- a/scripts/docs/dgeni-readmes-config.js +++ b/scripts/docs/dgeni-readmes-config.js @@ -19,6 +19,7 @@ module.exports = function(currentVersion) { // .processor(require('./processors/latest-version')) .processor(require('./processors/readmes')) +.processor(require('./processors/npm-id')) .processor(require('./processors/remove-private-members')) .processor(require('./processors/hide-private-api')) // .processor(require('./processors/collect-inputs-outputs')) diff --git a/scripts/docs/processors/npm-id.js b/scripts/docs/processors/npm-id.js new file mode 100644 index 000000000..259c19d58 --- /dev/null +++ b/scripts/docs/processors/npm-id.js @@ -0,0 +1,24 @@ +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; + + // 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) { + doc.npmId = doc.outputPath.replace('/README.md', '') + .replace('src/@ionic-native/plugins/','') + .replace('@ionic-native/plugins/',''); + }); + + // returning docs will replace docs object in the next process + return docs; + } + }; +}; diff --git a/scripts/docs/processors/readmes.js b/scripts/docs/processors/readmes.js index e5c1f458c..dde2001bf 100644 --- a/scripts/docs/processors/readmes.js +++ b/scripts/docs/processors/readmes.js @@ -1,4 +1,4 @@ -module.exports = function jekyll(renderDocsProcessor) { +module.exports = function readmes(renderDocsProcessor) { return { name: 'readmes', description: 'Create jekyll includes', @@ -13,8 +13,6 @@ module.exports = function jekyll(renderDocsProcessor) { }); docs.forEach(function(doc, i) { - doc.npmId = doc.outputPath.replace('/README.md', '') - .replace('src/@ionic-native/plugins/',''); doc.outputPath = doc.outputPath.replace('src/', ''); }); diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html index 307e77017..2277721b2 100644 --- a/scripts/docs/templates/common.template.html +++ b/scripts/docs/templates/common.template.html @@ -224,9 +224,8 @@ docType: "<$ doc.docType $>"

<@ endif @> -

-  $ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @>
-  $ npm install --save @ionic-native/<$ prop.pluginRef $>
+
$ <@ if prop.install @><$ prop.install $><@ else @>ionic plugin add <$ prop.plugin $><@ endif @>
+$ npm install --save @ionic-native/<$ prop.npmId $>
 

Repo: