字段说明测试
This commit is contained in:
@@ -22,38 +22,32 @@ def truncate_text(text: str, max_length: int = MAX_MD_LENGTH) -> str:
|
||||
return text[:max_length] + "\n\n<font color=\"comment\">... 消息过长,已截断</font>"
|
||||
|
||||
|
||||
def _format_param_table(changes: List) -> List[str]:
|
||||
"""按 model.md 生成参数变更 Markdown 表格。"""
|
||||
def _format_param_change_list(changes: List) -> List[str]:
|
||||
"""生成企微友好的参数变更列表(卡片式)。"""
|
||||
if not changes:
|
||||
return ['<font color="comment">无</font>']
|
||||
lines = [
|
||||
"",
|
||||
"| 字段 | 说明 | 变更 |",
|
||||
"|------|------|------|",
|
||||
]
|
||||
for change in changes:
|
||||
lines.append(change.to_table_row())
|
||||
lines = ["", f"共 **{len(changes)}** 项变更", ""]
|
||||
for i, change in enumerate(changes, 1):
|
||||
lines.append(change.to_markdown_block(i))
|
||||
if i < len(changes):
|
||||
lines.append("")
|
||||
return lines
|
||||
|
||||
|
||||
def _format_param_details_section(report: EndpointChangeReport) -> List[str]:
|
||||
"""生成接口参数变动详情区块(对齐 model.md)。"""
|
||||
"""生成接口参数变动详情区块。"""
|
||||
body_changes = [c for c in report.parameter_changes if c.source == "body"]
|
||||
regular_changes = [c for c in report.parameter_changes if c.source != "body"]
|
||||
lines = ["", "---", "", "## 接口参数变动详情", "", "---", ""]
|
||||
lines = ["", "---------------------------------------", "", "#### 【接口参数变动详情】", ""]
|
||||
|
||||
if body_changes:
|
||||
lines.append("### 类对象变更")
|
||||
lines.append("")
|
||||
lines.append("- **参数变更列表:**")
|
||||
lines.extend(_format_param_table(body_changes))
|
||||
lines.append("**类对象变更**")
|
||||
lines.extend(_format_param_change_list(body_changes))
|
||||
lines.append("")
|
||||
|
||||
if regular_changes:
|
||||
lines.append("### 普通参数变更(非对象字段)")
|
||||
lines.append("")
|
||||
lines.append("- **参数变更列表:**")
|
||||
lines.extend(_format_param_table(regular_changes))
|
||||
lines.append("**普通参数变更**")
|
||||
lines.extend(_format_param_change_list(regular_changes))
|
||||
lines.append("")
|
||||
|
||||
if not body_changes and not regular_changes:
|
||||
|
||||
Reference in New Issue
Block a user