{"id":16441876,"url":"https://github.com/pengjiyuan/ts-document","last_synced_at":"2025-03-16T17:36:29.950Z","repository":{"id":41972119,"uuid":"381010087","full_name":"PengJiyuan/ts-document","owner":"PengJiyuan","description":"Generate ts document schema and markdown by ts interface conform to the TSDoc.","archived":false,"fork":false,"pushed_at":"2023-03-17T06:29:10.000Z","size":206,"stargazers_count":40,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T04:23:56.864Z","etag":null,"topics":["docgen","document","jsdoc","tsdoc","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PengJiyuan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-28T11:39:56.000Z","updated_at":"2025-02-16T09:22:50.000Z","dependencies_parsed_at":"2024-06-18T21:18:03.001Z","dependency_job_id":"eb7e5487-7e9a-4b9e-a70c-ea9d2cd4c1a4","html_url":"https://github.com/PengJiyuan/ts-document","commit_stats":{"total_commits":76,"total_committers":7,"mean_commits":"10.857142857142858","dds":"0.17105263157894735","last_synced_commit":"1a45f0114489d2e90e7294e43d4aff942ab7963d"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PengJiyuan%2Fts-document","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PengJiyuan%2Fts-document/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PengJiyuan%2Fts-document/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PengJiyuan%2Fts-document/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PengJiyuan","download_url":"https://codeload.github.com/PengJiyuan/ts-document/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243909014,"owners_count":20367514,"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":["docgen","document","jsdoc","tsdoc","typescript"],"created_at":"2024-10-11T09:15:39.965Z","updated_at":"2025-03-16T17:36:29.619Z","avatar_url":"https://github.com/PengJiyuan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-document\n\nAuto generate ts document schema by ts interface conform to the [TSDoc](https://tsdoc.org/).\n\n## Highlight\n\n- Controllable parameter extraction, only the specified interface is extracted.\n- Automatically analyze extends relationships.\n- Support extract English and Chinese in one ts file.\n- Support generate markdown string directly.\n\n## Usage\n\n```bash\nnpm i ts-document -D\n```\n\n```js\nconst { generate, generateMarkdown } = require('ts-document');\n\ngenerate('interface.ts', config);\n\ngenerateMarkdown('interface.ts', config);\n```\n\n### interface.ts\n\nts-document will only extract interface and type with jsDoc tag `title`。\n\n```ts\nimport { ReactNode } from 'react';\n\n/**\n * @title Alert\n *\n * @zh\n *\n * 向用户显示警告的信息时，通过警告提示，展现需要关注的信息。\n *\n * @en\n *\n * Display warning information to the user. the Alert is used to display the information that needs attention.\n */\nexport interface AlertProps {\n  /**\n   * @zh 自定义操作项\n   * @en this is action\n   * @version 2.15.0\n   */\n  action?: ReactNode;\n  /**\n   * @zh 是否可以关闭\n   * @en Whether Alert can be closed\n   * @defaultValue false\n   */\n  closable?: InnerProps;\n}\n\ninterface InnerProps {\n  /**\n   * @zh 位置\n   * @en position\n   */\n  position?: string;\n  /**\n   * @zh 尺寸\n   * @en Size\n   */\n  size?: string;\n}\n```\n\n## Generate jsDoc schema\n\n```js\nconst { generate } = require('ts-document');\n\ngenerate('interface.ts');\n```\n\noutput\n\n```json\n{\n  \"Alert\": {\n    \"data\": [\n      {\n        \"name\": \"action\",\n        \"type\": \"ReactNode\",\n        \"isOptional\": true,\n        \"tags\": [\n          {\n            \"name\": \"zh\",\n            \"value\": \"自定义操作项\"\n          },\n          {\n            \"name\": \"en\",\n            \"value\": \"this is action\"\n          },\n          {\n            \"name\": \"version\",\n            \"value\": \"2.15.0\"\n          }\n        ]\n      },\n      {\n        \"name\": \"closable\",\n        \"type\": \"InnerProps\",\n        \"isOptional\": true,\n        \"tags\": [\n          {\n            \"name\": \"zh\",\n            \"value\": \"是否可以关闭\"\n          },\n          {\n            \"name\": \"en\",\n            \"value\": \"Whether Alert can be closed\"\n          },\n          {\n            \"name\": \"defaultValue\",\n            \"value\": \"false\"\n          }\n        ]\n      }\n    ],\n    \"tags\": [\n      {\n        \"name\": \"title\",\n        \"value\": \"Alert\"\n      },\n      {\n        \"name\": \"zh\",\n        \"value\": \"向用户显示警告的信息时，通过警告提示，展现需要关注的信息。\"\n      },\n      {\n        \"name\": \"en\",\n        \"value\": \"Display warning information to the user. the Alert is used to display the information that needs attention.\"\n      }\n    ]\n  }\n}\n```\n\n## Generate markdown document\n\n```js\nconst { generateMarkdown } = require('ts-document');\n\ngenerateMarkdown('interface.ts');\n```\n\noutput\n\n```json\n{\n  \"Alert\": \"### Alert\\n\\nDisplay warning information to the user. the Alert is used to display the information that needs attention.\\n\\n|Property|Description|Type|DefaultValue|Version|\\n|---|---|---|---|---|\\n|action|this is action|`ReactNode`|`-`|2.15.0|\\n|closable|Whether Alert can be closed|`InnerProps`|`false`|-|\"\n}\n```\n\n## Config\n\n### defaultTypeMap\n\n`Record\u003cstring, { type: string, tags?: TagType[] }\u003e`\n\nIf no comments are extracted, will extracted from the `defaultTypeMap` automatically.\n\n### sourceFilesPaths\n\n`string | string[]`\n\nSee [ts-morph](https://ts-morph.com/setup/adding-source-files)。\n\n### strictComment\n\n`boolean`\n\nWhether to skip parsing documentation comment like `/** Some comment **/` as property description if there is no tag like `@en` or `@zh`.\n\n### strictDeclarationOrder\n\n`boolean`\n\nGenerate schema in the order their declarations appear in the document. When it's true, `generate/generateMarkdown` will return an array list(`Array\u003c{ title: string; schema: Schema }\u003e`).\n\n### propertySorter\n\n`(a: { name: string; type: string; isOptional: boolean; tags: Array\u003c{ name: string; value: string }\u003e; }, b: typeof a) =\u003e number`\n\nThe compare function to sort properties/arguments of schema generated.\n\n### lang\n\n`string`\n\nOnly work in `generateMarkdown`, specify output language.\n\n### project\n\n`Project`\n\nCustom project to use in `generate/generateMarkdown` function. See [ts-morph](https://ts-morph.com/setup/)。\n\n### linkFormatter\n\n`({ typeName: string, jsDocTitle?: string, fullPath: string }) =\u003e string`\n\nFormat function to generate link of nested types.\n\n### ignoreNestedType\n\nWhen parsing nested types, whether to ignore these nested types if they are defined in some files.\nWhen returning true, nested types must not be exported, but when false is returned,\nnested types may not be exported due to other reasons (such as the nested type has jsdoc @title, which needs to be manually exported)\n\n### escapeChars\n\n`boolean`: default to `true`\n\nWhether to escape characters for extracted type text. E.g. `|` will be escaped to `\\|`, `\u003cPromise\u003e` will be escaped to `\u0026lt;Promise\u0026gt;`.\n\n## Who's using? \n\n[Arco Design](https://github.com/arco-design/arco-design) - A comprehensive React UI components library based on Arco Design.\n\n## LICENSE\n\n[MIT](./LICENSE) © [PengJiyuan](https://github.com/PengJiyuan)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengjiyuan%2Fts-document","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpengjiyuan%2Fts-document","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengjiyuan%2Fts-document/lists"}