in doc/ext/extras/txnbox.cmake.in.py [0:0]
def run(self):
env = self.state.document.settings.env
txb_name = self.arguments[0]
txb_id = nodes.make_id(txb_name)
# First, make a generic desc() node to be the parent.
node = sphinx.addnodes.desc()
node.document = self.state.document
node['objtype'] = 'directive'
# Next, make a signature node. This creates a permalink and a highlighted background when the link is selected.
title = sphinx.addnodes.desc_signature(txb_name, '')
title['ids'].append(txb_name)
title['ids'].append(txb_id)
title['names'].append(txb_name)
title['first'] = False
title['objtype'] = 'directive'
self.add_name(title)
title['classes'].append('directive-title')
# Finally, add a desc_name() node to display the name of the
# configuration variable.
title += sphinx.addnodes.desc_name(txb_name, txb_name)
node.append(title)
if ('class' in self.options):
title['classes'].append(self.options.get('class'))
# This has to be a distinct node before the title. if nested then the browser will scroll forward to just past the title.
anchor = nodes.target('', '', names=[txb_name])
# Second (optional) arg is 'msgNode' - no idea what I should pass for that
# or if it even matters, although I now think it should not be used.
self.state.document.note_explicit_target(title)
env.domaindata['txb']['directive'][txb_name] = env.docname
fl = nodes.field_list()
if ('keys' in self.options):
key_field = nodes.field()
key_field.append(nodes.field_name(text='Secondary Keys'))
key_value = nodes.field_list()
key_body = nodes.field_body()
key_body.append(key_value)
key_field.append(key_body)
key_list = self.options['keys'].split('|')
for key in key_list:
tag = key
descr = ''
if ':' in key:
(tag, descr) = key.split(':')
tag = tag.strip()
descr = descr.strip()
key_value.append(self.make_field(tag, descr))
fl.append(key_field)
if ('arg' in self.options):
fl.append(self.make_field('Argument', self.options['arg']))
if ('value' in self.options):
fl.append(self.make_field('Value', self.options['value']))
# Get any contained content
nn = nodes.compound()
self.state.nested_parse(self.content, self.content_offset, nn)
# Create an index node so that Sphinx adds this directive to the index.
indexnode = sphinx.addnodes.index(entries=[])
indexnode['entries'].append(('single', _('%s') % txb_name, txb_id, '', ''))
return [indexnode, node, fl, nn]