Skip to content

Commit

Permalink
Merge pull request #41 from stanford-oval/wip/jsdoc
Browse files Browse the repository at this point in the history
Document the Thingpedia SDK with jsdoc
  • Loading branch information
gcampax committed Oct 21, 2019
2 parents b925cae + 72855be commit 592f3f2
Show file tree
Hide file tree
Showing 25 changed files with 1,257 additions and 215 deletions.
37 changes: 37 additions & 0 deletions index.js
Expand Up @@ -26,22 +26,59 @@ const BasePlatform = require('./lib/base_platform');

const ThingTalk = require('thingtalk');

/**
* Versioning information for the library.
*
* Use this object to check if the currently loaded Thingpedia SDK
* is compatible with your device, and to dynamically check if a specific
* feature is present.
*
* Note: you should never bundle the Thingpedia SDK with your device.
*
* @alias version
* @namespace
*/
const VERSION = {
/** Major version number (incremented on incompatible changes) */
major: 2,
/** Minor version number (incremented on feature additions) */
minor: 6,
/** Full version string, in semantic version format */
full: '2.6.0-alpha.1',
/** Convert the version number to a number (for comparisons) */
valueOf() {
return this.major * 100 + this.minor;
},
toString() {
return this.full;
},
/**
* Check if the current version is compatible with the passed in version
*
* @param {number|Version} v - the version, as a number or object with `major`
* and minor properties
* @return {Boolean}
*/
compatible(v) {
if (typeof v === 'number')
return this.valueOf() >= v && Math.floor(v/100) === this.major;
else
return this.major === v.major && this.minor >= v.minor;
},
/**
* Check if the given feature is present.
*
* It is ok to pass invalid or unrecognized feature names to this function,
* which will then return `false`.
*
* In this version of the library, the following feature names are recognized:
* - `rss`: RSS helpers and loaders
* - `value-types`: ThingTalk value types are re-exported
* - `thingpedia-client`: Thingpedia Client APIs are present
*
* @param {String} f - a feature name
* @return {Boolean} whether the named feature is supported.
*/
hasFeature(f) {
switch (f) {
case 'rss':
Expand Down
23 changes: 23 additions & 0 deletions jsdoc.json
@@ -0,0 +1,23 @@
{
"plugins": [
"plugins/markdown"
],
"recurseDepth": 10,
"source": {
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"sourceType": "module",
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
},
"templates": {
"cleverLinks": true,
"monospaceLinks": true,
"default": {
"useLongnameInNav": true
}
}
}

22 changes: 20 additions & 2 deletions lib/base_client.js
Expand Up @@ -11,10 +11,27 @@

const Mixins = require('./mixins.json');

module.exports = class ThingpediaClientBase {
/**
* The base class of all clients to access the Thingpedia API.
*
* Accessing the Thingpedia API from Almond occurs in a platform-specific manner,
* through clients that extend this class.
*
* @interface
*/
class BaseClient {
/**
* @protected
*/
constructor() {
}

/**
* The locale to use when querying Thingpedia, as BCP 47 tag.
*
* @type {string}
* @readonly
*/
get locale() {
throw new Error('not implemented');
}
Expand Down Expand Up @@ -100,4 +117,5 @@ module.exports = class ThingpediaClientBase {
mixins[mixin.kind] = mixin;
return Promise.resolve(mixins);
}
};
}
module.exports = BaseClient;

0 comments on commit 592f3f2

Please sign in to comment.