MCPcopy
hub / github.com/sphinx-doc/sphinx / get_line_number

Method get_line_number

sphinx/ext/doctest.py:400–413  ·  view source on GitHub ↗

Get the real line number or admit we don't know.

(node: Node)

Source from the content-addressed store, hash-verified

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:

Callers 1

test_docMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected