plantuml.py 文件源码

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

项目:foliant 作者: foliant-docs 项目源码 文件源码
def process_diagram(caption, body, src_dir, diag_dir_name, diag_id):
    """Save diagram body to .diag file, draw PNG from it with plantuml,
    and return the image ref."""

    diag_src_path = join(src_dir, diag_dir_name, SUBDIR_NAME, "%s.diag" % diag_id)

    with open(diag_src_path, 'w', encoding="utf8") as diag_src:
        diag_src.write(body)

    try:
        subprocess.check_output(
            "%s %s" % (PLANTUML_COMMAND, diag_src_path),
            stderr=subprocess.PIPE,
            shell=True
        )
    except subprocess.CalledProcessError as exception:
        print(
            Fore.YELLOW + "\nWarning: Processing of diagram %s failed: %s"
            % (diag_src_path, exception)
        )

    return "![%s](%s/%s/%s.png)" % (caption, diag_dir_name, SUBDIR_NAME, diag_id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号