{"id":18355424,"url":"https://github.com/charto/docts","last_synced_at":"2025-04-06T12:32:01.581Z","repository":{"id":57214304,"uuid":"54240257","full_name":"charto/docts","owner":"charto","description":"README.md API section autogenerator for TypeScript projects","archived":false,"fork":false,"pushed_at":"2019-06-14T07:52:12.000Z","size":28,"stargazers_count":22,"open_issues_count":6,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T23:51:15.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/charto.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}},"created_at":"2016-03-19T01:00:43.000Z","updated_at":"2021-04-06T21:58:27.000Z","dependencies_parsed_at":"2022-08-26T13:23:42.836Z","dependency_job_id":null,"html_url":"https://github.com/charto/docts","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fdocts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fdocts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fdocts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fdocts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charto","download_url":"https://codeload.github.com/charto/docts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247484349,"owners_count":20946384,"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-11-05T22:06:52.501Z","updated_at":"2025-04-06T12:32:01.282Z","avatar_url":"https://github.com/charto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"docts\n=====\n\n[![build status](https://travis-ci.org/charto/docts.svg?branch=master)](http://travis-ci.org/charto/docts)\n[![dependency status](https://david-dm.org/charto/docts.svg)](https://david-dm.org/charto/docts)\n[![npm version](https://img.shields.io/npm/v/docts.svg)](https://www.npmjs.com/package/docts)\n\nThis is a command-line tool to generate API documentation for TypeScript projects\nbased on information about types and exported declarations extracted using [readts](https://github.com/charto/readts).\nRun `docts` inside your package and it parses the `.d.ts` files referenced from the `typings` key of your `package.json`.\nThen it replaces any section titled `API` in your `README.md` file with new automatically generated content.\nFor an example of its output, see the [API](#api) section below.\n\nIf your package is a Git working tree and the `repository` field in `package.json` points to a Github URL,\nlinks to relevant parts of the code published on Github are added next to functions, classes and methods.\nEach link looks like `\u003c\u003e` and includes the hash of the latest commit which changed the relevant file.\nIf that file is dirty in the working tree, the link points to whatever is on the current branch instead.\nThis minimizes changes to the links while trying to keep them pointed to the correct location in latest code.\n\nAny additional TypeScript configuration should be defined in `tsconfig.json` in the root if your package.\n\nUsage\n-----\n\nStart by making a backup of your `README.md`.\n\nThen install:\n\n```sh\nnpm install --save-dev docts\n```\n\nMake sure your `package.json` has a `typings` section and add in the `scripts` section:\n\n```json\n  \"scripts\": {\n    \"docts\": \"docts\"\n  }\n```\n\nFinally run:\n\n```sh\nnpm run docts\n```\n\nAPI\n===\nDocs generated using [`docts`](https://github.com/charto/docts)\n\u003e\n\u003e \u003ca name=\"api-DocBuilder\"\u003e\u003c/a\u003e\n\u003e ### Class [`DocBuilder`](#api-DocBuilder)\n\u003e \u003cem\u003eTypeScript project Markdown documentation builder.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/docts/blob/db09800/src/DocBuilder.ts#L41-L284)  \n\u003e  \n\u003e Methods:  \n\u003e \u003e **new( )** \u003csup\u003e\u0026rArr; \u003ccode\u003e[DocBuilder](#api-DocBuilder)\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/db09800/src/DocBuilder.ts#L42-L59)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; basePath \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.build( )** \u003csup\u003e\u0026rArr; \u003ccode\u003ePromise\u0026lt;any\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/db09800/src/DocBuilder.ts#L253-L270)  \n\u003e \u003e \u0026emsp;\u003cem\u003eGenerate API documentation for the package.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eReturns promise resolving to an array of text split by line breaks.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-Markdown\"\u003e\u003c/a\u003e\n\u003e ### Class [`Markdown`](#api-Markdown)\n\u003e \u003cem\u003eRepresents a Markdown file.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/docts/blob/1c6326e/src/Markdown.ts#L21-L82)  \n\u003e  \n\u003e Methods:  \n\u003e \u003e **new( )** \u003csup\u003e\u0026rArr; \u003ccode\u003e[Markdown](#api-Markdown)\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/1c6326e/src/Markdown.ts#L22-L24)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; markdownPath \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e **.readSections( )** \u003csup\u003e\u0026rArr; \u003ccode\u003e[Section](#api-Section)[]\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/1c6326e/src/Markdown.ts#L28-L67)  \n\u003e \u003e \u0026emsp;\u003cem\u003eRead the file and split each heading into a separate section.\u003c/em\u003e  \n\u003e \u003e **.writeSections( )** \u003csup\u003e\u0026rArr; \u003ccode\u003ePromise\u0026lt;void\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/1c6326e/src/Markdown.ts#L71-L79)  \n\u003e \u003e \u0026emsp;\u003cem\u003eReplace file contents with a new list of sections.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; sectionList \u003csup\u003e\u003ccode\u003e[Section](#api-Section)[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.path** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-Section\"\u003e\u003c/a\u003e\n\u003e ### Class [`Section`](#api-Section)\n\u003e \u003cem\u003eRepresents a section in a Markdown file.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/docts/blob/1c6326e/src/Markdown.ts#L9-L17)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.header** \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eHeading and its markup split by newlines.\u003c/em\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eHeading is a line beginning with # or followed by another line full of - or =.\u003c/em\u003e  \n\u003e \u003e **.content** \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eSection content split by newlines.\u003c/em\u003e  \n\u003e \u003e **.name** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eHeading with markup stripped.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-patchReadme\"\u003e\u003c/a\u003e\n\u003e ### Function [`patchReadme`](#api-patchReadme)\n\u003e \u003cem\u003ePatch section titled API of README.md file in given directory.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/docts/blob/d74799b/src/Patcher.ts#L11-L27)  \n\u003e \u003e **patchReadme( )** \u003csup\u003e\u0026rArr; \u003ccode\u003evoid\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/docts/blob/d74799b/src/Patcher.ts#L11-L27)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; basePath \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\nLicense\n=======\n\n[The MIT License](https://raw.githubusercontent.com/charto/docts/master/LICENSE)\n\nCopyright (c) 2016 BusFaster Ltd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fdocts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharto%2Fdocts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fdocts/lists"}