import sphinx from docutils import nodes from docutils.parsers.rst import Directive from docutils.parsers.rst import directives from docutils.statemachine import ViewList
class CustomDirective(Directive): has_content = True required_arguments = 1 option_spec = { } app = None def run(self): node = nodes.Element() node.document = self.state.document env = self.state.document.settings.env docname = env.docname new_content='\n'.join(self.content) sphinx.util.nodes.nested_parse_with_titles(self.state, ViewList(new_content. splitlines(), source=docname), node) return node.children I think the above is about the smallest example possible. It will take the content of the directive and render it as reST. --Peter On Tuesday, September 6, 2016 at 11:45:06 AM UTC-7, Jason S wrote: > > Custom role functions have an inliner: > > def myrole(role, rawtext, text, lineno, inliner, options={}, content=[]): > > ... > > > But what about a custom Directive? How can I get the inliner from within the > run() function? I need to call inliner.nested_parse(). > > > -- 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 sphinx-users+unsubscr...@googlegroups.com. To post to this group, send email to sphinx-users@googlegroups.com. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.