MCPcopy Index your code
hub / github.com/numpy/numpy / linkcode_resolve

Function linkcode_resolve

doc/source/conf.py:523–597  ·  view source on GitHub ↗

Determine the URL corresponding to Python object

(domain, info)

Source from the content-addressed store, hash-verified

521 return None
522
523def linkcode_resolve(domain, info):
524 """
525 Determine the URL corresponding to Python object
526 """
527 if domain != 'py':
528 return None
529
530 modname = info['module']
531 fullname = info['fullname']
532
533 submod = sys.modules.get(modname)
534 if submod is None:
535 return None
536
537 obj = submod
538 for part in fullname.split('.'):
539 try:
540 obj = getattr(obj, part)
541 except Exception:
542 return None
543
544 # strip decorators, which would resolve to the source of the decorator
545 # possibly an upstream bug in getsourcefile, bpo-1764286
546 try:
547 unwrap = inspect.unwrap
548 except AttributeError:
549 pass
550 else:
551 obj = unwrap(obj)
552
553 fn = None
554 lineno = None
555
556 if isinstance(obj, type):
557 # Make a poor effort at linking C extension types
558 if obj.__module__ == 'numpy':
559 fn = _get_c_source_file(obj)
560
561 # This can be removed when removing the decorator set_module. Fix issue #28629
562 if hasattr(obj, '_module_source'):
563 obj.__module__, obj._module_source = obj._module_source, obj.__module__
564
565 if fn is None:
566 try:
567 fn = inspect.getsourcefile(obj)
568 except Exception:
569 fn = None
570 if not fn:
571 return None
572
573 # Ignore re-exports as their source files are not within the numpy repo
574 module = inspect.getmodule(obj)
575 if module is not None and not module.__name__.startswith("numpy"):
576 return None
577
578 try:
579 source, lineno = inspect.getsourcelines(obj)
580 except Exception:

Callers

nothing calls this directly

Calls 5

unwrapFunction · 0.85
_get_c_source_fileFunction · 0.85
splitMethod · 0.80
startswithMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…