api-docs.ts - API 文档数据

api-docs.ts - API 文档数据

概述

自动生成并供 IDE 侧边栏使用的 API 文档数据。包含 prompts.chat SDK 的所有类型和方法文档。

⚠️ 注意: 此文件为自动生成,请勿手动编辑。运行 npm run docs:generate 重新生成。

数据结构

ApiSection

interface ApiSection {
  name: string;      // 分组名称
  items: ApiItem[];  // API 项目列表
}

ApiItem

interface ApiItem {
  name: string;       // 名称
  type: "function" | "class" | "type" | "interface" | "const" | "method";
  signature?: string; // 签名
  description?: string; // 描述
  example?: string;   // 示例代码
  returns?: string;   // 返回类型
  params?: {          // 参数
    name: string;
    type: string;
    description?: string;
  }[];
}

文档分组

Text Prompts

文本提示词构建器的所有方法和类型。

主要包含:

  • 构造器: builder(), fromPrompt()
  • 链式方法: .role(), .context(), .task(), .constraints(), .output(), .example()
  • 构建方法: .build(), .toString()
  • 预设模板: templates.codeReview(), templates.translation(), templates.summarize()

Chat Prompts

对话式提示词构建器的所有方法和类型。

主要包含:

  • 构造器: chat()
  • 消息方法: .system(), .user(), .assistant(), .messages()
  • 角色设置: .persona(), .role(), .tone(), .expertise()
  • 上下文: .context(), .domain(), .audience()
  • 任务设置: .task(), .steps(), .criteria()
  • 输出格式: .json(), .markdown(), .code(), .table()
  • 推理设置: .reasoning(), .stepByStep(), .chainOfThought()

使用方式

此数据主要用于 IDE 插件和侧边栏文档展示:

import { API_DOCS } from '@/data/api-docs';

// 查找特定方法
const textSection = API_DOCS.find(s => s.name === "Text Prompts");
const builderMethod = textSection?.items.find(i => i.name === "builder()");

console.log(builderMethod?.signature);     // "builder(): PromptBuilder"
console.log(builderMethod?.description);   // "Create a new prompt builder"
console.log(builderMethod?.returns);       // "PromptBuilder"

模板列表

代码相关

  • templates.codeReview() - 代码审查
  • templates.debug() - 调试
  • templates.refactor() - 重构
  • templates.unitTest() - 单元测试
  • templates.apiDocs() - API 文档
  • templates.commitMessage() - 提交信息
  • templates.reviewComment() - 审查评论
  • templates.regex() - 正则表达式
  • templates.sql() - SQL 查询

内容相关

  • templates.translation() - 翻译
  • templates.summarize() - 摘要
  • templates.write() - 写作
  • templates.explain() - 解释说明
  • templates.brainstorm() - 头脑风暴
  • templates.extract() - 数据提取

问答相关

  • templates.qa() - 问答

生成流程

文档通过 TypeScript AST 解析自动生成:

  1. 扫描 SDK 源文件
  2. 提取 JSDoc 注释和类型信息
  3. 生成结构化的 API 文档数据
  4. 输出到本文件

开发者不应手动修改此文件,应在源代码中添加 JSDoc 注释,然后重新生成。

← 返回目录