views:

378

answers:

1

Is there a way to automatically generate an image/figure caption using sphinx?

I currently have rest-sphinx files I'm converting to html and (latex)pdf using sphinx.

I'd like an easy way for users to reference a specific image in the resulting html/pdf files. For example, if a user is refering to the documentation in an email, "In 'Image 65' it says XXX, but this doesn't work for me".

I've tried using figure where it appears to allow you to apply a caption to an image, but this has to be manually added. (And I have problems getting it to work with substitution for some reason).

Is there a rest-sphinx method I'm overlooking that would achieve this? Or, is there a way to modify/edit sphinx's existing templates to add this ability?

+2  A: 

Sphinx consumes reStructuredText as templated by Jinja. According to the Sphinx documentation though, you have other templating options.

You should be able to use Jinja's control structures in a custom template to achieve the effect you're after.

bignose
I have sphinx-rest files, which I am converting to html and pdf using sphinx. I'm really wondering if there's an option or method for doing this within the sphinx framework that I'm overlooking. For example, if there's some way to edit sphinx's existing templating system to add this ability.
monkut
@monkut: Please update your question with additional facts -- do not put new information in a comment.
S.Lott
@S.Lott: Thanks, I've updated the question with further detail.
monkut
I haven't done this yet, but after re-review this makes sense, I'll take a look.
monkut