Skip to content

Commit

Permalink
MNT Fix incorrect source code link for wrapped objects (scikit-learn#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alfaro96 authored May 17, 2020
1 parent 0db5f36 commit 0ba19ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/sphinxext/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
return

class_name = info['fullname'].split('.')[0]
if type(class_name) != str:
# Python 2 only
class_name = class_name.encode('utf-8')
module = __import__(info['module'], fromlist=[class_name])
obj = attrgetter(info['fullname'])(module)

# Unwrap the object to get the correct source
# file in case that is wrapped by a decorator
obj = inspect.unwrap(obj)

try:
fn = inspect.getsourcefile(obj)
except Exception:
Expand Down

0 comments on commit 0ba19ad

Please sign in to comment.