{"id":18727835,"url":"https://github.com/ccontrols/structured-types","last_synced_at":"2025-04-12T16:32:45.692Z","repository":{"id":38391493,"uuid":"388068384","full_name":"ccontrols/structured-types","owner":"ccontrols","description":"Extract structured type information from javascript and typescript files","archived":false,"fork":false,"pushed_at":"2022-07-16T09:25:13.000Z","size":42480,"stargazers_count":57,"open_issues_count":6,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-08T12:51:31.015Z","etag":null,"topics":["types","typescript"],"latest_commit_sha":null,"homepage":"https://structured-types.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccontrols.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-21T09:43:38.000Z","updated_at":"2024-09-08T10:19:22.000Z","dependencies_parsed_at":"2022-08-25T05:10:52.040Z","dependency_job_id":null,"html_url":"https://github.com/ccontrols/structured-types","commit_stats":null,"previous_names":[],"tags_count":110,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccontrols%2Fstructured-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccontrols%2Fstructured-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccontrols%2Fstructured-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccontrols%2Fstructured-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccontrols","download_url":"https://codeload.github.com/ccontrols/structured-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223528095,"owners_count":17160150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["types","typescript"],"created_at":"2024-11-07T14:19:00.866Z","updated_at":"2024-11-07T14:19:01.411Z","avatar_url":"https://github.com/ccontrols.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Table of contents\n\n-   [About](#about)\n-   [Live example](#live-example)\n-   [Using the API](#using-the-api)\n    -   [1. Installation](#1-installation)\n    -   [2. Your API source file (sum.js):](#2-your-api-source-file-sumjs)\n    -   [3. Your documentation extraction](#3-your-documentation-extraction)\n    -   [4. The result](#4-the-result)\n-   [Using the CLI](#using-the-cli)\n    -   [1. Installation](#1-installation-1)\n    -   [2. Configure](#2-configure)\n    -   [3. Launch](#3-launch)\n-   [Typescript playground plugin](#typescript-playground-plugin)\n-   [Roadmap](#roadmap)\n\n# About\n\n`structured-types` is a collection of libraries using the [Typescript Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API) to generate \"structured\" type information from jsdoc and typescript files.\n\nThe library API extracts full types for your libraries, not just string representations of the type, and is built around a plugin architecture, so it can be extended to extract custom types for frameworks such as `react`, `vue`, `angular`.\n\n# Live example\n\nYou can use our [Playground site](https://tinyurl.com/abpkj845) to experiment with custom code\n\n![./img-playground.jpg](https://github.com/ccontrols/structured-types/raw/master/img-playground.jpg)\n\n# Using the API\n\nMore information about the [@structured-types/api](https://github.com/ccontrols/structured-types/blob/master/packages/api/README.md) package.\n\n## 1. Installation\n\n```bash\n$ npm install @structured-types/api --save-dev\n```\n\n## 2. Your API source file (sum.js):\n\n````js\n/**\n * sum api function\n * @remarks\n * Unlike the summary, the remarks block may contain lengthy documentation content.\n * The remarks should not restate information from the summary, since the summary section\n * will always be displayed wherever the remarks section appears.  Other sections\n * (e.g. an `@example` block) will be shown after the remarks section.\n *\n * @param {number} a first parameter to add\n * @param {number} b second parameter to add\n * @returns {number} the sum of the two parameters\n *\n * @example\n *\n * ```js\n * import { sum } from './sum';\n *\n * expect(sum(1, 2)).toMatchObject({ a: 1, b: 2, result: 3});\n * ```\n */\nexport const sum = (a, b = 1) =\u003e ({ a, b, result: a + b });\n````\n\n## 3. Your documentation extraction\n\n```ts\nimport { parseFiles } from '@structured-types/api';\n\nconst docs = parseFiles(['../src/sum.js']);\n```\n\n## 4. The result\n\n````json\n{\n  \"sum\": {\n    \"name\": \"sum\",\n    \"kind\": 11,\n    \"parameters\": [\n      {\n        \"kind\": 2,\n        \"name\": \"a\",\n        \"description\": \"first parameter to add\"\n      },\n      {\n        \"kind\": 2,\n        \"name\": \"b\",\n        \"value\": 1,\n        \"description\": \"second parameter to add\"\n      }\n    ],\n    \"examples\": [\n      {\n        \"content\": \"```js\\nimport { sum } from './sum';\\n\\nexpect(sum(1, 2)).toMatchObject({ a: 1, b: 2, result: 3});\\n```\"\n      }\n    ],\n    \"returns\": {\n      \"description\": \"the sum of the two parameters\",\n      \"kind\": 2\n    },\n    \"tags\": [\n      {\n        \"tag\": \"remarks\",\n        \"content\": \"Unlike the summary, the remarks block may contain lengthy documentation content.\\nThe remarks should not restate information from the summary, since the summary section\\nwill always be displayed wherever the remarks section appears.  Other sections\\n(e.g. an `@example` block) will be shown after the remarks section.\"\n      }\n    ],\n    \"description\": \"sum api function\"\n  }\n}\n````\n\n# Using the CLI\n\nYou can also use structured-types to automatically generate markdown README.md-type files for your libraries.\n\nMore information about the [@structured-types/api-readme](https://github.com/ccontrols/structured-types/blob/master/packages/api-readme/README.md) package.\n\n## 1. Installation\n\n```bash\n$ npm install @structured-types/api-readme --save-dev\n```\n\n## 2. Configure\n\nIn your `README.md` (or other markdown file) file, you will insert a `\u003capi-readme /\u003e` tag to generate the API section:\n\n```md\n\u003capi-readme /\u003e\n```\n\n## 3. Launch\n\nYou can launch directly from the command-line ie `yarn run api-readme` or from your `package.json` file by adding a script to launch the command line documentation tool.\n\n```json\n...\n  \"scripts\": {\n    \"docs\": \"api-readme\",\n    ...\n  },\n...\n```\n\n# Typescript playground plugin\n\n[Click to install](https://www.typescriptlang.org/play?install-plugin=@structured-types/playground-plugin) our TypeScript playground plugin which shows the type information for the current file.\n\nMore information about the [@structured-types/playground-plugin](https://github.com/ccontrols/structured-types/blob/master/packages/ts-playground-plugin/README.md) package.\n\n# Roadmap\n\n-   [x] JSDoc types\n-   [x] Typescript types\n-   [x] React plugin\n-   [x] React \"prop-types\" plugin\n-   [x] Typescript playground plugin\n-   [x] Automatically generate README.md files (api-readme)\n-   [x] VSCode plugin for instant documentation\n-   [ ] [component-controls](https://github.com/ccontrols/component-controls) integration\n-   [ ] Vue plugin\n-   [ ] Angular plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccontrols%2Fstructured-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccontrols%2Fstructured-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccontrols%2Fstructured-types/lists"}