Skip to main content

jsonschema2rst

This project aims to parse JSON schemas or YAML schemas in order to create RestructuredText documentation. Using a tool like Sphinx, it is possible to create high readable documentation from the files generated, which are RST formatted text.

The outcome RST can be customized by defining a blacklist in csv and using a custom CSS file. that will inherit the Sphinx one. For the latter, an example is provided.

Usage

To create RST files from JSON schemas (or YAML) run the command:

jsonschema2rst input_folder output_folder

This command will take all JSON or YAML files in this path, sub-folders included, and wll create a new directory - removing it if already exists - where all parsed RST file will be placed.

Example

Let's assume you run the following command:

jsonschema2rst json_folder rst_output_folder

and also let's assume the folder json_folder contains the file url.json, which contains the following schema:

{
    "title": "URL of related document",
    "properties": {
        "description": {
            "type": "string"
        },
        "value": {
            "format": "url",
            "type": "string"
        }
    },
    "type": "object"
}

As result, jsonschema2rst will create a file called url.rst in the rst_output_folder that will contain the following rst code:

.. contents:: Table of Contents
.. section-numbering::
.. container:: section-title
 url.json

.. container:: title

 URL of related document

**type** : ``object``

**Properties:** description_, value_


.. description:

description
+++++++++++

**type** : ``string``


.. value:

value
+++++


**type** : ``string``

**format** : ``url``

Testing

Install the project along with its test dependencies using Poetry:

poetry install --with tests

Then run the test suite with pytest:

poetry run pytest --cov=jsonschema2rst --cov-report=term-missing tests jsonschema2rst

The project also uses pre-commit for linting and formatting checks (via ruff). To run all hooks against the whole codebase:

pre-commit run --all-files

Extra

In case you want to generate HTML documentation using a tool like Sphinx, we suggest you to try the custom.css file in the contribution folder to make your schemas documentation looking better. What you need is just replace the default css used by Sphinx in the conf.py file with the one proposed, then enjoy!

Release files for jsonschema2rst 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema2rst 0.1.8
File Size Uploaded
jsonschema2rst-0.1.8.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema2rst 0.1.8
File Interpreter ABI Platform
jsonschema2rst-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 58.5 kB

Release files / jsonschema2rst-0.1.8.tar.gz

Download URL jsonschema2rst-0.1.8.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f72ca4d351d99dc6b0ddcb1274015c1caef1be9b2d7a5b63e8ac9cafd28d851b
BLAKE2b-256 checksum
How to use checksums
80082a82d910df3b0e5cf4eb8692895eab301e544df2ca4ac6801b2802fc70f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / jsonschema2rst-0.1.8-py3-none-any.whl

Download URL jsonschema2rst-0.1.8-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9f9849f6b2f0253a8077ee20140e11d5348244883920a5313b321ffb74e5c1d
BLAKE2b-256 checksum
How to use checksums
840cf949fa80c21a7daf13987b7f3773f484aa6ea94ccfffcd1ca3ee4e6cb7d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page