Hmm, I don't use self.state.nested_parse, this is how I've done it:

        sphinx.util.nodes.nested_parse_with_titles(self.state, 
                                                   ViewList(new_content.
splitlines(), source=docname),
                                                   node)     
        return node.children
Where new_content is the reST code to parse, and node is the current node.


On Monday, January 28, 2019 at 9:38:50 AM UTC-8, Matthew Woehlke wrote:
>
> On 23/01/2019 10.27, Maxime Adam wrote: 
> > With that's said I'm willing to do this following directive 
> > 
> > class MarkAsDeprecated(Directive): 
> > 
> >     def run(self): 
> > 
> >         txt = "Blablabla moved to :doc:{0}".format(self.arguments[0]) 
> >         paragraph_node = nodes.paragraph(text=txt) 
> > 
> >         return [paragraph_node] 
> > 
> > But :doc: is not render. I think I should insert a pending_xref (not 
> > sure it's the correct one but it's seems to be) node but I really 
> > don't know how to do it. 
>
> In such cases, I find it is often helpful to look at how the role in 
> question is implemented. 
>
> However, there is another option which you may find easier, especially 
> as you need to generate several nodes for your directive's body: use 
> self.state.nested_parse to convert your reST source to nodes. 
>
> -- 
> Matthew 
>

-- 
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 https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to