From bc02c9573cc10ca4a9ae70514be019dbfc2c83c7 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 16 Nov 2018 10:04:53 +0000 Subject: [PATCH] Generate runtime api docs in runtime module --- .gitignore | 1 + Gruntfile.js | 2 +- .../@node-red/runtime/lib/api/context.js | 4 ++-- .../@node-red/runtime/lib/api/index.js | 18 ++++++++++++------ .../@node-red/runtime/lib/index.js | 5 ++--- packages/node_modules/node-red/lib/red.js | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 25fca64a5..c3fa9624a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ nodes/core/locales/zz-ZZ packages/node_modules/@node-red/editor-client/public !test/**/node_modules docs +!packages/node_modules/**/docs diff --git a/Gruntfile.js b/Gruntfile.js index 1d345c5de..317cb7eba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -450,7 +450,7 @@ module.exports = function(grunt) { separators: true }, src: 'packages/node_modules/@node-red/runtime/lib/api/*.js', - dest: 'docs/runtime-api.md' + dest: 'packages/node_modules/@node-red/runtime/docs/api.md' }, nodeREDUtil: { options: { diff --git a/packages/node_modules/@node-red/runtime/lib/api/context.js b/packages/node_modules/@node-red/runtime/lib/api/context.js index 64eddda93..cbe665e53 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/context.js +++ b/packages/node_modules/@node-red/runtime/lib/api/context.js @@ -69,7 +69,7 @@ var api = module.exports = { * @param {String} opts.key - the context key * @return {Promise} - the node information - * @memberof RED.nodes + * @memberof RED.context */ getValue: function(opts) { return new Promise(function(resolve,reject) { @@ -163,7 +163,7 @@ var api = module.exports = { * @param {String} opts.key - the context key * @return {Promise} - the node information - * @memberof RED.nodes + * @memberof RED.context */ delete: function(opts) { return new Promise(function(resolve,reject) { diff --git a/packages/node_modules/@node-red/runtime/lib/api/index.js b/packages/node_modules/@node-red/runtime/lib/api/index.js index da04e191c..2b315c0dc 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/index.js +++ b/packages/node_modules/@node-red/runtime/lib/api/index.js @@ -1,4 +1,4 @@ -/** +/*! * Copyright JS Foundation and other contributors, http://js.foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +14,14 @@ * limitations under the License. **/ -/** - * A user accessing the API - * @typedef User - * @type {object} - */ + var runtime; /** + * This module provides the core runtime component of Node-RED. + * It does *not* include the Node-RED editor. All interaction with + * this module is done using the api provided. + * * @namespace RED */ var api = module.exports = { @@ -66,3 +66,9 @@ var api = module.exports = { return Promise.resolve(runtime.version()); } } + +/** + * A user accessing the API + * @typedef User + * @type {object} + */ diff --git a/packages/node_modules/@node-red/runtime/lib/index.js b/packages/node_modules/@node-red/runtime/lib/index.js index fd6e59794..2ca92a4f0 100644 --- a/packages/node_modules/@node-red/runtime/lib/index.js +++ b/packages/node_modules/@node-red/runtime/lib/index.js @@ -30,7 +30,7 @@ var path = require('path'); var fs = require("fs"); var os = require("os"); -var redUtil; +var redUtil = require("@node-red/util"); var log; var i18n; @@ -57,8 +57,7 @@ var adminApi = { var nodeApp; -function init(userSettings,_redUtil,_adminApi) { - redUtil = _redUtil; +function init(userSettings,_adminApi) { log = redUtil.log; i18n = redUtil.i18n; userSettings.version = getVersion(); diff --git a/packages/node_modules/node-red/lib/red.js b/packages/node_modules/node-red/lib/red.js index d7893464c..128869c43 100644 --- a/packages/node_modules/node-red/lib/red.js +++ b/packages/node_modules/node-red/lib/red.js @@ -54,14 +54,14 @@ module.exports = { } redUtil.init(userSettings); if (userSettings.httpAdminRoot !== false) { - runtime.init(userSettings,redUtil,api); + runtime.init(userSettings,api); api.init(httpServer,userSettings,runtime._.storage,runtime); apiEnabled = true; server = runtime._.adminApi.server; runtime._.server = runtime._.adminApi.server; } else { - runtime.init(userSettings,redUtil); + runtime.init(userSettings); apiEnabled = false; if (httpServer){ server = httpServer;