Skip to content

Commit 53b36f6

Browse files
committed
basic doc generation - stil has a few kinks to work out
1 parent af26da4 commit 53b36f6

File tree

28 files changed

+320
-62
lines changed

28 files changed

+320
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ test/resources/auth.js
66
test/integration/
77
test/resources/tts-output.ogg
88
.idea
9+
doc/

.jsdoc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"source": {
3+
"include": [ "lib/", "services/" ]
4+
},
5+
"opts": {
6+
"package": "package.json",
7+
"recurse": true,
8+
"destination": "./doc/"
9+
}
10+
}

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ examples
1212
LICENSE
1313
CONTRIBUTING.md
1414
RELEASE.md
15+
.jsdoc.json

lib/index.js

Lines changed: 166 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function encodeBase64(creds) {
2929
return new Buffer(creds.username + ':' + creds.password).toString('base64');
3030
}
3131

32+
/**
33+
* @private
34+
* @param serviceName
35+
* @returns {Function}
36+
*/
3237
function createServiceAPI(serviceName) {
3338
return function(user_options) {
3439
var options = extend({}, user_options);
@@ -128,37 +133,170 @@ function createServiceAPI(serviceName) {
128133
};
129134
}
130135

131-
var watson = {};
132-
133-
[
134-
'concept_expansion',
135-
'question_and_answer',
136-
'relationship_extraction',
137-
'visual_recognition',
138-
'speech_to_text',
139-
'text_to_speech',
140-
'concept_insights',
141-
'tradeoff_analytics',
142-
'personality_insights',
143-
'natural_language_classifier',
144-
'authorization',
145-
'language_translation',
146-
'tone_analyzer',
147-
'dialog',
148-
'retrieve_and_rank',
149-
'document_conversion',
150-
'visual_insights',
136+
/**
137+
* @namespace
138+
*/
139+
var watson = {
140+
141+
/**
142+
* @function
143+
* @param {{}} options
144+
* @returns {ConceptExpansion}
145+
*/
146+
concept_expansion: createServiceApi('concept_expansion'),
147+
148+
/**
149+
* @function
150+
* @param {{}} options
151+
* @returns {QuestionAndAnswer}
152+
*/
153+
question_and_answer: createServiceApi('question_and_answer'),
154+
155+
/**
156+
* @function
157+
* @param {{}} options
158+
* @returns {RelationshipExtraction}
159+
*/
160+
relationship_extraction: createServiceApi('relationship_extraction'),
161+
162+
/**
163+
* @function
164+
* @param {{}} options
165+
* @returns {VisualRecognitionV1Beta|VisualRecognitionV2Beta}
166+
*/
167+
visual_recognition: createServiceApi('visual_recognition'),
168+
169+
/**
170+
* @function
171+
* @param {{}} options
172+
* @returns {SpeechToText}
173+
*/
174+
speech_to_text: createServiceApi('speech_to_text'),
175+
176+
/**
177+
* @function
178+
* @param {{}} options
179+
* @returns {TextToSpeech}
180+
*/
181+
text_to_speech: createServiceApi('text_to_speech'),
182+
183+
/**
184+
* @function
185+
* @param {{}} options
186+
* @returns {ConceptInsights}
187+
*/
188+
concept_insights: createServiceApi('concept_insights'),
189+
190+
/**
191+
* @function
192+
* @param {{}} options
193+
* @returns {TradeoffAnalytics}
194+
*/
195+
tradeoff_analytics: createServiceApi('tradeoff_analytics'),
196+
197+
/**
198+
* @function
199+
* @param {{}} options
200+
* @returns {PersonalityInsights}
201+
*/
202+
personality_insights: createServiceApi('personality_insights'),
203+
204+
/**
205+
* @function
206+
* @param {{}} options
207+
* @returns {NaturalLanguageClassifier}
208+
*/
209+
natural_language_classifier: createServiceApi('natural_language_classifier'),
210+
211+
/**
212+
* @function
213+
* @param {{}} options
214+
* @returns {Authorization}
215+
*/
216+
authorization: createServiceApi('authorization'),
217+
218+
/**
219+
* @function
220+
* @param {{}} options
221+
* @returns {LanguageTranslation}
222+
*/
223+
language_translation: createServiceApi('language_translation'),
224+
225+
/**
226+
* @function
227+
* @param {{}} options
228+
* @returns {ToneAnalyzer}
229+
*/
230+
tone_analyzer: createServiceApi('tone_analyzer'),
231+
232+
/**
233+
* @function
234+
* @param {{}} options
235+
* @returns {Dialog}
236+
*/
237+
dialog: createServiceApi('dialog'),
238+
239+
/**
240+
* @function
241+
* @param {{}} options
242+
* @returns {RetrieveAndRank}
243+
*/
244+
retrieve_and_rank: createServiceApi('retrieve_and_rank'),
245+
246+
/**
247+
* @function
248+
* @param {{}} options
249+
* @returns {DocumentConversion}
250+
*/
251+
document_conversion: createServiceApi('document_conversion'),
252+
253+
/**
254+
* @function
255+
* @param {{}} options
256+
* @returns {VisualInsights}
257+
*/
258+
visual_insights: createServiceApi('visual_insights'),
259+
151260
// deprecated
152-
'search',
153-
'message_resonance',
261+
/**
262+
* @function
263+
* @param {{}} options
264+
* @returns {Search}
265+
* @deprecated Replaced by {@link RetrieveAndRank}
266+
*/
267+
search: createServiceApi('search'),
268+
269+
/**
270+
* @function
271+
* @param {{}} options
272+
* @returns {MessageResonance}
273+
* @deprecated
274+
*/
275+
message_resonance: createServiceApi('message_resonance'),
154276

155277
// alchemy
156-
'alchemy_language',
157-
'alchemy_vision',
158-
'alchemy_data_news'
278+
/**
279+
* @function
280+
* @param {{}} options
281+
* @returns {AlchemyLanguage}
282+
*/
283+
alchemy_language: createServiceApi('alchemy_language'),
284+
285+
/**
286+
* @function
287+
* @param {{}} options
288+
* @returns {AlchemyVision}
289+
*/
290+
alchemy_vision: createServiceApi('alchemy_vision'),
291+
292+
/**
293+
* @function
294+
* @param {{}} options
295+
* @returns {AlchemyDataNews}
296+
*/
297+
alchemy_data_news: createServiceApi('alchemy_data_news')
298+
};
299+
159300

160-
].forEach(function(api) {
161-
watson[api] = createServiceAPI(api);
162-
});
163301

164302
module.exports = watson;

lib/requestwrapper.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function parsePath(path, params) {
3737
/**
3838
* Check if the service/request have error and try to format them.
3939
* @param {Function} cb the request callback
40+
* @private
4041
*/
4142
function formatErrorIfExists(cb) {
4243
return function(error, response, body) {
@@ -74,6 +75,7 @@ function formatErrorIfExists(cb) {
7475
* 2. Checks for missing parameters
7576
* 3. Encode path and query parameters
7677
* 4. Call the api
78+
* @private
7779
*/
7880
function createRequest(parameters, callback) {
7981
var missingParams = null,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"concat-stream": "^1.5.0",
6262
"coveralls": "^2.11.4",
6363
"istanbul": "^0.4.0",
64+
"jsdoc": "^3.4.0",
6465
"jshint": "^2.8.0",
6566
"mocha": "^2.3.4",
6667
"nock": "^3.4.0",
@@ -86,6 +87,8 @@
8687
"scripts": {
8788
"test": "jshint --exclude ./node_modules/ && mocha --reporter spec --timeout 4000",
8889
"prepare": "npm test && npm version patch",
90+
"doc": "jsdoc -c .jsdoc.json",
91+
"watch-doc": "nodemon --watch lib/ --watch services/ --watch .jsdoc.json --watch package.json --exec npm run doc",
8992
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --reporter spec --timeout 4000",
9093
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
9194
}

services/alchemy_data_news/v1.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ function errorFormatter(cb) {
3636
};
3737
}
3838

39+
/**
40+
* @param options
41+
* @constructor
42+
*/
3943
function AlchemyDataNews(options) {
4044
// Default URL
4145
var serviceDefaults = {
@@ -48,6 +52,10 @@ function AlchemyDataNews(options) {
4852
/**
4953
* Extracts a grouped, ranked list of named entities (people, companies,
5054
* organizations, etc.) from text, a URL or HTML.
55+
* @param {Object} params
56+
* @param params.end
57+
* @param params.start
58+
* @param {Function} callback
5159
*/
5260
AlchemyDataNews.prototype.getNews = function(params, callback ) {
5361
params = params || {};

services/alchemy_language/v1.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function createRequest(method) {
6565
};
6666
}
6767

68+
/**
69+
*
70+
* @param options
71+
* @constructor
72+
*/
6873
function AlchemyLanguage(options) {
6974
// Default URL
7075
var serviceDefaults = {

services/alchemy_vision/v1.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ function createRequest(method) {
8484
};
8585
}
8686

87+
/**
88+
*
89+
* @param options
90+
* @constructor
91+
*/
8792
function AlchemyVision(options) {
8893
// Default URL
8994
var serviceDefaults = {

services/authorization/v1.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ var extend = require('extend');
2020
var requestFactory = require('../../lib/requestwrapper');
2121
var url = require('url');
2222

23+
/**
24+
*
25+
* @param options
26+
* @constructor
27+
*/
2328
function Authorization(options) {
2429
// Default URL
2530
var serviceDefaults = {

services/concept_expansion/v1-beta.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function responseFormatter(cb) {
7474
};
7575
}
7676

77+
/**
78+
*
79+
* @param options
80+
* @constructor
81+
*/
7782
function ConceptExpansion(options) {
7883
var serviceDefaults = {
7984
url: 'https://gateway.watsonplatform.net/concept-expansion-beta/api'
@@ -161,4 +166,4 @@ ConceptExpansion.prototype.expand = function(params, callback) {
161166
});
162167
};
163168

164-
module.exports = ConceptExpansion;
169+
module.exports = ConceptExpansion;

services/concept_insights/v2.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ var requestFactory = require('../../lib/requestwrapper');
2222

2323
/**
2424
* Format the ids into a JSON array if is a string array
25-
* @param {Array or string} ids the concept identifiers
25+
* @param {Array|String} ids the concept identifiers
2626
* @return {String} The concept ids as JSON array
27+
* @private
2728
*/
2829
function formatConceptIds(ids) {
2930
// Initially, we expected the user to supply JSON.stringify'd ids.
@@ -46,6 +47,11 @@ function formatConceptIds(ids) {
4647
return JSON.stringify(ids);
4748
}
4849

50+
/**
51+
*
52+
* @param options
53+
* @constructor
54+
*/
4955
function ConceptInsights(options) {
5056
// Default URL
5157
var serviceDefaults = {

0 commit comments

Comments
 (0)