i'm writing custom roles/directives in sphinx, , need insert node in interpret text string restructuredtext. there way this?
i found source http://agateau.com/2015/docutils-snippets says how use docutils.nodes
classes construct doctree fragment programmatically, e.g.
class bulletlist(directive): def run(self): fruits = ['apples', 'oranges', 'bananas'] lst = nodes.bullet_list() fruit in fruits: item = nodes.list_item() lst += item item += nodes.paragraph(text=fruit) return [lst]
what want like
:myrole:`this *really* cool|trade|`
by doing in conf.py:
def myrole(name, rawtext, text, lineno, inliner, options={}, content=[]): # somehow convert "text" parameter docutils nodes # interpreting rst nodes = ???? goes here ??? return nodes, [] def setup(app): app.add_role('myrole', myrole)
Comments
Post a Comment