(self)
| 238 | default_priority = 800 |
| 239 | |
| 240 | def apply(self): |
| 241 | methods = ( |
| 242 | sig for sig in self.document.traverse(SphinxNodes.desc_signature) |
| 243 | if "class" in sig |
| 244 | ) |
| 245 | |
| 246 | # Extra data for replace functions |
| 247 | details = {} |
| 248 | |
| 249 | for ref in methods: |
| 250 | name_node = ref.next_node(SphinxNodes.desc_name) |
| 251 | name = name_node.astext() |
| 252 | |
| 253 | # Determine the class to associate with this method, so we can |
| 254 | # swap __init__ with a named constructor. |
| 255 | annotation_node = ref.next_node(SphinxNodes.desc_annotation) |
| 256 | if annotation_node: |
| 257 | annotation = annotation_node.astext().strip() |
| 258 | if annotation == "class": |
| 259 | details["class_name"] = name |
| 260 | |
| 261 | parameters_node = ref.next_node(SphinxNodes.desc_parameterlist) |
| 262 | |
| 263 | # Transform special methods |
| 264 | if name in SPECIAL_METHODS: |
| 265 | name_node.replace_self( |
| 266 | SPECIAL_METHODS[name](name_node, parameters_node, details) |
| 267 | ) |
| 268 | parameters_node.replace_self(()) |
| 269 | |
| 270 | # Remove 'self' parameter from other methods |
| 271 | elif is_method(parameters_node): |
| 272 | parameters_node.replace_self(patch_node(parameters_node, "")) |
| 273 | |
| 274 | |
| 275 | def setup(app): |
nothing calls this directly
no test coverage detected