I feel like I am so close to finding this answer, but I'm not finding 
anything.  

I moved on to my second custom directive. I figured out a lot of things, 
but this one small bit...

Anyway. I have managed to get everything to the HTML except the classes on 
the span elements.


Here's the generated pseudoxml:

<target refid="source-0">
        <source ids="source-0">
            Aoife's Kiss
            <inline class="issue">
                24
            <inline class="url">
                http://www.sdpbookstore.com/aoifeskiss.htm


The HTML looks like I'd expect, but the spans don't have the class

 <div class="source" id="source-0">
Aoife's 
Kiss<span>24</span><span>http://www.sdpbookstore.com/aoifeskiss.htm</span></div>

 

 Here is the text of the directive:

class sourceDirective(Directive):
    has_content = False
    required_arguments = 0
    optional_arguments = 2
    final_argument_whitespace = True
    option_spec = {'issue': directives.unchanged,
                   'url': directives.uri}

    def run(self):
        env = self.state.document.settings.env

        # targetnode is an invisible node used to mark the original 
reference
        targetid = "source-%d" % env.new_serialno('source')
        targetnode = nodes.target('', '', ids=[targetid])


        this_node = source(self.content)
        source_name = ' '.join(self.arguments)
        this_node += nodes.Text(source_name, source_name)
        for opt in ['issue','url']:
            val = self.options.get(opt)
            if val is None:
                continue

            this_node += nodes.inline(val, val, CLASS=(opt,))


        if not hasattr(env, 'source_all_sources'):
            env.source_all_sources = defaultdict(list)

        env.source_all_sources[source_name].append({
            'docname': env.docname,
            'lineno': self.lineno,
            'source': this_node.deepcopy(),
            'target': targetnode})

        return [targetnode] + [this_node]



Any ideas? I haven't found a site explaining this. I think I'm missing 
something in the writer, but I haven't managed to figure out that code at 
all.

Josh 

-- 
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