AgentSkillsCN

docc

为 Swift 模块编写并维护 DocC 文档。适用于以下场景: (1) 创建新的 Documentation.docc 目录 (2) 编写或编辑 Main.md 着陆页 (3) 向文档中添加文章或指南 (4) 使用三斜杠注释记录符号 (5) 组织 Topics 章节 (6) 在文档中添加图片、图表或代码示例 (7) 修复 DocC 构建警告或失效链接 (8) 当用户提及“文档”、“DocC”、“文档”或要求为代码撰写文档时

SKILL.md
--- frontmatter
name: docc
description: |
  Write and maintain DocC documentation for Swift modules. Use when:
  (1) Creating new Documentation.docc catalogs
  (2) Writing or editing Main.md landing pages
  (3) Adding articles or guides to documentation
  (4) Documenting symbols with triple-slash comments
  (5) Organizing Topics sections
  (6) Adding images, diagrams, or code examples to docs
  (7) Fixing DocC build warnings or broken links
  (8) User mentions "documentation", "docc", "docs", or asks to document code

DocC Documentation

Write documentation that builds correctly and follows Apple's DocC conventions.

Quick Reference

Documentation Comment Syntax

swift
/// Summary sentence (becomes the abstract).
///
/// Discussion paragraph with additional context.
/// Can span multiple lines.
///
/// - Parameters:
///   - name: Description of the parameter.
///   - value: Another parameter description.
/// - Returns: What the function returns.
/// - Throws: ``ErrorType`` when something fails.
///
/// ## Example
/// ```swift
/// let result = myFunction(name: "test", value: 42)
/// ```
func myFunction(name: String, value: Int) throws -> String

Symbol Linking

SyntaxUse
TypeName Link to type
TypeName/method Link to member
<doc:ArticleName>Link to article

Documentation Catalog Structure

code
ModuleName/
├── Sources/
│   └── *.swift
└── Documentation.docc/
    ├── Main.md           # Landing page (# ``ModuleName``)
    ├── Article.md        # Conceptual articles
    └── Resources/
        ├── image@2x.png      # Light mode
        └── image~dark@2x.png # Dark mode

Main.md Template

markdown
# ``ModuleName``

One-sentence summary of the module.

## Overview

Paragraph explaining the module's purpose and key concepts.

## Topics

### Group Name
- ``TypeName``
- ``TypeName/property``
- <doc:ArticleName>

Article Template

markdown
# Article Title

Summary sentence for the article.

## Overview

Introductory paragraph.

## Section Header

Content with code examples:

```swift
// Example code

Image alt text

code

## Layout Directives

For rich layouts beyond standard Markdown:

```markdown
@Row {
    @Column {
        Paragraph text explaining a concept.
    }

    @Column {
        ![Description](image-name)
    }
}

@TabNavigator {
    @Tab("First") {
        Content for first tab.
    }

    @Tab("Second") {
        Content for second tab.
    }
}

Common Issues

ProblemSolution
Symbol not foundVerify symbol is public; use full path Module/Type/member
Image not showingCheck file is in Documentation.docc, correct naming (@2x, ~dark)
Article not linkedAdd <doc:ArticleName> to Topics section in Main.md
Build warning "No overview"Add ## Overview section after title

Validation

Build documentation to check for errors:

bash
# In Xcode: Product → Build Documentation
# Or via command line:
xcodebuild docbuild -scheme SchemeName