Skip to content

feature: /json-to-jsdoc #1

Description

@coolaj86

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.

  • JavaScript conversion function (no frameworks or libraries)
    • JSON.stringify(input, null, 2) to prettify JSON
    • Traverses JSON to produce JSDoc
    • Checkbox for "treat arrays as enums"
    • Order types alphabetically
    • "" is type String
    • "a|b|c" creates a typedef MyTypeStatusEnum ?
  • HTML Textareas
    • CSS with variables (see MVP.css)

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"];

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions