Skip to content

Commit

Permalink
Docs: Fix link to source for class properties
Browse files Browse the repository at this point in the history
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
  • Loading branch information
peace-maker committed Dec 9, 2024
1 parent ec262d8 commit 24d217c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 24d217c

Please sign in to comment.