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

@agds/jsdoc-plugin-ts

v1.0.4

Published

jsdoc的ts支持插件(fork自better-docs)

Downloads

14

Readme

@agds/jsdoc-plugin-ts

版本 :1.0.4

jsdoc的ts支持插件(fork自better-docs)

快速开始

安装

npm i -D @agds/jsdoc-plugin-ts

效果展示

  1. ts 的 type 类型声明
/**
 * ActionRequest
 * @memberof Action
 * @alias ActionRequest
 */
export type ActionRequest = {
    /**
     * parameters passed in an URL
     */
    params: {
        /**
         * Id of current resource
         */
        resourceId: string;
        /**
         * Id of current record
         */
        recordId?: string;
        /**
         * Name of an action
         */
        action: string;

        [key: string]: any;
    };
};

转换为:

/**
 * ActionRequest'
 *
 * @memberof Action'
 * @alias ActionRequest'
 * @typedef {object} ActionRequest'
 * @property {object} params   parameters passed in an URL'
 * @property {string} params.resourceId   Id of current resource'
 * @property {string} [params.recordId]   Id of current record'
 * @property {string} params.action   Name of an action'
 * @property {any} params.{...}'
 */
  1. 您还可以用类似的方式对interface进行注释
/**
 * JSON representation of an {@link Action}
 * @see Action
 */
export default interface ActionJSON {
  /**
   * Unique action name
   */
  name: string;
  /**
   * Type of an action
   */
  actionType: 'record' | 'resource' | Array<'record' | 'resource'>;
  /**
   * Action icon
   */
  icon?: string;
  /**
   * Action label - visible on the frontend
   */
  label: string;
  /**
   * Guarding message
   */
  guard?: string;
  /**
   * If action should have a filter (for resource actions)
   */
  showFilter: boolean;
  /**
   * Action component. When set to false action will be invoked immediately after clicking it,
   * to put in another words: there wont be an action view
   */
  component?: string | false | null;
}

或者像那样描述你的class属性:

/**
 * Class name
 */
class ClassName {
  /**
   * Some private member which WONT be in jsdoc (because it is private)
   */
  private name: string

  /**
   * Some protected member which will go to the docs
   */
  protected somethingIsA: number

  /**
   * And static member which will goes to the docs.
   */
  static someStaticMember: number

  public notCommentedWontBeInJSDoc: string

  constructor(color: string) {}
}

如何使用

jsdoc 引入

请在根目录的jsdoc.conf.json的 plugins 字段新增插件的文件导入

{
  // 有时候需要指定node_modules,例如:`node_modules/@agds/jsdoc-plugin-ts`
  "plugins": [
+    "@agds/jsdoc-plugin-ts"
  ]
}

并在运行 jsdoc 时指定使用 config 文件

jsdoc -c jsdoc.conf.json

在@agds/cli-plugin-doc 中使用

请在根目录的agds.doc.config.js文件的导出对象的presets数组中新增对应的导入,可以无需设置直接使用

const tsPreset = require('@agds/jsdoc-plugin-ts/lib/agds-ts-preset');
module.exports =
/**
 * 配置参数
 *
 * @returns {import('@agds/cli-plugin-doc').RenderOptions}
 */
(async () => {
    return {
        presets:[
+          tsPreset
        ]
    };
})();

如果你要直接使用插件,请在根目录的agds.doc.config.js文件的导出对象的jsdocEngineOptions.plugins数组中新增对应的导入

const tsPreset = require('@agds/jsdoc-plugin-ts/lib/agds-ts-preset');
module.exports =
/**
 * 配置参数
 *
 * @returns {import('@agds/cli-plugin-doc').RenderOptions}
 */
(async () => {
    return {
      jsdocEngineOptions: {
        plugins:[
+        require.resolve('@agds/jsdoc-plugin-ts')
        ],
        source: {
           // jsdoc默认仅支持js、jsx文件,需要支持ts、tsx,需设置includePattern
+         includePattern: '\\.[jt]sx?$',
        }
      }
    };
})();

许可证

MIT License Copyright (c) 2021 锦阳

请维护者喝杯咖啡

加入钉钉群讨论或加入开发