| 183 | optional_arguments = 1 |
| 184 | |
| 185 | def run(self): |
| 186 | try: |
| 187 | obj = self.arguments[0] |
| 188 | except IndexError: |
| 189 | # Argument is empty; use default text |
| 190 | obj = "submodule" |
| 191 | text = (f"This {obj} is considered legacy and will no longer receive " |
| 192 | "updates. This could also mean it will be removed in future " |
| 193 | "NumPy versions.") |
| 194 | |
| 195 | try: |
| 196 | self.content[0] = text + " " + self.content[0] |
| 197 | except IndexError: |
| 198 | # Content is empty; use the default text |
| 199 | source, lineno = self.state_machine.get_source_and_line( |
| 200 | self.lineno |
| 201 | ) |
| 202 | self.content.append( |
| 203 | text, |
| 204 | source=source, |
| 205 | offset=lineno |
| 206 | ) |
| 207 | text = '\n'.join(self.content) |
| 208 | # Create the admonition node, to be populated by `nested_parse` |
| 209 | admonition_node = self.node_class(rawsource=text) |
| 210 | # Set custom title |
| 211 | title_text = "Legacy" |
| 212 | textnodes, _ = self.state.inline_text(title_text, self.lineno) |
| 213 | title = nodes.title(title_text, '', *textnodes) |
| 214 | # Set up admonition node |
| 215 | admonition_node += title |
| 216 | # Select custom class for CSS styling |
| 217 | admonition_node['classes'] = ['admonition-legacy'] |
| 218 | # Parse the directive contents |
| 219 | self.state.nested_parse(self.content, self.content_offset, |
| 220 | admonition_node) |
| 221 | return [admonition_node] |
| 222 | |
| 223 | |
| 224 | def setup(app): |