Hi Georg,

On Jan 22, 8:43 pm, Georg Brandl <[email protected]> wrote:
> >> (Maybe I did not RTFM well enough.  Sorry, if it's the case)
>
> >> I'm writing documentation for an application and there are two things
> >> I do not know how to do :)
>
> >> 1. I would like to refer to toolbar images application offers, however
> >> I do not really want to copy images to the directory where
> >> documentation sources reside.
>
> >> 2. The application has slightly different icons depending on the
> >> target platform.  I'd like the documentation to show correct icons
> >> when generated for those different platforms.
>
> image paths are always relative to the directory of the document that
> contains them.
>
> Your problem could be solved by a custom image directive, e.g. add this
> to your conf.py (this assumes docutils 0.5):
>
> from docutils.parsers.rst.directives.images import Image
>
> def platimage_directive(desctype, arguments, options, content, lineno,
>                         content_offset, block_text, state, state_machine):
>     # run the standard Image directive
>     ret = Image('image', arguments, options, content, lineno,
>                 content_offset, block_text, state, state_machine).run()
>     # fetch the config value and modify the URI of the image node
>     env = state.document.settings.env
>     ret[-1]['uri'] = env.config.platform + '/' + ret[-1]['uri']
>     # return everything the image directive returned
>     return ret
>
> def setup(app):
>     # register the new directive and the new config value
>     app.add_directive('platimage', platimage_directive, 0, (1, 0, 1),
>                       **Image.option_spec)
>     app.add_config_value('platform', 'win', True)
>
> Then use .. platimage:: instead of .. image:: and set the "platform"
> value in conf.py accordingly.
Thanks for the suggestion! :)  I could not get this working though:
Image is not available in the specified module (maybe, I'm using a
wrong version of docutils, however the standard ``.. image:`` works
just fine).

While changing ``Image`` to ``image`` and ``.option_spec`` to
``.options`` I got it to ``.run()``, where I am now completely
clueless.

Could you please help? :)

--
Misha
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to