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

@lanyue/tie

v0.1.1

Published

A tool for generating api document from source code.

Downloads

21

Readme

Tie

A tool for generating api document from source code.

npm install -g @lanyue/tie

Library

const tie = require('@lanyue/tie')
tie.parse(entry, options)

// or
const demo = new tie.Tie({ tag: 'api' }) // Defining block tags @tie => @api
demo.parse(text)

CLI

tie controller/ --dest=docs

It will generated documents to the docs folder.

Usage: tie [options] <entry>

Extracting description to generate markdown document.

Options:
  -V, --version       output the version number
  --dest <dir>        output folder
  --log [enable]      enable logs (default: "0")
  --match <pattern>   match pattern (default: "**/*.js")
  -i --ignore <file>  ignore file (default: "node_modules/**/*.js")
  -b --bundle <file>  bundle handler javascript file
  --json [filename]   output json to file
  -h, --help          display help for command

bundle.js

// bundle.js

// Custom rendering handler
exports.render = async function ({ chunks, file, filename, meta, metaMarkdown }) {
    console.log(file)

    // Redefining rendering
    return '# Hi'
}

// Do something else when you're done
exports.done = async function (files) {
    console.log(files.length)
}

Pattern

  • @tie 标记接口,有标记的注释才会被解析,放在注释开头
  • @tie:<type> 标记块类型,目前有 metamarkdown 类型
  • @title 接口名称
  • @des 接口说明
  • @tags 标签,多个逗号分隔
  • @author 作者,多个逗号分隔
  • @version 版本
  • @route 路由定义
  • @type Body 类型说明
  • @header Header 键值对;可以多个
  • @query Query 键值对;可以多个
  • @body Body 键值对;可以多个
  • @response 响应字段说明;可以多个
  • @code 响应错误码,多个逗号分隔
  • @change 接口变更记录,可以多个
  • @example 请求案例说明

tie:meta

Meta block

/**
 * @tie:meta
 * @key value
 * @key1 value1
 * @key2 value2
 * ...
 * **/

tie:markdown

Markdown block

/**
 * @tie:markdown
 * # Hi
 * This is content...
 * ...
 * **/

Example

see demo

/**
 * @tie
 * @author [email protected],[email protected]
 * @version 1.0
 * @code 0,10,200
 * @tags login,sign-in
 * @change Add feature 1 (2020-11-17)
 * @change Add feature 2 (2020-11-18)
 * @route POST /test
 * @title Sign In
 * @des Log on user
 * @query {number} [page=1] Page number
 * @query {number} [page=] Page size
 * @query {number} [pageSize=10] Page size
 * @body {string} username Username
 * @body {string} password Password
 * @response {object} data User Profile
 * @response {string} token Session Token
 * @example example/login
 * **/
function Func () {}

Will be generated


### Sign In

`login`, `sign-in`

```
POST /test
```

Log on user

**Changes:**

+ Add feature 1 (2020-11-17)
+ Add feature 2 (2020-11-18)

#### Query

| Key | Type | Required | Default | Description |
| :-----| :---- | :----: | :---- | :---- |
| page | number | False | `1` | Page number |
| page | number | False | `` | Page size |
| pageSize | number | False | `10` | Page size |

#### Body

| Key | Type | Required | Default | Description |
| :-----| :---- | :----: | :---- | :---- |
| username | string | True | — | Username |
| password | string | True | — | Password |

#### Response

| Key | Type | Description |
| :-----| :---- | :---- |
| data | object | User Profile |
| token | string | Session Token |

**Errcode:**

+ `0`
+ `10`
+ `200`

#### Contact

+ [[email protected]](#)
+ [[email protected]](#)

Support multi line comments

// @tie
// ...
// ...
// @tieEnd


// @tie
// @author [email protected],[email protected]
// @version 1.0
// @code 0,10,200
// @tags login,sign-in
// @change Add feature 1 (2020-11-17)
// @change Add feature 2 (2020-11-18)
// @route POST /foo
// @title Sign In
// @des Log on user
// @query {number} [page=1] Page number
// @query {number} [page=] Page size
// @query {number} [pageSize=10] Page size
// @body {string} username Username
// @body {string} password Password
// @response {object} data User Profile
// @response {string} token Session Token
// @example example/login
// @tieEnd
function Foo () {}

LICENSE

MIT