npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

auto-tspress

v1.0.0

Published

通过tsdoc快速生成项目中工具函数的文档

Downloads

5

Readme

auto-tspress

这是一款hooks文档生成工具,根据ts类型以及tsdoc自动生成快速生成项目中工具函数的文档。

why tspress

  • 支持读取函数参数ts类型,不需要在函数中再次声明
  • 支持文件tsdoc
  • 支持读取文件路径配置使用通配符
  • 自动解析类型,并支持一键跳转到类型详情
  • 采用了vitepress来生成文档网站,简洁好看

使用

1.本地安装

请确保为最新版本,推荐使用pnpm安装

pnpm i -D auto-tspress@latest

2. 加入运行脚本

然后在你的package.json加入以下命令

"scripts": {
	"doc": "auto-tspress"
}

3. 添加配置文件

在你的项目路径中新建一个auto-tspress.config.ts,配置项如下所示:

export default () => {
    return {
        // 要解析的文件路径,内部采用ts-morph解析,详情见:https://ts-morph.com/setup/adding-source-files#by-file-globs-or-file-paths
        include: ['test/**/*.ts'],
        // 排除的文件路径
        exclude: ['**/main.ts', '**/views.ts'],
        // 是否开启debug模式,会打印文档生成过程中详细信息
        debug: false,
        // vitepress运行配置
        server: {
            // 运行端口
            port: 5073,
        }
    };
};

tsdoc

tspress支持所有标准的tsdoc解析以及自定义tag解析,@example | TSDoc,但是并不会展示所有的tsdoc,目前支持的tsdoc如下:

| tag | 说明 | 实例 | | ------------ | ------------------------------------------------------------ | --------------------------- | | @param | 参数注释 | @param id 这是id | | @returns | 函数返回注释 | @returns 返回一个当前的时间 | | @file | 文件注释声明 | 见下方 | | @description | 注释说明(该tag可以省略),可用于interface,enum,type关键字定义的类型,以及它们的内部键值对上等等 | 见下方 |

/** 这是test接口 */
interface hh{
    /** 这是name */
    name:string
}

文件doc

这一点没有找tsdoc官方中找到,不过auto-tspress也实现了,基本和tsdoc保持一致,以下是tag说明

| tag | 说明 | 实例 | | ------------ | ------------------------------------ | ---------------- | | @file | 指明这是文件注释 | @file | | @author | 作者 | @author shiouhoo | | @description | 文件说明,不同于tsdoc,该tag不能省略 | @description XX | | @date | 文件创建日期 | @date 2023-1-1 |

/**
 * @file
 * @description 这是hooks文件
 * @author 我
 * @date 2023-1-1
 */

常见错误

没有权限

如果遇到这种错误,Error: EPERM: operation not permitted, mkdir 'D:\software\nvm\v16.13.0\node_modules\auto-tspress\docs\hooks',请使用管理员权限运行命令行。或者参考这里设置。如果是nvm安装的node,需要在nvm的安装目录下设置,比如:nvm\v16.13.0。