> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 自动从 Linear 生成 API 文档

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="从 Linear 自动生成 API 文档" description="创建一个文档 Playbook，将其同步为 Linear 标签，让团队中任何人只需给工单打上该标签就能触发文档生成。" prompt="创建一个名为 !add-docs 的 Playbook，用于根据 Linear 工单中描述的端点生成相应的 API 文档，并遵循我们的文档规范。" category="项目管理" features="集成、Playbook" devinUrl="https://app.devin.ai/settings/connections/linear" />

<div className="uc-detail-wrapper">
  <Tip>不想手动设置？将此页面的链接粘贴到 Devin 会话中，并让它为你完成所有设置。</Tip>

  <Steps>
    <Step title="编写文档指南">
      首先为你想标准化的任务创建一个[运行手册](/zh/product-guides/creating-playbooks)。在本例中，我们将构建一个运行手册，当团队成员为工单添加特定标签时自动生成 API 文档。

      前往 [**Settings > Playbooks**](https://app.devin.ai/settings/playbooks?utm_source=docs\&utm_medium=use-case-gallery) 并点击 **Create playbook**。为其命名并设置一个宏命令 (例如 `!add-docs`) 。

      编写明确的、分步骤的指令。引用真实的文件路径和约定，以便 Devin 遵循你团队的标准：

      <PromptBlock type="playbook">
        ```txt !add-docs playbook theme={null}
        阅读 Linear 工单，了解该功能或端点的上下文。然后：

        1. 找到相关源代码 —— 路由处理器、控制器、
           模型和类型定义
        2. 阅读 docs/api/ 中的现有文档，了解我们使用的
           格式和约定
        3. 生成文档，涵盖：端点 URL、HTTP 方法、
           请求/响应结构（schema）、身份验证要求、错误
           代码，以及一个使用 curl 的示例
        4. 将新页面添加到 docs/sidebar.json 中的文档侧边栏
        5. 如果有相关端点，添加交叉引用
        6. 为新文档打开一个 PR
        ```
      </PromptBlock>

      你的运行手册越具体，输出效果就越好。引用你团队实际使用的文档模板、风格指南和工具。参见[运行手册文档](/zh/product-guides/creating-playbooks)了解更多编写高效运行手册的说明。
    </Step>

    <Step title="将 Playbook 同步到 Linear">
      如果你尚未连接 [Linear 集成](/zh/integrations/linear)：前往 [**Settings > Connections > Linear**](https://app.devin.ai/settings/connections/linear?utm_source=docs\&utm_medium=use-case-gallery) 并点击 **Connect**。选择 Devin 需要访问的团队。

      连接完成后，向下滚动到 **Synced playbook labels** 并点击 **Add playbook**。从下拉菜单中选择 `!add-docs`。这会在 Linear 中的 **Devin Playbooks** 标签组下自动创建一个名为 `!add-docs` 的标签。

      现在，当有人将该标签添加到工单时，Devin 会基于你的 playbook 启动会话。

      <Note>要让 playbook 标签自动同步到 Linear，你的 Linear 工作区必须将 **Manage workspace labels** 设置为 **All members** (位于 Linear 的 **Settings > Security** 下) 。如果未启用该设置，你需要在 Linear 中手动创建这些标签。</Note>
    </Step>

    <Step title="给工单打标签并生成文档">
      当团队成员在这样的工单上添加 `!add-docs` 标签时：

      > **ENG-215**: Add POST /api/v2/webhooks endpoint — accepts a URL and event types, validates the URL is reachable, stores the subscription, and returns the webhook ID.

      Devin 会自动启动一次会话，并按照你的文档 playbook 执行：

      * **阅读工单** — 提取端点描述、参数以及任何关联的 PR
      * **查找源代码** — 定位路由处理函数、请求校验 schema 和响应类型
      * **生成文档** — 在 `docs/api/` 中创建一个遵循你现有格式的新页面
      * **打开一个 PR** — 包含新的文档页面和更新后的侧边栏

      这在批量操作场景中同样适用——使用 **Cmd+A** 多选工单，右键单击，然后添加 `!add-docs` 标签，就可以并行为多个端点生成文档。

      <Tip>安装 Linear 集成后，Devin 可以原生访问 Linear 的工具——因此你的 playbook 可以指示 Devin 根据结果更新工单标签或状态。由于标签可以触发其他自动化，你可以串联工作流——例如，在文档生成之后，一个 `Docs Ready` 标签可以通知技术文档作者进行审阅。</Tip>
    </Step>

    <Step title="为你的团队制定更多操作手册">
      同样的模式适用于任何重复性任务。创建一个 playbook，将其同步为一个标签，你的团队就可以在任意工单上触发它。以下是一些示例：

      * **`!write-tests`** — 为工单中描述的功能添加测试覆盖
      * **`!refactor`** — 按照你团队的约定重构代码
      * **`!security-audit`** — 审查代码中的安全漏洞，并提交一个包含修复的 PR (pull request)
      * **`!migrate`** — 运行标准化迁移 (依赖升级、API 版本提升)

      你也可以设置[自动化触发器](/zh/integrations/linear)，让 Devin 在无人手动添加标签的情况下自动开始工作。前往 [**Settings > Connections > Linear**](https://app.devin.ai/settings/connections/linear?utm_source=docs\&utm_medium=use-case-gallery)，滚动到 **Automation triggers**，并配置一个触发器，使其在工单流转到特定状态或被打上特定标签时触发。
    </Step>
  </Steps>
</div>
