38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""routers/docgen.py 的 P3 增量补丁(A3 草稿,交 TL 审后合入)。
|
||
|
||
零改动既有路径:只在 get_artifact_html 的 template_name=='bioflow_report'
|
||
时增量分支到 services/docgen/templating_bioflow.py(改动点 2 处:
|
||
1. 文件头 import;2. get_artifact_html 内插入分支)。红线校验:
|
||
templating.py 既有函数零改动(bioflow 逻辑全在新模块)。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
|
||
# ---- 改动点 1:import(docgen.py 顶部新增一行) ----
|
||
IMPORT_LINE = "from ..services.docgen.templating_bioflow import BIOFLOW_TEMPLATE_NAME, render_bioflow_report # P3 A3 增量"
|
||
|
||
# ---- 改动点 2:get_artifact_html 分支(替换现有 render_html 调用处) ----
|
||
# 现有代码(保持不变):
|
||
# key = str(row.get("template_key") or "")
|
||
# frozen_css = str(row.get("template_css") or "")
|
||
# letterhead = str(row.get("letterhead") or "")
|
||
# html, rendered_css = render_html(
|
||
# markdown, title=title, key=key, letterhead=letterhead
|
||
# )
|
||
# 增量分支(插在 render_html 调用之前):
|
||
BRANCH_CODE = ''' template_name = str(row.get("template_name") or "")
|
||
if template_name == BIOFLOW_TEMPLATE_NAME:
|
||
html, rendered_css = render_bioflow_report(
|
||
markdown, title=title, letterhead=letterhead
|
||
)
|
||
else:
|
||
html, rendered_css = render_html(
|
||
markdown, title=title, key=key, letterhead=letterhead
|
||
)'''
|
||
|
||
# 说明:fig:// 引用渲染器(services/docgen/templating_bioflow.resolve_fig_refs)
|
||
# 由 get_artifact_html 渲染链路自然执行(报告 HTML 现渲染时替换)。
|
||
# DocPane 复用零改造(P3 目标):前端预览走同一 /html 端点,白底预览。
|