• Stars
    star
    133
  • Rank 271,349 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate Markdown documentation from JSON Schema

wetzel

Generate Markdown or AsciiDoctor documentation from JSON Schema

Purpose and Limitations

This tool was developed to generate reference documentation for the glTF schema. As such, it doesn't support the entire JSON Schema spec, only what is needed by the glTF schema. Currently it accepts JSON Schema drafts 3, 4, 7, and 2020-12.

Example

This JSON Schema:

{
    "$schema" : "https://json-schema.org/draft/2020-12/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" : ["type"],
    "additionalProperties" : false
}

can be used to generate this Markdown documentation:


example

Example description.

example 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/2.0/schema/accessor.schema.json -l 2 | pbcopy

On Windows:

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

Run the tests:

npm run test

There's also a version published on npm.

Command-Line Options

  • The -l option specifies the starting header level.
  • The -c option lets you specify a custom symbol to place in front of required properties.
  • The -k option replaces the word must with a specified keyword, such as **MUST**.
  • The -p option lets you specify the relative path that should be used when referencing the schema, relative to where you store the documentation.
  • The -s option lets you specify the path string that should be used when loading the schema reference paths.
  • The -e option writes an additional output file that embeds the full text of JSON schemas (AsciiDoctor mode only).
  • The -m option controls the output style mode. The default is Markdown, use -m=a for AsciiDoctor mode.
  • The -n option will skip writing a Table of Contents.
  • The -w option will suppress any warnings about potential documentation problems that wetzel normally prints by default.
  • The -d option lets you specify the root filename that will be used for writing intermediate wetzel artifacts that are useful when doing wetzel development.
  • The -a option will attempt to aggressively auto-link referenced type names in descriptions between each other. If it's too aggressive, you can add =cqo so that it only attempts to auto-link type names that are within "code-quotes only" (cqo) (e.g.: typeName)
  • The -i option lets you specify an array of schema filenames that might be referenced by others, but shouldn't get their own documentation section.

Common Usage

This tool is used to generate the glTF Properties Reference section and the JSON Schema Reference Appendix of the glTF specification, using the glTF JSON Schema files as its input data.

The process is initiated from a GitHub Action in the glTF repository (CI.yml). This action runs glTF's Makefile. The Makefile calls wetzel with a command similar to the following:

~/bin/wetzel.js \
    -n -a=cqo -m=a \
    -p "schema" \
    -e "JsonSchemaReference.adoc" \
    -i '["gltfchildofrootproperty.schema.json", "gltfid.schema.json", "gltfproperty.schema.json"]' \
    -c "icon:check[]" \
    -k "**MUST**" \
    schema/glTF.schema.json > PropertiesReference.adoc

This will read schema/glTF.schema.json and all referenced sub-schemas, and produce two different output files:

These files are then included into glTF's Specification.adoc using AsciiDoc include commands:

[[properties-reference]]
= Properties Reference

// Generated with wetzel
include::PropertiesReference.adoc[]

and later:

[appendix]
[[appendix-a-json-schema-reference]]
= JSON Schema Reference (Informative)

// Generated with wetzel
include::JsonSchemaReference.adoc[]

Finally, the Makefile uses asciidoctor to convert Specification.adoc and its included, generated documentation, into HTML and PDF forms of the final glTF specification document, which are then posted to the glTF Registry.

Contributions

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


Developed by the Cesium team and external contributors.

More Repositories

1

cesium

An open-source JavaScript library for world-class 3D globes and maps 🌎
JavaScript
12,400
star
2

3d-tiles

Specification for streaming massive heterogeneous 3D geospatial datasets 🌎
Batchfile
2,046
star
3

gltf-pipeline

Content pipeline tools for optimizing glTF assets. 🌐
JavaScript
1,872
star
4

obj2gltf

Convert OBJ assets to glTF
JavaScript
1,677
star
5

cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
C++
884
star
6

3d-tiles-validator

Validator for 3D Tiles 🚦
TypeScript
415
star
7

webglreport

A web page that reports a browser's WebGL capabilities, including supported extensions and implementation specific capabilities, such as the maximum number of texture units.
JavaScript
393
star
8

cesium-native

C++
390
star
9

cesium-unity

Bringing the 3D geospatial ecosystem to Unity
C#
319
star
10

3d-tiles-samples

Sample tilesets for learning how to use 3D Tiles 📚
JavaScript
266
star
11

3d-tiles-tools

TypeScript
248
star
12

cesium-webpack-example

The minimal recommended setup for an application using Cesium with Webpack.
JavaScript
241
star
13

quantized-mesh

Specification for streaming massive terrain datasets for 3D visualization.
233
star
14

cesium-unity-samples

Sample project for Cesium for Unity
C#
214
star
15

cesium-threejs-experiment

A small example for using Three JS on Cesium to emulate a combined scene.
JavaScript
184
star
16

cesium-unreal-samples

Getting Started Sample Project for Cesium for Unreal
179
star
17

cesium-workshop

An example application that visualizes and annotates a 3D city using the Cesium platform.
JavaScript
162
star
18

cesium-google-earth-examples

Google Earth plugin API samples ported to Cesium
JavaScript
93
star
19

cesium-materials-pack

A Cesium plugin with procedurally-shaded materials such as bricks, wood, and noise patterns
JavaScript
84
star
20

cdb-to-3dtiles

Convert CDB to 3D Tiles
C++
74
star
21

cesium-o3de

Cesium for O3DE
C++
70
star
22

cesium-omniverse

Bringing the 3D geospatial ecosystem to Omniverse
C++
49
star
23

cesium-ion-rest-api-examples

Code examples for using the Cesium ion REST API 🌎
JavaScript
35
star
24

cesium-unreal-vr-tutorial

Unreal Engine project, assets, and code used in the Cesium for Unreal VR Tutorial Series
30
star
25

cesium-vite-example

The minimal recommended setup for an application using Cesium with Vite.
JavaScript
27
star
26

cesium-ion-blender-addon

Blender add-on for uploading and tiling models with Cesium ion. https://cesium.com
Python
20
star
27

collada2gltf-web-service

Simple Node.js web service to convert 3D models from COLLADA to glTF
JavaScript
20
star
28

cesium-ion-3ds-max-plugin

Autodesk 3DS Max plugin for uploading and tiling models with Cesium ion.
MAXScript
14
star
29

cesium-omniverse-samples

Sample projects for Cesium for Omniverse
12
star
30

3d-tiles-samples-generator

TypeScript
12
star
31

webstorm-plugin

Kotlin
8
star
32

OpenPhillyGlobe

"Google Earth for Philadelphia" with open source and open data.
JavaScript
7
star
33

cesium-ion-sketchup-extension

SketchUp extension for uploading and tiling models with Cesium ion.
Ruby
7
star
34

cesium-concierge

I automate common GitHub tasks
JavaScript
6
star
35

cesium-o3de-samples

Samples project for Cesium for O3DE
CMake
4
star
36

strip-pragma-loader

JavaScript
4
star
37

eslint-config-cesium

ESLint Configuration for Cesium
JavaScript
1
star
38

cesium-ion-plugin-template

1
star