{"id":13524744,"url":"https://github.com/galvez/typejuice","last_synced_at":"2025-04-09T16:05:16.954Z","repository":{"id":57142131,"uuid":"441363811","full_name":"galvez/typejuice","owner":"galvez","description":"Documentation generator for TypeScript Declaration Files inspired by godoc.","archived":false,"fork":false,"pushed_at":"2021-12-24T19:52:58.000Z","size":42,"stargazers_count":269,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T16:05:09.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/galvez.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-12-24T04:19:47.000Z","updated_at":"2024-06-27T09:26:48.000Z","dependencies_parsed_at":"2022-09-05T10:00:30.828Z","dependency_job_id":null,"html_url":"https://github.com/galvez/typejuice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galvez%2Ftypejuice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galvez%2Ftypejuice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galvez%2Ftypejuice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galvez%2Ftypejuice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/galvez","download_url":"https://codeload.github.com/galvez/typejuice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065289,"owners_count":21041871,"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":[],"created_at":"2024-08-01T06:01:13.019Z","updated_at":"2025-04-09T16:05:16.934Z","avatar_url":"https://github.com/galvez.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# typejuice\n\nDocumentation generator for TypeScript Declaration Files inspired by [godoc](https://go.dev/blog/godoc).\n\nThis repo contains two packages:\n\n- **typejuice**: the JavaScript API library\n- **vite-plugin-typejuice**: the Vite plugin for it.\n\n_Hat tip to [Guido D'Orsi](https://github.com/gdorsi) for the name idea (vite**press**, type**juice**)_.\n\n\n```bash\nnpm i typejuice --save\n``` \n\n## Introduction\n\n[TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) have become a common addition to libraries, even those written in standard JavaScript, as a means of enhancing autocomplete behaviour of the exposed APIs. \n\nThere's a lot of overlap between documentation and these declaration files. This project attempts to bridge the gap by providing godoc-like comment extraction from `.d.ts` files while also inferring on types and signatures so you don't have to maintain the same information in two different places. It's a radically stripped down, minimalist analogue to [typedoc](https://typedoc.org/guides/doccomments/).\n\n### Examples\n\n**Instead of using tags like @param, just have one function parameter per line**\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n  \n*TypeScript Declaration File*\n\n```ts\ndeclare class Client extends Dispatcher {\n  // Extends: `undici.Dispatcher`\n  // A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.\n  // Requests are not guaranteed to be dispatched in order of invocation.\n  constructor(\n    // Should only include the **protocol, hostname, and port**.\n    url: string | URL,\n    options?: Client.Options\n  );\n```\n  \n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n*Generated Markdown*\n\n\u003cimg width=\"733\" alt=\"constructor\" src=\"https://user-images.githubusercontent.com/12291/144707016-21605a86-600b-47cc-b290-858e72a070fa.png\"\u003e\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n**Multi-line comments on interface props**\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n  \n*TypeScript Declaration File*\n\n```ts\ndeclare namespace Client {\n  export interface Options {\n    // The timeout after which a request will time out, in milliseconds. \n    // Monitors time between receiving body data. Use `0` to disable it entirely.\n    // Defaults to 30e3 (number), 30s in milliseconds\n    bodyTimeout?: number | null;\n\n    // The amount of time the parser will wait to receive the complete HTTP \n    // headers (Node 14 and above only). \n    // Defaults to 30e3 (number), 30s in milliseconds\n    headersTimeout?: number | null;\n```\n  \n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n*Generated Markdown*\n\n\u003cimg width=\"733\" alt=\"interface\" src=\"https://user-images.githubusercontent.com/12291/144706946-e438dd9e-14cd-4826-a983-ae824803bdea.png\"\u003e\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eSupported Syntax\u003c/summary\u003e\n\n- Top-level function and class declarations\n- Single-file namespace declarations\n- Constructor declarations\n– Primitive types such as `string`, `number`, `boolean`\n- Primitive values such as `null` and `undefined`\n- Union Types\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\n\u003csummary\u003eTODO\u003c/summary\u003e\n\n- Intersection Types\n- Type Aliases\n- Utility Types\n- Element type arrays or generic array types (`type[]`, `Array\u003ctype\u003e`)\n\n\u003c/details\u003e\n\n## Basic Usage\n\n```js\nimport TypeJuice from 'typejuice'\n\nconst tj = new TypeJuice('./sample.d.ts')\n\nconsole.log(tj.toMarkdown())\n```\n\n## Vite integration\n\nIn **vite.config.js**:\n\n```js\nimport { dirname } from 'path'\nimport { fileURLToPath } from 'url'\nimport TypeJuice from 'vite-plugin-typejuice'\n\nexport default {\n  plugins: [\n    TypeJuice({\n      // Defaults to process.cwd()\n      typeRoot: resolve(dirname(fileURLToPath(import.meta.url)), 'types'),\n      // Defaults to only 'md'\n      extensions: ['md'],\n    })\n  ],\n}\n```\n\nIn your Markdown files:\n\n```\n\u003c\u003c\u003c typejuice:client.d.ts\n```\n\nThis will insert the autogenerated markdown for `client.d.ts` under `typeRoot`.\n\n# Meta\n                        \nSponsored by [NearForm](http://nearform.com/).\n                        \n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalvez%2Ftypejuice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgalvez%2Ftypejuice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalvez%2Ftypejuice/lists"}