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

@grava.io/api-doc

v1.1.1

Published

Transform commented documentation into markdown formatted documentation

Downloads

329

Readme

@grava.io/api-doc

@grava.io/api-doc is a module that allows you transform commented documentation into markdown formatted documentation. Make comments in the code and export an markdown documentation!

Install from npm

npm install -g @grava.io/api-doc

Run

Help:

api-doc --help

Result:

Usage: api-doc [options]

Transform commented documentation into markdown formatted documentation

Options:
  -V, --version        output the version number
  -f, --files <path>   Folder to analize
  -o, --output <path>  Output path to save markdown documentation. If is not defined, it will print on console
  -h, --help           display help for command

Route definitions format

The definitions must be inside a "comment" with this format:

/*

*/

To make it preattier we use this convention:

/**
 * definition_line
 * definition_line
 * definition_line
 */

Inside this structure you can use different type of definitions:

Name

In this definition you must define a title for your route.

Format:

@name ROUTE_NAME

For example:

@name List user posts

Description

In this definition you must define a more specific description for your route.

Format:

@description ROUTE_DESCRIPTION

For example:

@name In this route you can get all post of an specific user. You must send a userId and you can filter post by some fields.

Route

In this definition you must define a the method and path for your route.

Format:

@route {ROUTE_METHOD} ROUTE_COMPLETE_PATH

For example:

@route {GET} /users/:userId/posts

Parameters

With this definitions you can specify the parameters of the route (both required and optional). There are 4 types of parameters, but all have the same format:

@PARAMETER_TYPE (optional) {PARAMETER_FIELD_TYPE} [PARAMETER_FIELD_NAME] PARAMETER_FIELD_DESCRIPTION

with this options:

  • PARAMETER_TYPE: could be "headerparam", "urlparam", "queryparam", "bodyparam"
  • (optional): it says that the parameter is optional. If the parameter is requered don't include this
  • PARAMETER_FIELD_TYPE: the data type of the field. For example: "string", "number", "date", "array", "object"
  • PARAMETER_FIELD_NAME: the name of the field
  • PARAMETER_FIELD_DESCRIPTION: a description of the field. Here you can explain posibles values, validations, etc

Examples of each parameter type:

headerparam

@headerparam {string} [Authorization] JWT token

urlparam

@urlparam {string} [userId] The user identifier

queryparam

@queryparam (optional) {date} [dateFrom] filter the results after this date
@queryparam {string} [category] filter the post category. Posibles values: "sports", "memes", "music"

bodyparam

@bodyparam {number} [age] User age
@bodyparam (optional) {string} [address] User full address with street, number and postal code

Responses

With this definitions you can specify the posible responses of the route (with status). Inside this definition you can spicify the body response.

Format:

@response {RESPONSE_STATUS} RESPONSE_TITLE

For example:

@response {201} User information was succesfully

or

@response {400} Invalid field value

Response body

After a "response" line you can add "responsebody" definitions. IMPORTANT: the responsebody definitions must be following the response definition.

Format:

@responsebody {RESPONSE_FIELD_TYPE} [RESPONSE_FIELD_NAME] RESPONSE_FIELD_DESCRIPTION

For example:

@responsebody {number} [age] User age
@responsebody {string} [address] User address

Examples

You can find some examples in the "examples" folder