in doc/ext/traffic-server.cmake.in.py [0:0]
def run(self):
env = self.state.document.settings.env
stat_example = None
stat_group, stat_name, stat_type = self.arguments[0:3]
if (len(self.arguments) > 3):
stat_example = self.arguments[3]
# First, make a generic desc() node to be the parent.
node = sphinx.addnodes.desc()
node.document = self.state.document
node['objtype'] = 'stat'
# Next, make a signature node. This creates a permalink and a
# highlighted background when the link is selected.
title = sphinx.addnodes.desc_signature(stat_name, '')
title['ids'].append(nodes.make_id('stat-' + stat_name))
title['names'].append(stat_name)
title['first'] = False
title['objtype'] = 'stat'
self.add_name(title)
title['classes'].append('ts-stat-title')
# Finally, add a desc_name() node to display the name of the
# configuration variable.
title += sphinx.addnodes.desc_name(stat_name, stat_name)
node.append(title)
# 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=[stat_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']['stat'][stat_name] = env.docname
fl = nodes.field_list()
fl.append(self.make_field('Collection', stat_group))
if ('type' in self.options):
fl.append(self.make_field('Type', self.options['type']))
if ('units' in self.options):
fl.append(self.make_field('Units', self.options['units']))
fl.append(self.make_field('Datatype', stat_type))
if ('introduced' in self.options and len(self.options['introduced']) > 0):
fl.append(self.make_field('Introduced', self.options['introduced']))
if ('deprecated' in self.options):
if (len(self.options['deprecated']) > 0):
fl.append(self.make_field('Deprecated', self.options['deprecated']))
else:
fl.append(self.make_field('Deprecated', 'Yes'))
if ('ungathered' in self.options):
fl.append(self.make_field('Gathered', 'No'))
if (stat_example):
fl.append(self.make_field('Example', stat_example))
# 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 statistic 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') % stat_name, nodes.make_id(stat_name), '', '')
)
else:
indexnode['entries'].append(
('single', _('%s') % stat_name, nodes.make_id(stat_name), '')
)
return [indexnode, node, fl, nn]