aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/jsextensions
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-02-01 04:55:39 -0800
committerJake Petroules <jake.petroules@qt.io>2017-02-15 00:03:01 +0000
commit7ba540b35f894fbfcf93fcda9e56eeb321edb1fe (patch)
tree15709e8c48a0cd691dff86ff07d2f220670fea70 /doc/reference/jsextensions
parent58b4f1395f0a394cf040e1afe994ddb84fbfebeb (diff)
Deprecate loadFile and loadExtension in favor of require
This is more in line with mainstream JavaScript (especially node.js) which uses the CommonJS/RequireJS scheme for loading external modules. [ChangeLog] The loadFile and loadExtension functions are deprecated in favor of the new require function, which accepts arguments of either form accepted by the deprecated functions. Change-Id: Icc00aa3eb7c136a5be787f28ef38435e4ce261bb Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'doc/reference/jsextensions')
-rw-r--r--doc/reference/jsextensions/jsextensions-general.qdoc27
1 files changed, 10 insertions, 17 deletions
diff --git a/doc/reference/jsextensions/jsextensions-general.qdoc b/doc/reference/jsextensions/jsextensions-general.qdoc
index ed7b26f8a..383f7b2bf 100644
--- a/doc/reference/jsextensions/jsextensions-general.qdoc
+++ b/doc/reference/jsextensions/jsextensions-general.qdoc
@@ -38,27 +38,20 @@
\section1 Available Operations
- \section2 loadFile
+ \section2 require
\code
- loadFile(filePath: string): any
+ require(identifier: string): any
\endcode
- Loads a JavaScript file and returns an object that contains the evaluated context of this file.
- This function is only available in JavaScript files.
- For example:
+ Loads an extension and returns an object representing the extension.
+ If \a identifier is a relative or absolute file path, this function will load a JavaScript file
+ and return an object containing the evaluated context of that file. Otherwise, loads a \QBS
+ extension named \a identifier and returns an object that contains the extension's context.
+ This function is only available in JavaScript files and is designed to behave similarly to the
+ CommonJS/RequireJS/Node.js module resolution systems.
\code
- var MyFunctions = loadFile("myfunctions.js");
+ var MyFunctions = require("./myfunctions.js");
MyFunctions.doSomething();
- \endcode
-
- \section2 loadExtension
- \code
- loadExtension(extensionName: string): any
- \endcode
- Loads a \QBS extension and returns an object that contains all functions of that extension.
- This function is only available in JavaScript files.
- For example:
- \code
- var FileInfo = loadExtension("qbs.FileInfo");
+ var FileInfo = require("qbs.FileInfo");
var fileName = FileInfo.fileName(filePath);
\endcode