Get the real line number or admit we don't know.
(node: Node)
| 398 | |
| 399 | @staticmethod |
| 400 | def get_line_number(node: Node) -> int | None: |
| 401 | """Get the real line number or admit we don't know.""" |
| 402 | # TODO: Work out how to store or calculate real (file-relative) |
| 403 | # line numbers for doctest blocks in docstrings. |
| 404 | if ':docstring of ' in os.path.basename(node.source or ''): |
| 405 | # The line number is given relative to the stripped docstring, |
| 406 | # not the file. This is correct where it is set, in |
| 407 | # `docutils.nodes.Node.setup_child`, but Sphinx should report |
| 408 | # relative to the file, not the docstring. |
| 409 | return None |
| 410 | if node.line is not None: |
| 411 | # TODO: find the root cause of this off by one error. |
| 412 | return node.line - 1 |
| 413 | return None |
| 414 | |
| 415 | def skipped(self, node: Element) -> bool: |
| 416 | if 'skipif' not in node: |