BeyondCodeBootcamp / jswithtypes.com

JS with Types (jswt)
https://jswithtypes.com
0 stars 0 forks source link

feature: /json-to-jsdoc #1

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

The Big Idea

I'd like to host a standalone online tool like https://transform.tools/json-to-jsdoc, but that will break down intermediary types, and also handle enums.

Example Output: JSON

/** @typedef {object} json
 * @property {object} about
 * @property {string} about.legalBusinessName
 * @property {string} about.website
 * @property {string} about.industry
 * @property {string} about.countryOfOperation
 * @property {string} about.description
 * @property {string} about.operations
 */

should instead be

/** 
 * @typedef MyType
 * @prop {MyTypeAbout} about
 */

/**
  * @typedef MyTypeAbout
  * @prop {String} legalBusinessName
  * @prop {String} website
  * @prop {String} industry
  * @prop {String} countryOfOperation
  * @prop {String} description
  * @prop {String} operations
  */

Example Output: Enums

Maybe any props that are all caps and assigned an array could be considered enums?

/**
 * @typedef {"IsPep"|"IsNotPep"} PepOption
 */
Mercury.POLITICALLY_EXPOSED_OPTIONS = ["IsPep", "IsNotPep"];
wmerfalen commented 2 years ago

would be a really fun parser to write

coolaj86 commented 2 years ago

It shouldn't require any parsing, just generating, but feel free to take it on.