From 24d217cfbdc9efc0ac0c29d1ce792b3b87603a07 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Mon, 9 Dec 2024 13:09:10 +0100 Subject: [PATCH] Docs: Fix link to source for class properties The property has setters and getters. Link to the getter if it's available. This adds line numbers to the source link for properties. Fixes #2401 --- docs/source/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6d72a01af..d908e2436 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -360,6 +360,9 @@ def linkcode_resolve(domain, info): else: filename = info['module'].replace('.', '/') + '.py' + if isinstance(val, property): + val = val.fget + if isinstance(val, (types.ModuleType, types.MethodType, types.FunctionType, types.TracebackType, types.FrameType, types.CodeType) + six.class_types): try: lines, first = inspect.getsourcelines(val)