vega / sphinxext-altair

BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

Add captions #8

Open mrocklin opened 4 months ago

mrocklin commented 4 months ago

Lovely project. Thanks! I've really been enjoying using it.

Question: I'd like to be able to add captions to these images as I would do with a Sphinx Figure. Is there an easy way to do that? Does this project support a caption, or is there an easy pattern that people use to combine this with the figure directive?

binste commented 4 months ago

Thanks for the feedback, happy to hear you find this useful! Honestly, I just moved this code out of the Altair repo into a separate codebase but I'm not too familiar with Sphinx. Seems like the relevant source code for the figure directive is https://github.com/docutils/docutils/blob/master/docutils/docutils/parsers/rst/directives/images.py#L159. We could add a caption option to the altair plot directive and then add it as a caption node to result in https://github.com/vega/sphinxext-altair/blob/main/sphinxext_altair/altairplot.py#L222.

I don't have the capacity to look into this right now but I could review a PR if someone can pick this up :)