Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import os
import re
import inspect
from pandas.compat import u, PY3

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -47,6 +48,7 @@
'sphinx.ext.coverage',
'sphinx.ext.pngmath',
'sphinx.ext.ifconfig',
'sphinx.ext.linkcode',
]


Expand Down Expand Up @@ -424,6 +426,55 @@ def get_items(self, names):
return items


# based on numpy doc/source/conf.py
def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
if domain != 'py':
return None

modname = info['module']
fullname = info['fullname']

submod = sys.modules.get(modname)
if submod is None:
return None

obj = submod
for part in fullname.split('.'):
try:
obj = getattr(obj, part)
except:
return None

try:
fn = inspect.getsourcefile(obj)
except:
fn = None
if not fn:
return None

try:
source, lineno = inspect.getsourcelines(obj)
except:
lineno = None

if lineno:
linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
else:
linespec = ""

fn = os.path.relpath(fn, start=os.path.dirname(pandas.__file__))

if '+' in pandas.__version__:
return "http://github.com/pydata/pandas/blob/master/pandas/%s%s" % (
fn, linespec)
else:
return "http://github.com/pydata/pandas/blob/v%s/pandas/%s%s" % (
pandas.__version__, fn, linespec)


# remove the docstring of the flags attribute (inherited from numpy ndarray)
# because these give doc build errors (see GH issue 5331)
def remove_flags_docstring(app, what, name, obj, options, lines):
Expand Down