Skip to content

Latest commit

 

History

History
108 lines (79 loc) · 3.01 KB

README.md

File metadata and controls

108 lines (79 loc) · 3.01 KB

wetzel

Generate Markdown documentation from JSON Schema

Example

This JSON Schema:

{
    "$schema" : "http://json-schema.org/draft-03/schema",
    "title" : "example",
    "type" : "object",
    "description" : "Example description.",
    "properties" : {
        "byteOffset" : {
            "type" : "integer",
            "description" : "The offset relative to the start of the buffer in bytes.",
            "minimum" : 0,
            "default" : 0
        },
        "type" : {
            "type" : "string",
            "description" : "Specifies if the elements are scalars, vectors, or matrices.",
            "enum" : ["SCALAR", "VEC2", "VEC3", "VEC4", "MAT2", "MAT3", "MAT4"],
            "required" : true
        }
    },
    "additionalProperties" : false
}

is used to generate this Markdown documentation:

example

Example description.

Properties

Type Description Required
byteOffset integer The offset relative to the start of the buffer in bytes. No, default: 0
type string Specifies if the elements are scalars, vectors, or matrices. ✅ Yes

Additional properties are not allowed.

example.byteOffset

The offset relative to the start of the buffer in bytes.

  • Type: integer
  • Required: No, default: 0
  • Minimum: >= 0

example.type ✅

Specifies if the elements are scalars, vectors, or matrices.

  • Type: string
  • Required: Yes
  • Allowed values: "SCALAR", "VEC2", "VEC3", "VEC4", "MAT2", "MAT3", "MAT4"

Getting Started

Install Node.js if you don't already have it, clone this repo, and then:

cd wetzel
npm install

Run node bin/wetzel.js and pass it the path to a file with a JSON Schema, and the generated Markdown is output to the console.

It is useful to pipe the Markdown output to the clipboard and then paste into a temporary GitHub issue for testing.

On Mac:

wetzel ../glTF/specification/schema/accessor.schema.json -l 2 | pbcopy

On Windows:

wetzel ../glTF/specification/schema/accessor.schema.json -l 2 | clip

The -l option specifies the starting header level.

Limitations

This tool was developed to generate reference documentaiton for the glTF schema. As such, it currently only supports JSON Schema 3 and doesn't support the entire JSON Schema spec. However, wetzel is easy to hack on, just edit lib/generateMarkdown.js.

Contributions

Pull requests are appreciated. Please use the same Contributor License Agreement (CLA) used for Cesium.


Developed by the Cesium team.