简体   繁体   English

是否可以使用TypeDoc为TypeScript项目生成单页doc html?

[英]Is it possible to generate single page doc html with TypeDoc for TypeScript project?

Let's say I have two TypeScript classes in my library called SuperBase . 假设我的类库中有两个TypeScript类,称为SuperBase The Database and the Record . DatabaseRecord

Would it be possible with TypeDoc to generate a single page with something like very simple format below. 使用TypeDoc可以生成单个页面 ,其格式如下所示。 It doesn't have to be exactly that way, just something simple and similar. 不一定就是那样,只是简单而相似。

It should be very simple and minimal , and just one page. 它应该非常简单和最小 ,只有一页。 Something like you would write yourself in a Markdown readme. 就像您会在Markdown自述文件中写自己一样。 All it needs to do just fetch those docs from sources and glue it into the single HTML page. 它所要做的只是从源中获取这些文档并将其粘贴到单个HTML页面中。 Is that possible with TypeDoc or maybe with some other tool for TypeScript? 使用TypeDoc或使用其他用于TypeScript的工具是否可能?

(header) SuperBase
(text) description of the package taken from package.json or somewhere else

(header) Database
(text) Description of the database taken from class docs

(subheader) connect(url: string)
(text) description of the connect method taken from method docs

(header) Record
(text) Description of the Record taken from class docs

(subheader) validate()
(text) description of the validate method taken from method docs

You can use typedoc , typedoc-plugin-markdown , showdown and concat-md in a single command. 您可以在单个命令中使用typedoctypedoc-plugin-markdownshowdownconcat-md In result, you both have a single page Markdown and HTML together. 结果,你们两个页面都有Markdown和HTML在一起。

(Disclaimer: I am developer of open source concat-md and readmeasy ) (免责声明:我是开源concat-mdreadmeasy开发人员)

How 怎么样

typedoc-plugin-markdown produces a series of Markdown files from your TypeDoc comments and concat-md creates a single file from multiple Markdown files. typedoc-plugin-markdown根据您的TypeDoc注释生成一系列Markdown文件,而concat-md根据多个Markdown文件创建单个文件。

In case you need further customize README.md file in addition to including created API Markdown file, you can use a README.hbs or README.njk template with readmeasy and include created API Markdown into your customized README.md . 如果除了包含创建的API Markdown文件之外还需要进一步自定义README.md文件,则可以README.hbs README.njkREADME.njk模板与readmeasy一起readmeasy并将创建的API Markdown包含在自定义的README.md

Example

Single Command 单指令

Below command creates multiple files into a temp directory merge them to README.md file and deletes temp directory. 下面的命令将多个文件创建到临时目录中,将它们合并到README.md文件中,然后删除临时目录。 ( rimraf module is used for delete, because it is cross OS compatible) rimraf模块用于删除,因为它与跨OS兼容)

$ npm install -D typedoc typedoc-plugin-markdown concat-md rimraf showdown
$ rimraf temp-docs && typedoc --plugin typedoc-plugin-markdown --theme markdown --mode file --out temp-docs && concat-md --toc --decrease-title-levels --dir-name-as-title temp-docs > README.md && showdown makehtml -i README.md -o README.html && rimraf temp-docs

Description 描述

  • Install necessary modules: 安装必要的模块:
$ npm install -D typedoc typedoc-plugin-markdown concat-md showdown
  • Create Markdown files using TypeDoc comments into temp-docs directory: 使用TypeDoc注释将Markdown文件创建到temp-docs目录中:
$ typedoc --plugin typedoc-plugin-markdown --theme markdown --mode file --out temp-docs
  • Create a single README.md Markdown file from them: (Also creates table of contents, adds directory names as titles, and decreases title levels automatically) 从它们创建一个README.md Markdown文件:(还创建目录,将目录名称添加为标题,并自动降低标题级别)
$ concat-md --toc --decrease-title-levels --dir-name-as-title temp-docs > README.md
  • Convert created Markdown into HTML using any converter: (I used showdown for this example) 使用任何转换器将创建的Markdown转换为HTML :(在此示例中,我使用showdown)
$ showdown makehtml -i README.md -o README.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeDoc 找不到模块 typescript - TypeDoc cannot find module typescript Typedoc / Typescript 编译器在导入的类型上抛出错误 - Typedoc / Typescript Compiler throws error on an imported type TypeDoc来自一个项目的一些文档 - TypeDoc a few documentations from one project 如何为测试编写文档注释并使用 typedoc 制作报告? - How can i write doc comments for test and make a report with typedoc? 如何从基于TypeScript的Express应用程序生成swagger API文档? - How to generate swagger API doc from TypeScript based Express app? 如何为打字稿枚举类型 {[key]: value } 生成文档? - how to generate doc for typescript enum type {[key]: value }? 在TypeScript中使用单个模块生成声明文件 - Generate declaration file with single module in TypeScript 如何运行具有单个html和一个打字稿文件的示例github项目? 这不应该那么困难 - How to run sample github project that is has a single html and a typescript file? This should not be so difficult 导入外部库并使用打字稿生成单个文件 - Import external libraries and generate single file with typescript 使用 TypeScript 中的单个模块生成声明文件不起作用 - Generate declaration file with single module in TypeScript not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM