Pages

Thursday, August 15, 2013

Directives in reST

In reST, directive is a general block of explicit markup. It is widely used extension method for reST. You can think of it a method call with a parameter. For example, the image directive is a function that has an input as path to the picture; it returns an output of HTML img tag.
> .. image:: ./image/img.png

> <img alt="./image/img.png" src="./image/img.png" />
reST also enables to incorporate img tag wherever you want with |…| attached in front of the image directive.
|bio| is bio

.. |bio| image:: ./image/img.png

<p><img alt="bio" src="./image/img.png" /> is bio

Maybe, one the most popular directives is code block in Sphinx. This is an example of Python code block, but you can use other languages such as Ruby, C, and even reST itself.
.. code_block:: python
  
   python code ...

No comments:

Post a Comment