(domain, info)
| 61 | |
| 62 | # Try to link to source code on GitHub |
| 63 | def linkcode_resolve(domain, info): |
| 64 | if domain != "py": |
| 65 | return None |
| 66 | |
| 67 | module = info.get("module", None) |
| 68 | fullname = info.get("fullname", None) |
| 69 | |
| 70 | if not module or not fullname: |
| 71 | return None |
| 72 | |
| 73 | obj = sys.modules.get(module, None) |
| 74 | if obj is None: |
| 75 | return None |
| 76 | |
| 77 | for part in fullname.split("."): |
| 78 | obj = getattr(obj, part) |
| 79 | if isinstance(obj, property): |
| 80 | obj = obj.fget |
| 81 | |
| 82 | try: |
| 83 | file = inspect.getsourcefile(obj) |
| 84 | if file is None: |
| 85 | return None |
| 86 | except: |
| 87 | return None |
| 88 | |
| 89 | file = os.path.relpath(file, start=os.path.abspath("..")) |
| 90 | source, line_start = inspect.getsourcelines(obj) |
| 91 | line_end = line_start + len(source) - 1 |
| 92 | filename = f"{file}#L{line_start}-L{line_end}" |
| 93 | return f"{gh_url}/blob/master/{filename}" |
| 94 | |
| 95 | |
| 96 | # Napoleon settings |
nothing calls this directly
no outgoing calls
no test coverage detected