Sphinx Data Viewer

0.1.5 · active · verified Thu Apr 16

Sphinx Data Viewer is a Sphinx extension that provides an interactive list view for presenting JSON and Python data within your documentation. It allows users to display structured data directly from inline content, JSON files, or Python objects. The library is currently at version 0.1.5, released on August 28, 2024, and maintains an active development cadence tied to Sphinx compatibility.

Common errors

Warnings

Install

Imports

Quickstart

To get started with Sphinx Data Viewer, first install the package. Then, enable the extension by adding 'sphinx_data_viewer' to the `extensions` list in your Sphinx project's `conf.py` file. Finally, use the `.. data-viewer::` reStructuredText directive in your documentation files to display inline JSON, content from a JSON file, or data from a Python variable defined in `conf.py`. The `:expand:` option can be used to show the complete data by default.

# 1. Install the library:
# pip install sphinx-data-viewer

# 2. Add 'sphinx_data_viewer' to your conf.py extensions list:
# In docs/conf.py
# extensions = [
#     'sphinx.ext.autodoc',
#     'sphinx.ext.napoleon',
#     'sphinx_data_viewer'  # Add this line
# ]

# 3. Use the data-viewer directive in a reStructuredText file (e.g., index.rst):
# .. data-viewer::
#    :title: Example Data
#    :expand:
#
#    {
#        "name": "Alice",
#        "age": 30,
#        "is_student": false,
#        "courses": ["Math", "Science"]
#    }

# You can also load data from a file:
# .. data-viewer::
#    :file: my_data.json

# Or from a Python variable defined in conf.py:
# # In conf.py:
# # my_python_data = {'city': 'New York', 'population': 8000000}
# # In .rst file:
# # .. data-viewer::
# #    :var: my_python_data

view raw JSON →