Hello,

I'm trying to learn how to extend Sphinx. I need to create new directives 
and other stuff, so I tried to start off with a simple directive, which 
encloses the contents in div tags of certain class in the html output. This 
is the closest I got:

=======
from docutils import nodes
from docutils.parsers.rst import Directive

class example_node(nodes.raw):
    pass

class Examp(Directive):

    has_content = True

    def run(self):
        node = example_node(text=self.content, format='html')
        return [node]

def setup(app):
    app.add_directive('example', Examp)
    app.add_node(example_node, html=(visit_example, depart_example))

def visit_example(self, node):
    self.body.append(self.starttag(node, 'div', CLASS='example'))
def depart_example(self, node):
    self.body.append('</div>\n')
========

However, it is far from satisfactory: the contents are not parsed further, 
e.g. roles inside are not processed.

Can you point me to the right direction to do this? If possible, I would be 
grateful not only for a code example, but also on hints on where to look 
and learn more.

BTW, I've been dealing with this for quite some time. All the ideas I got 
are from code I read from other people. I tried to follow the tutorial, but 
it has been of no help. In general, I feel like Sphinx and Docutils are 
poorly documented for newbies, but maybe it's just me. I have a lot of 
comments on the tutorial, but I don't know if anybody is interested on 
reading them?

Thanks for your help

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to