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

Method get_filename_for_node

sphinx/ext/doctest.py:389–397  ·  view source on GitHub ↗

Try to get the file which actually contains the doctest, not the filename of the document it's included in.

(self, node: Node, docname: str)

Source from the content-addressed store, hash-verified

387 break
388
389 def get_filename_for_node(self, node: Node, docname: str) -> str:
390 """Try to get the file which actually contains the doctest, not the
391 filename of the document it's included in.
392 """
393 try:
394 filename = relpath(node.source, self.env.srcdir) # type: ignore[arg-type]
395 return filename.partition(':docstring of ')[0]
396 except Exception:
397 return str(self.env.doc2path(docname, False))
398
399 @staticmethod
400 def get_line_number(node: Node) -> int | None:

Callers 1

test_docMethod · 0.95

Calls 2

relpathFunction · 0.90
doc2pathMethod · 0.45

Tested by

no test coverage detected