[英]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
. Database
和Record
。
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. 您可以在单个命令中使用typedoc
, typedoc-plugin-markdown
, showdown
和concat-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-md
和readmeasy
开发人员)
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.njk
或README.njk
模板与readmeasy
一起readmeasy
并将创建的API Markdown包含在自定义的README.md
。
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
$ npm install -D typedoc typedoc-plugin-markdown concat-md showdown
temp-docs
directory: 使用TypeDoc注释将Markdown文件创建到temp-docs
目录中: $ typedoc --plugin typedoc-plugin-markdown --theme markdown --mode file --out temp-docs
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
$ showdown makehtml -i README.md -o README.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.