include_vars.py 文件源码

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

项目:xrally-docs 作者: xrally 项目源码 文件源码
def include_var(name, rawtext, text, lineno, inliner, options=None,
                content=None):
    """include variable

    :param name: The local name of the interpreted role, the role name
                 actually used in the document.
    :param rawtext: A string containing the enitre interpreted text input,
                    including the role and markup. Return it as a problematic
                    node linked to a system message if a problem is
                    encountered.
    :param text: The interpreted text content.
    :param lineno: The line number where the interpreted text begins.
    :param inliner: The docutils.parsers.rst.states.Inliner object that
                    called include_var. It contains the several attributes
                    useful for error reporting and document tree access.
    :param options: A dictionary of directive options for customization
                    (from the 'role' directive), to be interpreted by the
                    role function. Used for additional attributes for the
                    generated elements and other functionality.
    :param content: A list of strings, the directive content for
                    customization (from the 'role' directive). To be
                    interpreted by the role function.
    :return:
    """
    obj = importutils.import_class(text)
    if isinstance(obj, (tuple, list)):
        obj = ", ".join(obj)
    elif isinstance(obj, dict):
        obj = json.dumps(dict, indent=4)
    else:
        obj = str(obj)
    return [nodes.Text(obj)], []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号