autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
51 lines (50 loc) • 3.13 kB
TypeScript
/**
* WikiRenderers.js — Wiki 文档渲染函数
*
* 从 WikiGenerator.js 中提取的 Markdown 渲染器和 AI Prompt 构建函数。
* 所有函数均为无状态纯函数(不依赖 class 实例)。
*
* 类型定义已提取到 WikiTypes.ts,供多文件共享使用。
*
* @module WikiRenderers
*/
import type { WikiAstInfo, WikiCodeEntityGraph, WikiData, WikiFolderProfile, WikiKnowledgeInfo, WikiModuleInfo, WikiProjectInfo, WikiRecipeJson, WikiTarget, WikiTopic } from './WikiTypes.js';
export type { WikiData } from './WikiTypes.js';
/**
* 为特定主题构建 AI 撰写 prompt (V3 AI-first 核心)
*
* 关键区别: 不是润色骨架,而是提供丰富数据让 AI 写完整文章
*
* @param data { projectInfo, astInfo, moduleInfo, knowledgeInfo }
*/
export declare function buildArticlePrompt(topic: WikiTopic, data: WikiData, isZh: boolean, codeEntityGraph: WikiCodeEntityGraph | null): string;
/**
* 构建非 AI 降级的丰富模板内容
* 即使没有 AI,也要产出有意义的内容 (不是只有列表罗列)
*
* @param data { projectInfo, astInfo, moduleInfo, knowledgeInfo }
*/
export declare function buildFallbackArticle(topic: WikiTopic, data: WikiData, isZh: boolean, codeEntityGraph: WikiCodeEntityGraph | null): string;
/** 渲染项目概述页 (index.md) */
export declare function renderIndex(project: WikiProjectInfo, ast: WikiAstInfo, modules: WikiModuleInfo, knowledge: WikiKnowledgeInfo, isZh: boolean, allTopics: WikiTopic[]): string;
/** 渲染架构总览文档 (architecture.md) */
export declare function renderArchitecture(project: WikiProjectInfo, ast: WikiAstInfo, modules: WikiModuleInfo, isZh: boolean, codeEntityGraph: WikiCodeEntityGraph | null): string;
/** 渲染模块详情文档 (modules/{name}.md) */
export declare function renderModule(target: WikiTarget, ast: WikiAstInfo, knowledge: WikiKnowledgeInfo, isZh: boolean, projectInfo: WikiProjectInfo): string;
/** 渲染代码模式文档 (patterns.md) */
export declare function renderPatterns(knowledge: WikiKnowledgeInfo, isZh: boolean): string;
/** 快速上手指南 (非 AI 降级模板) */
export declare function renderGettingStarted(project: WikiProjectInfo, modules: WikiModuleInfo, ast: WikiAstInfo, isZh: boolean): string;
/** 按分类拆分的代码模式文档 */
export declare function renderPatternCategory(patternData: {
category: string;
recipes: WikiRecipeJson[];
}, isZh: boolean): string;
/** 协议参考文档 */
export declare function renderProtocolReference(ast: WikiAstInfo, isZh: boolean, projectInfo: WikiProjectInfo): string;
/** 渲染文件夹结构总览 (folder-structure.md) */
export declare function renderFolderOverview(profiles: WikiFolderProfile[], projectInfo: WikiProjectInfo, isZh: boolean): string;
/** 渲染单个文件夹的深度画像文档 (folders/{name}.md) */
export declare function renderFolderProfile(fp: WikiFolderProfile, projectInfo: WikiProjectInfo, isZh: boolean): string;
/** 构建 AI 系统 Prompt (V3 — 撰写完整文章,非润色骨架) */
export declare function buildAiSystemPrompt(isZh: boolean): string;