Search code examples
python-sphinxrestructuredtextdocutils

Adding custom Exercise Environment blocks in reStructured Text


Is there an environment for formatting exercises? Something like

.. exercise:: Count to 10

   Write down all the numbers from 1 to (including 10)

I.e. this is for an instructional documentation that challenges the reader to work through the material.


Solution

  • You can add your custom semantics and style with admonition.

    E.g. the example:

    .. admonition:: description
    
            Here is some info for basic Plone troubleshooting, especially with add-on modules.
    

    The resulting output will have admonition-description CSS class. Then you can then style with CSS, :after and :before pseudo-selectors e.g. if you want to add an exercise icon next to the text.

    A random example file