| 73 | |
| 74 | # External entry point |
| 75 | def run(self): |
| 76 | env = self.state.document.settings.env |
| 77 | txb_name = self.arguments[0] |
| 78 | txb_id = nodes.make_id(txb_name) |
| 79 | |
| 80 | # First, make a generic desc() node to be the parent. |
| 81 | node = sphinx.addnodes.desc() |
| 82 | node.document = self.state.document |
| 83 | node['objtype'] = 'directive' |
| 84 | |
| 85 | # Next, make a signature node. This creates a permalink and a highlighted background when the link is selected. |
| 86 | title = sphinx.addnodes.desc_signature(txb_name, '') |
| 87 | title['ids'].append(txb_name) |
| 88 | title['ids'].append(txb_id) |
| 89 | title['names'].append(txb_name) |
| 90 | title['first'] = False |
| 91 | title['objtype'] = 'directive' |
| 92 | self.add_name(title) |
| 93 | title['classes'].append('directive-title') |
| 94 | |
| 95 | # Finally, add a desc_name() node to display the name of the |
| 96 | # configuration variable. |
| 97 | title += sphinx.addnodes.desc_name(txb_name, txb_name) |
| 98 | |
| 99 | node.append(title) |
| 100 | if ('class' in self.options): |
| 101 | title['classes'].append(self.options.get('class')) |
| 102 | |
| 103 | # This has to be a distinct node before the title. if nested then the browser will scroll forward to just past the title. |
| 104 | anchor = nodes.target('', '', names=[txb_name]) |
| 105 | # Second (optional) arg is 'msgNode' - no idea what I should pass for that |
| 106 | # or if it even matters, although I now think it should not be used. |
| 107 | self.state.document.note_explicit_target(title) |
| 108 | env.domaindata['txb']['directive'][txb_name] = env.docname |
| 109 | |
| 110 | fl = nodes.field_list() |
| 111 | if ('keys' in self.options): |
| 112 | key_field = nodes.field() |
| 113 | key_field.append(nodes.field_name(text='Secondary Keys')) |
| 114 | key_value = nodes.field_list() |
| 115 | key_body = nodes.field_body() |
| 116 | key_body.append(key_value) |
| 117 | key_field.append(key_body) |
| 118 | key_list = self.options['keys'].split('|') |
| 119 | for key in key_list: |
| 120 | tag = key |
| 121 | descr = '' |
| 122 | if ':' in key: |
| 123 | (tag, descr) = key.split(':') |
| 124 | tag = tag.strip() |
| 125 | descr = descr.strip() |
| 126 | key_value.append(self.make_field(tag, descr)) |
| 127 | fl.append(key_field) |
| 128 | if ('arg' in self.options): |
| 129 | fl.append(self.make_field('Argument', self.options['arg'])) |
| 130 | if ('value' in self.options): |
| 131 | fl.append(self.make_field('Value', self.options['value'])) |
| 132 | |