From 0d459ac327685b4e6d613a4c26b9a8669ea1bb3f Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Wed, 8 Aug 2018 17:03:30 -0600 Subject: [PATCH] Fix API documentation --- browser/path-loader.js | 38 ++------------------- docs/API.md | 6 ++-- gulpfile.js | 19 +++++++++-- index.d.ts | 76 +++++++++++++++++++++--------------------- index.js | 36 +------------------- lib/typedefs.js | 37 ++++++++++++++++++++ package.json | 1 + 7 files changed, 98 insertions(+), 115 deletions(-) create mode 100644 lib/typedefs.js diff --git a/browser/path-loader.js b/browser/path-loader.js index aee7bd7..371c456 100644 --- a/browser/path-loader.js +++ b/browser/path-loader.js @@ -54,40 +54,6 @@ function getScheme (location) { * @module path-loader */ -/** - * Options used when loading a path. - * - * @typedef {object} LoadOptions - * - * @property {string} [encoding='utf-8'] - The encoding to use when loading the file *(File loader only)* - * @property {string} [method=get] - The HTTP method to use for the request *(HTTP loader only)* - * @property {PrepareRequestCallback} [prepareRequest] - The callback used to prepare the request *(HTTP loader only)* - * @property {ProcessResponseCallback} [processContent] - The callback used to process the response - */ - -/** - * Callback used to provide access to altering a remote request prior to the request being made. - * - * @callback PrepareRequestCallback - * - * @param {object} req - The Superagent request object - * @param {string} location - The location being retrieved - * @param {function} callback - First callback - */ - - /** - * Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)* - * - * @callback ProcessResponseCallback - * - * @param {object} res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent - * object in that it will have a `text` property whose value is the raw string value being processed. This was done - * for consistency.)* - * @param {function} callback - Error-first callback - * - * @returns {*} the result of processing the responsexs - */ - function getLoader (location) { var scheme = getScheme(location); var loader = supportedLoaders[scheme]; @@ -106,7 +72,7 @@ function getLoader (location) { /** * Loads a document at the provided location and returns a JavaScript object representation. * - * @param {LoadOptions} location - The location to the document + * @param {module:path-loader~LoadOptions} location - The location to the document * * @returns {Promise<*>} Always returns a promise even if there is a callback provided * @@ -2981,4 +2947,4 @@ exports.cleanHeader = function(header,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B0byBcImpzb25cIiB3aGVuXG4gKiBhbiBvYmplY3QgaXMgZ2l2ZW4uXG4gKlxuICogRXhhbXBsZXM6XG4gKlxuICogICAgICAgLy8gbWFudWFsIGpzb25cbiAqICAgICAgIHJlcXVlc3QucG9zdCgnL3VzZXInKVxuICogICAgICAgICAudHlwZSgnanNvbicpXG4gKiAgICAgICAgIC5zZW5kKCd7XCJuYW1lXCI6XCJ0alwifScpXG4gKiAgICAgICAgIC5lbmQoY2FsbGJhY2spXG4gKlxuICogICAgICAgLy8gYXV0byBqc29uXG4gKiAgICAgICByZXF1ZXN0LnBvc3QoJy91c2VyJylcbiAqICAgICAgICAgLnNlbmQoeyBuYW1lOiAndGonIH0pXG4gKiAgICAgICAgIC5lbmQoY2FsbGJhY2spXG4gKlxuICogICAgICAgLy8gbWFudWFsIHgtd3d3LWZvcm0tdXJsZW5jb2RlZFxuICogICAgICAgcmVxdWVzdC5wb3N0KCcvdXNlcicpXG4gKiAgICAgICAgIC50eXBlKCdmb3JtJylcbiAqICAgICAgICAgLnNlbmQoJ25hbWU9dGonKVxuICogICAgICAgICAuZW5kKGNhbGxiYWNrKVxuICpcbiAqICAgICAgIC8vIGF1dG8geC13d3ctZm9ybS11cmxlbmNvZGVkXG4gKiAgICAgICByZXF1ZXN0LnBvc3QoJy91c2VyJylcbiAqICAgICAgICAgLnR5cGUoJ2Zvcm0nKVxuICogICAgICAgICAuc2VuZCh7IG5hbWU6ICd0aicgfSlcbiAqICAgICAgICAgLmVuZChjYWxsYmFjaylcbiAqXG4gKiAgICAgICAvLyBkZWZhdWx0cyB0byB4LXd3dy1mb3JtLXVybGVuY29kZWRcbiAqICAgICAgcmVxdWVzdC5wb3N0KCcvdXNlcicpXG4gKiAgICAgICAgLnNlbmQoJ25hbWU9dG9iaScpXG4gKiAgICAgICAgLnNlbmQoJ3NwZWNpZXM9ZmVycmV0JylcbiAqICAgICAgICAuZW5kKGNhbGxiYWNrKVxuICpcbiAqIEBwYXJhbSB7U3RyaW5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clsnaG9zdCddO1xuICAvLyBzZWN1aXJ0eVxuICBpZiAoY2hhbmdlc09yaWdpbikge1xuICAgIGRlbGV0ZSBoZWFkZXJbJ2F1dGhvcml6YXRpb24nXTtcbiAgICBkZWxldGUgaGVhZGVyWydjb29raWUnXTtcbiAgfVxuICByZXR1cm4gaGVhZGVyO1xufTtcbiJdfQ== diff --git a/docs/API.md b/docs/API.md index 05f42ab..e25517d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -22,7 +22,7 @@ Loads a document at the provided location and returns a JavaScript object repres | Param | Type | Description | | --- | --- | --- | -| location | LoadOptions | The location to the document | +| location | [LoadOptions](#module_path-loader..LoadOptions) | The location to the document | **Example** ```js @@ -96,8 +96,8 @@ Options used when loading a path. | --- | --- | --- | --- | | encoding | string | "'utf-8'" | The encoding to use when loading the file *(File loader only)* | | method | string | "get" | The HTTP method to use for the request *(HTTP loader only)* | -| prepareRequest | PrepareRequestCallback | | The callback used to prepare the request *(HTTP loader only)* | -| processContent | ProcessResponseCallback | | The callback used to process the response | +| prepareRequest | [PrepareRequestCallback](#module_path-loader..PrepareRequestCallback) | | The callback used to prepare the request *(HTTP loader only)* | +| processContent | [ProcessResponseCallback](#module_path-loader..ProcessResponseCallback) | | The callback used to process the response | diff --git a/gulpfile.js b/gulpfile.js index d7069f2..13fbf45 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -93,16 +93,18 @@ gulp.task('clean', function (done) { gulp.task('docs', function () { return gulp.src([ - './index.js' + './index.js', + './lib/typedefs.js' ]) .pipe($.concat('API.md')) .pipe($.jsdoc2MD()) .pipe(gulp.dest('docs')); }); -gulp.task('docs-ts', function (cb) { +gulp.task('docs-ts-raw', function (cb) { gulp.src([ - './index.js' + './index.js', + './lib/typedefs.js' ]) .pipe($.jsdoc3({ opts: { @@ -112,6 +114,17 @@ gulp.task('docs-ts', function (cb) { }, cb)); }); +// Due to bugs in @otris/jsdoc-tsd, we need to "fix" the generated TSD. +// +// * https://github.com/otris/jsdoc-tsd/issues/38 +// * https://github.com/otris/jsdoc-tsd/issues/39 +gulp.task('docs-ts', ['docs-ts-raw'], function () { + gulp.src(['index.d.ts']) + .pipe($.replace('<*>', '')) + .pipe($.replace('module:path-loader~', '')) + .pipe(gulp.dest('.')); +}); + gulp.task('lint', function () { return gulp.src([ 'lib/**/*.js', diff --git a/index.d.ts b/index.d.ts index 13e0ec0..bb92e24 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,51 +3,51 @@ */ declare module 'path-loader' { /** - * Options used when loading a path. + * Loads a document at the provided location and returns a JavaScript object representation. + * @param location - The location to the document + * @returns Always returns a promise even if there is a callback provided */ - declare interface LoadOptions { - /** - * The encoding to use when loading the file *(File loader only)* - */ - encoding?: string; - /** - * The HTTP method to use for the request *(HTTP loader only)* - */ - method?: string; - /** - * The callback used to prepare the request *(HTTP loader only)* - */ - prepareRequest?: PrepareRequestCallback; - /** - * The callback used to process the response - */ - processContent?: ProcessResponseCallback; - } + export function load(location: LoadOptions): Promise.; +} + +/** + * Options used when loading a path. + */ +declare interface LoadOptions { /** - * Callback used to provide access to altering a remote request prior to the request being made. - * @param req - The Superagent request object - * @param location - The location being retrieved - * @param callback - First callback + * The encoding to use when loading the file *(File loader only)* */ - declare type PrepareRequestCallback = (req: object, location: string, callback: Function)=>void; - + encoding?: string; /** - * Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)* - * @param res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent - * object in that it will have a `text` property whose value is the raw string value being processed. This was done - * for consistency.)* - * @param callback - Error-first callback - * @returns the result of processing the responsexs + * The HTTP method to use for the request *(HTTP loader only)* */ - declare type ProcessResponseCallback = (res: object, callback: Function)=>any; - + method?: string; /** - * Loads a document at the provided location and returns a JavaScript object representation. - * @param location - The location to the document - * @returns Always returns a promise even if there is a callback provided + * The callback used to prepare the request *(HTTP loader only)* */ - export function load(location: LoadOptions): Promise; - + prepareRequest?: PrepareRequestCallback; + /** + * The callback used to process the response + */ + processContent?: ProcessResponseCallback; } +/** + * Callback used to provide access to altering a remote request prior to the request being made. + * @param req - The Superagent request object + * @param location - The location being retrieved + * @param callback - First callback + */ +declare type PrepareRequestCallback = (req: object, location: string, callback: Function)=>void; + +/** + * Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)* + * @param res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent + * object in that it will have a `text` property whose value is the raw string value being processed. This was done + * for consistency.)* + * @param callback - Error-first callback + * @returns the result of processing the responsexs + */ +declare type ProcessResponseCallback = (res: object, callback: Function)=>any; + diff --git a/index.js b/index.js index 9d5a682..a54aced 100644 --- a/index.js +++ b/index.js @@ -53,40 +53,6 @@ function getScheme (location) { * @module path-loader */ -/** - * Options used when loading a path. - * - * @typedef {object} LoadOptions - * - * @property {string} [encoding='utf-8'] - The encoding to use when loading the file *(File loader only)* - * @property {string} [method=get] - The HTTP method to use for the request *(HTTP loader only)* - * @property {PrepareRequestCallback} [prepareRequest] - The callback used to prepare the request *(HTTP loader only)* - * @property {ProcessResponseCallback} [processContent] - The callback used to process the response - */ - -/** - * Callback used to provide access to altering a remote request prior to the request being made. - * - * @callback PrepareRequestCallback - * - * @param {object} req - The Superagent request object - * @param {string} location - The location being retrieved - * @param {function} callback - First callback - */ - - /** - * Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)* - * - * @callback ProcessResponseCallback - * - * @param {object} res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent - * object in that it will have a `text` property whose value is the raw string value being processed. This was done - * for consistency.)* - * @param {function} callback - Error-first callback - * - * @returns {*} the result of processing the responsexs - */ - function getLoader (location) { var scheme = getScheme(location); var loader = supportedLoaders[scheme]; @@ -105,7 +71,7 @@ function getLoader (location) { /** * Loads a document at the provided location and returns a JavaScript object representation. * - * @param {LoadOptions} location - The location to the document + * @param {module:path-loader~LoadOptions} location - The location to the document * * @returns {Promise<*>} Always returns a promise even if there is a callback provided * diff --git a/lib/typedefs.js b/lib/typedefs.js new file mode 100644 index 0000000..97f550f --- /dev/null +++ b/lib/typedefs.js @@ -0,0 +1,37 @@ +/** + * This file contains all type definitions that are purely for documentation purposes. + */ + +/** + * Options used when loading a path. + * + * @typedef {object} LoadOptions + * + * @property {string} [encoding='utf-8'] - The encoding to use when loading the file *(File loader only)* + * @property {string} [method=get] - The HTTP method to use for the request *(HTTP loader only)* + * @property {module:path-loader~PrepareRequestCallback} [prepareRequest] - The callback used to prepare the request *(HTTP loader only)* + * @property {module:path-loader~ProcessResponseCallback} [processContent] - The callback used to process the response + */ + +/** + * Callback used to provide access to altering a remote request prior to the request being made. + * + * @callback PrepareRequestCallback + * + * @param {object} req - The Superagent request object + * @param {string} location - The location being retrieved + * @param {function} callback - First callback + */ + + /** + * Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)* + * + * @callback ProcessResponseCallback + * + * @param {object} res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent + * object in that it will have a `text` property whose value is the raw string value being processed. This was done + * for consistency.)* + * @param {function} callback - Error-first callback + * + * @returns {*} the result of processing the responsexs + */ diff --git a/package.json b/package.json index 49c55c5..0716892 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "gulp-load-plugins": "^1.5.0", "gulp-mocha": "~3.0.1", "gulp-nsp": "^2.4.2", + "gulp-replace": "^1.0.0", "gulp-uglify": "^3.0.0", "karma": "^1.6.0", "karma-mocha": "^1.3.0",