in doc/ext/traffic-server.py [0:0]
def run(self):
env = self.state.document.settings.env
cv_default = None
cv_scope, cv_name, cv_type = self.arguments[0:3]
if (len(self.arguments) > 3):
cv_default = self.arguments[3]
# First, make a generic desc() node to be the parent.
node = sphinx.addnodes.desc()
node.document = self.state.document
node['objtype'] = 'cv'
# Next, make a signature node. This creates a permalink and a
# highlighted background when the link is selected.
title = sphinx.addnodes.desc_signature(cv_name, '')
title['ids'].append(nodes.make_id(cv_name))
title['ids'].append(cv_name)
title['names'].append(cv_name)
title['first'] = False
title['objtype'] = 'cv'
self.add_name(title)
title['classes'].append('ts-cv-title')
# Finally, add a desc_name() node to display the name of the
# configuration variable.
title += sphinx.addnodes.desc_name(cv_name, cv_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.
nodes.target('', '', names=[cv_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['ts']['cv'][cv_name] = env.docname
fl = nodes.field_list()
fl.append(self.make_field('Scope', cv_scope))
fl.append(self.make_field('Type', cv_type))
if (cv_default):
fl.append(self.make_field('Default', cv_default))
else:
fl.append(self.make_field('Default', sphinx.addnodes.literal_emphasis(text='*NONE*')))
if ('units' in self.options):
fl.append(self.make_field('Units', self.options['units']))
if ('reloadable' in self.options):
fl.append(self.make_field('Reloadable', 'Yes'))
if ('overridable' in self.options):
fl.append(self.make_field('Overridable', 'Yes'))
if ('deprecated' in self.options):
fl.append(self.make_field('Deprecated', 'Yes'))
# add yaml rep if record is not legacy.
code_block = None
code_block_title = None
if 'legacy' not in self.options:
code_block = self.__generate_code(cv_name, cv_default, cv_type)
code_block_title = sphinx.addnodes.compact_paragraph(text="yaml:")
self.add_name(code_block_title)
self.add_name(code_block)
# 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 config variable to the
# index. nodes.make_id() specifies the link anchor name that is
# implicitly generated by the anchor node above.
indexnode = sphinx.addnodes.index(entries=[])
if sphinx.version_info >= (1, 4):
indexnode['entries'].append(
('single', _('%s') % cv_name, nodes.make_id(cv_name), '', '')
)
else:
indexnode['entries'].append(
('single', _('%s') % cv_name, nodes.make_id(cv_name), '')
)
if code_block is None:
return [indexnode, node, fl, nn]
else:
return [indexnode, node, fl, code_block_title, code_block, nn]