pythonpython-sphinxrestructuredtextdocutils

Nesting Sphinx extension directives with reST


I'm trying to figure out if there's a way to nest Sphinx extension directives. I have a few custom node types that are working great, but I'd like a little more flexibility in the HTML I'm generating.

Here's an example of what I'm trying to accomplish:

Say I have a directive that creates a textbox and button that triggers some JavaScript. This works fine - I can put this in my reST file:

.. myDirective:: name
    :opt1: val
    content

Now, I want the ability to create a tabbed interface with jQuery in the output. I have a node type that creates the raw HTML/JavaScript needed for this to happen.

What I would like to be able to do is give the tab node 1 or more instances of myDirective (or other directives), and have it put each instance into another tab. Something like this:

..tabbedInterface:: 
    .. myDirective:: name1
        :op1: val1
        content

    .. myDirective:: name2
        :op1: val1
        content

Obviously this is a pretty specific case, but this is generally what I'd like to accomplish - nested directives.


Solution

  • The configuration-block extension might help you : https://github.com/fabpot/sphinx-php/blob/master/sensio/sphinx/configurationblock.py

    From : http://symfony.com/doc/2.0/contributing/documentation/format.html#configuration-blocks

    .. configuration-block::
    
      .. code-block:: yaml
    
        # Configuration in YAML
    
      .. code-block:: xml
    
        <!-- Configuration in XML //-->
    
      .. code-block:: php
    
        // Configuration in PHP