{"id":8668,"library":"sphinx-data-viewer","title":"Sphinx Data Viewer","description":"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.","status":"active","version":"0.1.5","language":"en","source_language":"en","source_url":"https://github.com/useblocks/sphinx-data-viewer","tags":["sphinx","documentation","data-viewer","json","python-data","extension"],"install":[{"cmd":"pip install sphinx-data-viewer","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency as this is a Sphinx extension.","package":"Sphinx","optional":false},{"reason":"Requires Python 3.8 or newer.","package":"Python","optional":false}],"imports":[{"note":"Sphinx Data Viewer is a Sphinx extension, not a Python library with direct runtime imports. It is enabled by adding its module name to the 'extensions' list in Sphinx's conf.py configuration file.","symbol":"sphinx_data_viewer","correct":"# In conf.py\nextensions = [\n    \"sphinx_data_viewer\"\n]"}],"quickstart":{"code":"# 1. Install the library:\n# pip install sphinx-data-viewer\n\n# 2. Add 'sphinx_data_viewer' to your conf.py extensions list:\n# In docs/conf.py\n# extensions = [\n#     'sphinx.ext.autodoc',\n#     'sphinx.ext.napoleon',\n#     'sphinx_data_viewer'  # Add this line\n# ]\n\n# 3. Use the data-viewer directive in a reStructuredText file (e.g., index.rst):\n# .. data-viewer::\n#    :title: Example Data\n#    :expand:\n#\n#    {\n#        \"name\": \"Alice\",\n#        \"age\": 30,\n#        \"is_student\": false,\n#        \"courses\": [\"Math\", \"Science\"]\n#    }\n\n# You can also load data from a file:\n# .. data-viewer::\n#    :file: my_data.json\n\n# Or from a Python variable defined in conf.py:\n# # In conf.py:\n# # my_python_data = {'city': 'New York', 'population': 8000000}\n# # In .rst file:\n# # .. data-viewer::\n# #    :var: my_python_data","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to sphinx-data-viewer version 0.1.5 or newer: `pip install --upgrade sphinx-data-viewer`.","message":"Version 0.1.5 fixed deprecations related to Sphinx's handling of CSS/JS assets. Older versions of sphinx-data-viewer (pre-0.1.5) may cause build failures or display issues with newer Sphinx versions due to these changes.","severity":"breaking","affected_versions":"<0.1.5"},{"fix":"Simply include `:expand:` without any value to enable it, like this: `.. data-viewer:: :expand: { ... }`.","message":"The `:expand:` option for the `data-viewer` directive is a flag and does not require a value. Providing a value or incorrect syntax (e.g., `:expand: True`) can lead to the option not being recognized or unexpected behavior.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `sphinx-data-viewer` to version 0.1.5 or later: `pip install --upgrade sphinx-data-viewer`.","cause":"Using an older version of `sphinx-data-viewer` that relies on deprecated Sphinx APIs for managing CSS/JS assets.","error":"Sphinx build fails with errors related to 'add_css_file' or 'add_js_file' after updating Sphinx."},{"fix":"Open your `conf.py` and ensure `\"sphinx_data_viewer\"` is present in the `extensions` list.","cause":"The `sphinx_data_viewer` extension has not been correctly added to the `extensions` list in your Sphinx project's `conf.py` file.","error":"WARNING: Unknown directive type \"data-viewer\"."},{"fix":"Carefully check the JSON syntax for correctness, verify file paths (absolute or relative to the current document), or ensure the Python variable is correctly named and available in the `conf.py` scope.","cause":"This typically occurs due to invalid JSON syntax for inline data, incorrect file paths for the `:file:` option, or the specified Python variable for `:var:` not being accessible or correctly defined in `conf.py`.","error":"Data specified in `data-viewer` directive is not displayed or appears malformed in the output."}]}