Walid-Shouman
6/16/2017 - 6:25 PM

some tips using sphinx

some tips using sphinx

Cheatsheet

Directives

Images

Variable folder name for images

A well-known case is internationalization.
Strictly speaking we can't have a variable folder name, but this question has the answer for how we can overcome that.

Default directory

By using image directive, in example,

.. image::myimage.png

Image search will check the folder of the .rst file for the image. Or it will use it as an absolute path if that's applicable.

ie: if the .rst location was projectname/doc/sphinx/source/core/file.rst and we need to access projectname/doc/doxygen/html/anotherimage.png, we'll need to use the following

.. image::../../../doxygen/html/anotherimage.png

Custom directory

Unfortunately, there's no simple way for that, creating an extension specially for that is illustrated here.

Constants

Based on this SO answer we can set some constants through the .rst. But we can't use that in directives according to this SO answer

References

A brief to configure conf.py.