conf.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:yadll 作者: pchavanne 项目源码 文件源码
def linkcode_resolve(domain, info):
    def find_source():
        # try to find the file and line number, based on code from numpy:
        # https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
        obj = sys.modules[info['module']]
        for part in info['fullname'].split('.'):
            obj = getattr(obj, part)
        import inspect
        import os
        fn = inspect.getsourcefile(obj)
        fn = os.path.relpath(fn, start=os.path.dirname(yadll.__file__))
        source, lineno = inspect.getsourcelines(obj)
        return fn, lineno, lineno + len(source) - 1

    if domain != 'py' or not info['module']:
        return None
    try:
        filename = 'yadll/%s#L%d-L%d' % find_source()
    except Exception:
        filename = info['module'].replace('.', '/') + '.py'
    tag = 'master' if 'dev' in release else ('v' + release)
    return "https://github.com/yadll/yadll/blob/%s/%s" % (tag, filename)

# -- Options for HTML output ----------------------------------------------
# Read the docs style:
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号