Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 737
Isaac Dontje Lindell Avatar asked May 23 '13 17:05

Isaac Dontje Lindell


People also ask

What is Maxdepth in Toctree?

toctree:: :maxdepth: 2 intro strings datatypes numeric (many more documents listed here) This accomplishes two things: Tables of contents from all those documents are inserted, with a maximum depth of two, that means one nested heading. toctree directives in those documents are also taken into account.

How do you use a sphinx code block?

Literal code blocks (ref) are introduced by ending a paragraph with the special marker :: . The literal block must be indented (and, like all paragraphs, separated from the surrounding ones by blank lines): This is a normal text paragraph.


1 Answers

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
like image 168
lpa Avatar answered Oct 05 '22 19:10

lpa