Skip to content

Commit 051a487

Browse files
committed
docs: HttpTransport
1 parent f887ce8 commit 051a487

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

docs-gen/template/publish.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,23 @@ function generateParams(doclet) {
3737
return `**Parameters:**\n\n${params.join('\n')}\n`;
3838
}
3939

40-
const generateFunctionDocletSection = (doclet) => {
40+
const generateFunctionDocletSection = (doclet, isConstructor) => {
4141
const title = doclet.name;
42-
const header = `##${doclet.longname.indexOf('#') !== -1 ? '#' : ''} ${title}\n`;
43-
const signature = `\`${doclet.meta.code.name || doclet.name}(${doclet.params && doclet.params.filter(p => p.name.indexOf('.') === -1).map(p => p.name).join(', ') || ''})\`\n`;
42+
const header = `##${doclet.longname.indexOf('#') !== -1 || isConstructor ? '#' : ''} ${title}${isConstructor ? ' Constructor' : ''}\n`;
43+
const args = doclet.params && doclet.params.filter(p => p.name.indexOf('.') === -1).map(p => p.optional ? `[${p.name}]` : p.name).join(', ') || '';
44+
const signature = `\`${isConstructor ? 'new ' : ''}${doclet.meta.code.name || doclet.name}(${args})\`\n`;
4445
const params = doclet.params ? generateParams(doclet) : ``;
4546
const returns = doclet.returns ? `**Returns:** ${doclet.returns.map(p => `${p.type ? renderLinks(p) : ''}${p.description ? ` ${resolveInlineLinks(p.description)}` : ''}`)}` : ``;
46-
return [header, signature, `${resolveInlineLinks(doclet.description)}\n`, params, returns, '\n'].join('\n');
47+
return [header, signature, doclet.description && `${resolveInlineLinks(doclet.description)}\n`, params, returns, '\n'].filter(f => !!f).join('\n');
4748
};
4849

4950
const generateClassSection = (doclet) => {
5051
const header = `## ${doclet.name}\n`;
51-
return [header, (doclet.classdesc || doclet.description).trim(), '\n'].join('\n');
52+
let classSection = [header, (doclet.classdesc || doclet.description).trim(), '\n'].join('\n');
53+
if (doclet.params && doclet.params.length) {
54+
classSection = classSection.concat(generateFunctionDocletSection(doclet, true));
55+
}
56+
return classSection;
5257
};
5358

5459
const tagValue = (doclet, tagOriginalTitle) => {

packages/cubejs-client-core/src/HttpTransport.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
/**
2+
* @module @cubejs-client/core
3+
*/
4+
15
import fetch from 'cross-fetch';
26
import 'url-search-params-polyfill';
37

8+
/**
9+
* Default transport implementation.
10+
*/
411
class HttpTransport {
12+
/**
13+
* @param options - mandatory options object
14+
* @param options.authorization - [jwt auth token](security)
15+
* @param options.apiUrl - path to `/cubejs-api/v1`
16+
* @param [options.headers] - object of custom headers
17+
*/
518
constructor({ authorization, apiUrl, headers = {} }) {
619
this.authorization = authorization;
720
this.apiUrl = apiUrl;

packages/cubejs-client-core/src/index.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ class CubejsApi {
198198
* new Chart(context, chartjsConfig(resultSet));
199199
* ```
200200
* @param query - [Query object](query-format)
201-
* @param options
202-
* @param callback
201+
* @param [options]
202+
* @param [callback]
203203
* @returns {Promise} for {@link ResultSet} if `callback` isn't passed
204204
*/
205205
load(query, options, callback) {
@@ -214,8 +214,8 @@ class CubejsApi {
214214
/**
215215
* Get generated SQL string for given `query`.
216216
* @param query - [Query object](query-format)
217-
* @param options
218-
* @param callback
217+
* @param [options]
218+
* @param [callback]
219219
* @return {Promise} for {@link SqlQuery} if `callback` isn't passed
220220
*/
221221
sql(query, options, callback) {
@@ -229,8 +229,8 @@ class CubejsApi {
229229

230230
/**
231231
* Get meta description of cubes available for querying.
232-
* @param options
233-
* @param callback
232+
* @param [options]
233+
* @param [callback]
234234
* @return {Promise} for {@link Meta} if `callback` isn't passed
235235
*/
236236
meta(options, callback) {
@@ -265,12 +265,13 @@ class CubejsApi {
265265
);
266266
```
267267
* @name cubejs
268-
* @param apiToken - [API token](security) is used to authorize requests and determine SQL database you're accessing.
268+
* @param [apiToken] - [API token](security) is used to authorize requests and determine SQL database you're accessing.
269269
* In the development mode, Cube.js Backend will print the API token to the console on on startup.
270-
* Can be an async function without arguments that returns API token. Optional.
271-
* @param options - options object.
270+
* Can be an async function without arguments that returns API token.
271+
* @param [options] - options object.
272272
* @param options.apiUrl - URL of your Cube.js Backend.
273273
* By default, in the development environment it is `http://localhost:4000/cubejs-api/v1`.
274+
* @param options.transport - transport implementation to use. {@link HttpTransport} will be used by default.
274275
* @returns {CubejsApi}
275276
* @order -10
276277
*/

0 commit comments

Comments
 (0)