autodoc.py 文件源码

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

项目:tefla 作者: openAGI 项目源码 文件源码
def get_src_path(obj, src_root='tefla', append_base=True):
    """Creates a src path string with line info for use as markdown link.
    """
    path = getsourcefile(obj)
    if not src_root in path:
        # this can happen with e.g.
        # inlinefunc-wrapped functions
        if hasattr(obj, "__module__"):
            path = "%s.%s" % (obj.__module__, obj.__name__)
        else:
            path = obj.__name__
        path = path.replace(".", "/")
    try:
        pre, post = path.rsplit(src_root + "/", 1)
    except:
        pre, post = '', ''

    lineno = get_line_no(obj)
    lineno = "" if lineno is None else "#L{}".format(lineno)

    path = src_root + "/" + post + lineno
    if append_base:
        path = os.path.join(
            'https://github.com/openagi/tefla/blob/master', path)
    return path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号