Skip to content

Commit

Permalink
DOC: Sync sphinxext with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ghisvail committed Aug 10, 2023
1 parent 35fdb34 commit cdb239a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions docs/sphinxext/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
This script comes from scikit-learn:
https://github.com/scikit-learn/scikit-learn/blob/master/doc/sphinxext/github_link.py
"""
from operator import attrgetter
import inspect
import subprocess
import os
import subprocess
import sys
from functools import partial
from operator import attrgetter

REVISION_CMD = "git rev-parse --short HEAD"

Expand Down Expand Up @@ -44,14 +44,12 @@ 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])
try:
obj = attrgetter(info["fullname"])(module)
except AttributeError:
return
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)
Expand Down

0 comments on commit cdb239a

Please sign in to comment.