pastejsonasjsdoc README
A tool for generating JSDoc in JaveScript project.
Features
Add Paste JSON as JSDoc Typedef
command for generating JSDoc Typdef comments from JSON string.
Example:
step 1: copy JSON string as follows:
{"a":1, "b":"2" , "c":true, "arr":["str1","str2","str3"]}
step 2: Select a point in your document for inserting comments.
step 3: Press Cmd+Shift+P
(for Mac) / Ctrl+Shift+P
(for Windows).
step 4: Input > Paste JSON as JSDoc Typedef
command and press Enter
.
step 5: Input a type name( e.g: IReturnData
) and press Enter
.
It will generate JSDoc typedef comments as follow:
/**
* @typedef {object} IReturnData
* @property {number} a - e.g:1
* @property {string} b - e.g:"2"
* @property {boolean} c - e.g:true
* @property {Array<string>} arr - e.g:["str1"]
*/
Than you can use IReturnData
type in your JSDoc comments.
/**
* @type {IReturnData}
*/
let returnData;
/**
* @param {IReturnData} data
*/
function getData(data){
//...
}
When you want use a 'IReturnData' typedef in other file. You can import it, as follow:
/**
* @type {import('./xxx/someFileDefineIReturnData').IReturnData}
*/
let data;
Also you can define an alias in other file for avoid to repeate input import("xxx")
/**
* @typedef {import('./xxx/someFileDefineIReturnData').IReturnData} IReturnData
*/
/**
* @returns {IReturnData}
*/
function getData() {
return {xxx};
}
Release Notes
1.0.0 (2022-05-19)
Initial release.