sphinxext-altair: Sphinx extension for embedding Altair charts
Project description
sphinxext-altair
sphinxext-altair provides the directive altair-plot
to insert live-rendered Altair plots within your Sphinx documentation:
.. altair-plot::
import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
shape='Origin'
)
You can enable the extension by adding it to your conf.py
:
extensions = [
...
"sphinxext_altair.altairplot",
...
]
You can find all available options in the docstring of sphinxext_altair/altairplot.py
. For more examples on how to use this extension, see the test Sphinx documentation in tests/roots/test-altairplot
or the official Altair documentation
Contributing
It's recommended to use a virtual environment for development:
python -m venv .venv
# Install the project in editable mode including development dependencies
pip install -e '.[dev]'
sphinxext-altair
uses black for code formatting, mypy for static type checking, ruff for various linting rules, and pytest for testing. All these tools can be executed by running:
hatch run test
As part of those tests, a Sphinx documentation is built at tests/roots/test-altairplot
. You can manually build this documentation and view it which is very useful during development of a new feature. For example, if you want to add a new option to the altair-plot
directive, you can add another example in the file tests/roots/test-altairplot/index.rst
and then build and view the documentation by running:
hatch run build-test-docs
hatch run serve-test-docs
The test documentation can now be viewed at http://localhost:8000.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sphinxext_altair-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a1a97e4c6556a2b093076c4657a6cdd566800be536840c03a6cbc0fbb2443f7 |
|
MD5 | add5a7e8237c3e8b809577331cde9b91 |
|
BLAKE2b-256 | 99dcc5a526646f17a88f31bbdcf8a977d2d74c0e826806f2efaebcd8b6a9fcf0 |