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

zh-cli

v2.4.15

Published

脚手架,api文档生成工具

Downloads

220

Readme

zh-cli是什么

工具实现参考了scion

如何使用

  • npm install zh-cli -g

初始化项目

api文档生成

  • pip install mkdocs
  • zcli mkdocs nodejs | c++

基于mkdocs生成api文档

项目根目录中增加配置文件mkdocs.json

{
  mkdocs: {
    "site_name": "z-seneca",
    "site_favicon": "favicon.ico",
    "copyright": "© Zz"
  }, // mkdocs配置,见官网
  apiCfgFilePath: "*.js", // api文件配置文件 glob pattern。如: "/Users/test/*/*.js"
  "indexFilePath": "../README.md",
  "mdFilePath": [
    "../header.md"
  ]
}

api配置文件:.js.json

例如定义部门相关api文件department.js

 module.exports = {
    name: '部门',
    groupName: "Department", // api组名
    description: "提供部门相关api", // api组描述

    // 定义一个类型
    Role: {
      description: "部门角色,如:组长,运营总监", // 类型描述
      propertys: { // 类型包含的属性
        name: {
          type: "String", // 类型
          descrpition: "角色名称", // 属性描述
        },
        status: {
          type: "Enum", // 类型
          description: "状态。1:可用,2:不可用", // 属性描述
          values: [1, 2]
        },
      }
    },

    // 定义一个方法
    create: {
      description: "创建一个部门",
      funcType: 'async', // async函数
      paramsIsObject: true, // 参数在一个object对象中传递
      method: 'post',
      url: '/departments',
      params: { // 参数
        name: {
          type: "String", // 类型
          descrpition: "名称", // 属性描述
          required: true, // 必填
        },
        status: {
          type: "Enum", // 类型
          description: "状态。1:可用,2:不可用", // 属性描述
          values: [1, 2],
          defaultValue: 1,
        },
        role: {
          type: "Role", // 自定义类型
        }
      },
      returns: { // 返回值
        name: {
          type: "String", // 类型
          descrpition: "名称", // 属性描述
          required: true, // 必填
        },
        status: {
          type: "Enum", // 类型
          description: "状态。1:可用,2:不可用", // 属性描述
          values: [1, 2],
          defaultValue: 1,
        }
      },
      exampleSuccess: [{
      desc: '成功时例子',
      params: {
        id: 1,
        status: 1
      },
      returns: {
        id: 1,
        status: 1,
        name: 'aa',
      }
    }, {
      desc: '成功时例子',
      params: {
        id: 1,
        status: 1
      },
      returns: {
        id: 1,
        status: 1,
        name: 'aa',
      }
    }],

    exampleFail: {
      desc: '失败时例子',
      params: {
        id: 1,
        status: 1
      },
      returns: {
        id: 1,
        status: 1,
        name: 'aa',
      }
    },
    }
  }

例如定义部门相关api文件department.json

{
  "name": "部门",
  "groupName": "Department",
  "description": "xxxxxxx",

  "Role": {
    "description": "部门角色。如:组长,运营总监",
    "propertys": {
      "name": {
        "type": "String",
        "descrpition": "角色名称"
      },
      "status": {
        "type": "Enum",
        "description": "状态。1:可用,2:不可用",
        "values": [1, 2]
      }
    }
  },

  "create": {
    "params": {
      "name": {
        "type": "String",
        "descrpition": "角色名称",
        "required": true
      },
      "status": {
        "type": "Enum",
        "description": "状态。1:可用,2:不可用",
        "values": [1, 2],
        "defaultValue": 1
      },
      "role": {
        "name": {
          "type": "String",
          "descrpition": "角色名称"
        },
        "status": {
          "type": "RoleStatus",
          "description": "角色状态"
        }
      }
    },
    "returns": {
      "name": {
        "type": "String",
        "descrpition": "角色名称",
        "required": true
      },
      "status": {
        "type": "Enum",
        "description": "状态。1:可用,2:不可用。",
        "values": [1, 2],
        "defaultValue": 1
      }
    }
  }
}

参数,返回值,属性type

支持常用的nodejs,c++等类型。自定义时传自定义类型的名称即可。 其他语言可自定义类型转换表。

引入内置类型:

  const dateTypes = require('zh-cli')

  dataTypes['c++'] // c++ 内置类型
  dataTypes['nodejs'] // nodejs 内置类型
  

nodejs支持type

  {
    String: 'String',
    Number: 'Number',
    Boolean: 'Boolean',
    Symbol: 'Symbol',
    Object: 'Object',
    Enum: 'Enum',
    Date: 'Date',
    DateTime: 'DateTime',
    Function: 'Function',

    FuncType: {
      kStatic: 'static',
      kAsync: 'async',
      kStaticAsync: 'static async',
    }
  }

c++支持type

{
  String: 'string',

  Int: 'int',
  UnsignedInt: 'unsigned int',
  SignedInt: 'signed int',
  ShortInt: 'short int',
  UnsignedShortInt: 'unsigned short int',
  SignedShortInt: 'signed short int',
  LongInt: 'long int',
  SignedLongInt : 'signed long int',
  UnsignedLongInt: 'unsigned long int',
  
  Float: 'float',
  
  Double: 'double',
  LongDouble: 'long double',
  
  Struct: 'struct',
  
  Boolean: 'bool',
  Bool: 'bool',
  
  Void: 'void',
  Wchar_t: 'wchar_t',
  Char: 'char',
  
  UnsignedChar: 'unsigned char',
  SignedChar: 'signed char',

  Enum: 'enum',
  Date: 'date',
  DateTime: 'date time',

  Function: 'function',
  FuncType: {
    kStatic: 'static',
    kVirtual: 'virtual',
  }
}

帮助

  • zcli -h

问题反馈

在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流