# node-docson

> Documentation for your JSON types on node

Latest version **0.4.6** (published 2017-07-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install node-docson
pnpm add node-docson
yarn add node-docson
bun add node-docson
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.6 |
| Published | 2017-07-18 |
| First published | 2017-06-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Faister Cabrera Carvalho |
| Maintainers | texkiller |
| Keywords | json, schema, documentation, node |

## Links

- npm: https://www.npmjs.com/package/node-docson
- Repository: https://github.com/TexKiller/node-docson
- Homepage: https://github.com/TexKiller/node-docson#readme
- Issues: https://github.com/TexKiller/node-docson/issues
- npm.io page: https://npm.io/package/node-docson

## Dependencies (7)

- [jsdom](https://npm.io/package/jsdom.md) ^11.0.0
- [marked](https://npm.io/package/marked.md) ^0.3.5
- [traverse](https://npm.io/package/traverse.md) ^0.6.6
- [handlebars](https://npm.io/package/handlebars.md) ^4.0.5
- [highlight.js](https://npm.io/package/highlight.js.md) ^9.6.0
- [sync-request](https://npm.io/package/sync-request.md) ^4.1.0
- [jsonpointer.js](https://npm.io/package/jsonpointer.js.md) ^0.4.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.4.6 (latest) — 2017-07-18
- 0.4.4 — 2017-07-15
- 0.4.2 — 2017-07-15
- 0.4.1 — 2017-07-14
- 0.4.0 — 2017-07-13
- 0.3.0 — 2017-07-10
- 0.2.0 — 2017-07-02
- 0.1.0 — 2017-06-26

## README

#  Node-Docson

[![NPM version](https://img.shields.io/npm/v/node-docson.svg)](https://www.npmjs.com/package/node-docson) [![node](https://img.shields.io/node/v/gh-badges.svg)](http://nodejs.org/)

Documentation for your JSON types on Node.js.

Give Node-Docson a JSON schema and it will generate a [beautiful documentation](http://lbovet.github.io/docson/index.html#/docson/examples/example.json).

## Features
* [JSON schema](http://json-schema.org/) v4 keywords.
* Runs on Node.js and on the browser (using browserify or webpack).
* Render schema descriptions with markdown.

## Installation

`npm install node-docson`

## Usage

Node example:

```js
var docson = require("node-docson")();

var schema = {
  "title": "Example Schema",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "age": {
      "description": "Age in years",
      "type": "integer",
      "minimum": 0
    }
  },
  "required": ["firstName", "lastName"]
};

var element = docson.doc(schema);
fs.writeFileSync("./index.html", element.ownerDocument.documentElement.outerHTML);
```

Browser example:

```html
<html>
    <head>
        <title>
            node-docson script tag example
        </title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
        <script type="text/javascript" src="https://github.com/TexKiller/node-docson/releases/download/v0.4.6/node-docson.min.js"></script>
    </head>
    <body>
        <div id="element"></div>
        <script type="text/javascript">
            var docson = nodeDocson();

            var schema = {
                "title": "Example Schema",
                "type": "object",
                "properties": {
                    "firstName": {
                        "type": "string"
                    },
                    "lastName": {
                        "type": "string"
                    },
                    "age": {
                        "description": "Age in years",
                        "type": "integer",
                        "minimum": 0
                    }
                },
                "required": ["firstName", "lastName"]
            };

            docson.doc(schema, "element");
        </script>
    </body>
</html>
```

## API

Requiring Node-Docson (Node.js only):
```javascript
var nodeDocson = require("node-docson");
```
* Not necessary if including the Node-Docson release script on the browser using the `script` HTML tag.

Creating Docson instance:
```javascript
var docson = nodeDocson(opt);
```
* `opt` (optional) is an object holding the following properties. If not set, the default value for each property will be used.
* `opt.document` (optional) specifies the document node that will hold the documentation. If not set, [JSDOM](https://github.com/tmpvar/jsdom) will be used to create one on Node.js, and the global `document` variable will be used on the browser.
* `opt.$` (optional) specifies the [jQuery](https://github.com/jquery/jquery) instance. If not set, an instance will be created using `require('jquery')(opt.document.defaultView)` on Node.js, and the global `$` variable will be used on the browser.

Documenting a JSON Schema:
```javascript
var domElement = docson.doc(schema, element, ref);
```
* `schema` is the URI or path to the JSON Schema or a string containing the schema source itself.
* `element` (optional) is the element which will host the documentation. Either a DOM element (id or object) or jQuery element.
* `ref` (optional) is an json-pointer path to a sub-schema.

* `domElement` is the DOM element that holds the documentation for the specified schema, or `null` on failure.


## Limitations

* Mixing unrelated keywords can lead to unexpected results.

Not implemented:
* Non-primitive values in enums and default values
* dependencies, additionalItems, patternProperties

## Development

Please pull-request your failing schemas in the `tests/` folder and open an issue describing the expected result.

---
_Source: https://npm.io/package/node-docson · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
