| description | Generate comprehensive API documentation using DocC (Swift-DocC) for your PaleoRose project |
API Documentation Generator
Generate comprehensive API documentation using DocC (Swift-DocC) for your PaleoRose project.
Capabilities
-
DocC Documentation
- Generate DocC catalogs from code
- Create documentation articles
- Build tutorials and guides
- Generate browsable documentation websites
-
Code Comment Enhancement
- Add missing documentation comments
- Improve existing doc comments
- Follow Swift API Design Guidelines
- Add parameter/return descriptions
-
Documentation Structure
- Organize into logical groups
- Create topic collections
- Build navigation hierarchies
- Link related APIs
-
Rich Content
- Add code examples
- Include diagrams and images
- Create interactive tutorials
- Embed rendered graphics examples
-
Export Formats
- Static HTML website
- Xcode Documentation Browser
- PDF documentation
- Markdown files
Workflow
When invoked, this skill will:
- Analyze: Scan code for documentation gaps
- Enhance: Add/improve doc comments
- Structure: Organize documentation hierarchy
- Generate: Build DocC catalog
- Export: Create browsable documentation
Usage Instructions
When the user invokes this skill:
-
Ask what to document:
- Entire project
- Specific module/framework
- Public API only
- Include internal APIs
-
Choose documentation style:
- Minimal: Basic summaries only
- Standard: Summaries + parameters/returns
- Comprehensive: Full examples and explanations
-
Generate documentation structure
-
Build DocC catalog
-
Export to desired format
Project-Specific Context
Your key documentation targets:
- CodableSQLiteNonThread: Database framework
- Graphics: Visualization classes (Graphic, GraphicPetal, etc.)
- Document Model: DocumentModel, InMemoryStore
- Layers: Layer hierarchy and storage
- Utilities: Extensions and helpers
DocC Comment Patterns
1. Type Documentation
@objc class GraphicPetal: Graphic {
}
2. Method Documentation
@objc init?(
controller: GraphicGeometrySource,
forIncrement increment: Int32,
forValue aNumber: NSNumber
) {
}
3. Property Documentation
override var lineWidth: Float {
didSet {
drawingPath?.lineWidth = CGFloat(lineWidth)
}
}
4. Protocol Documentation
public protocol TableRepresentable: Codable {
static var tableName: String { get }
static var primaryKey: String? { get }
}
5. Extension Documentation
extension CGFloat {
func normalizedAngle() -> CGFloat {
var angle = self
while angle < 0 {
angle += 360
}
while angle >= 360 {
angle -= 360
}
return angle
}
var radians: CGFloat {
self * .pi / 180.0
}
var degrees: CGFloat {
self * 180.0 / .pi
}
}
Documentation Catalog Structure
Create DocC Catalog
PaleoRose.docc/
├── PaleoRose.md # Root documentation page
├── Resources/
│ ├── rose-diagram-example.png
│ ├── layer-hierarchy.png
│ └── database-schema.png
├── Articles/
│ ├── GettingStarted.md
│ ├── RoseDiagrams.md
│ ├── DatabaseModel.md
│ └── GraphicsArchitecture.md
└── Tutorials/
├── PaleoRose.tutorial
├── CreatingRoseDiagram.tutorial
└── WorkingWithLayers.tutorial
Root Page (PaleoRose.md)
# ``PaleoRose``
A macOS application for creating and analyzing rose diagrams from paleontological data.
## Overview
PaleoRose provides tools for visualizing directional data using rose diagrams,
circular histograms, and other specialized plots commonly used in geology and
paleontology.
## Topics
### Essentials
- <doc:GettingStarted>
- <doc:RoseDiagrams>
- <doc:DatabaseModel>
### Graphics and Visualization
- ``Graphic``
- ``GraphicPetal``
- ``GraphicCircle``
- ``GraphicKite``
- ``GraphicHistogram``
### Data Model
- ``DocumentModel``
- ``InMemoryStore``
- ``Layer``
- ``DataSet``
### Database Framework
- ``TableRepresentable``
- ``SQLiteInterface``
- ``Query``
### Utilities
- <doc:GraphicsArchitecture>
- ``CGFloat`` extensions
- ``NSBezierPath`` extensions
Tutorial Example
@Tutorial(time: 20) {
@Intro(title: "Creating Your First Rose Diagram") {
Learn how to create and customize a rose diagram to visualize
directional data.
@Image(source: "rose-diagram-intro.png", alt: "A completed rose diagram")
}
@Section(title: "Setting Up Your Data") {
@ContentAndMedia {
First, import your directional measurements into PaleoRose.
@Image(source: "data-import.png", alt: "Data import dialog")
}
@Steps {
@Step {
Create a new document.
@Code(name: "CreateDocument.swift", file: 01-create-document.swift)
}
@Step {
Add your measurements to the dataset.
@Code(name: "AddData.swift", file: 02-add-data.swift)
}
}
}
@Section(title: "Creating the Diagram") {
@ContentAndMedia {
Configure the rose diagram visualization settings.
}
@Steps {
@Step {
Create a data layer.
@Code(name: "CreateLayer.swift", file: 03-create-layer.swift)
}
@Step {
Configure petal graphics.
@Code(name: "ConfigurePetals.swift", file: 04-configure-petals.swift)
}
}
}
@Assessments {
@MultipleChoice {
What does the length of a petal represent in a rose diagram?
@Choice(isCorrect: false) {
The angle of the measurement
@Justification(isCorrect: false) {
The angle is represented by the petal's position, not its length.
}
}
@Choice(isCorrect: true) {
The frequency of measurements in that direction
@Justification(isCorrect: true) {
Correct! Petal length shows how many measurements fall within
that directional bin.
}
}
}
}
}
Building Documentation
Using Xcode
xcodebuild docbuild \
-scheme PaleoRose \
-derivedDataPath ./DocBuild
find ./DocBuild -name "*.doccarchive"
Using Swift-DocC CLI
swift package plugin generate-documentation \
--target PaleoRose \
--output-path ./docs
swift package plugin preview-documentation \
--target PaleoRose
Export Static Website
swift package plugin generate-documentation \
--target PaleoRose \
--hosting-base-path /PaleoRose \
--output-path ./docs
python3 -m http.server --directory ./docs 8000
Documentation Comments Checklist
Generate documentation for:
Each should have:
Automated Documentation Audit
#!/usr/bin/swift
import Foundation
let fileManager = FileManager.default
let projectPath = "./PaleoRose"
func auditDocumentation(in directory: String) {
}
struct DocumentationGap {
let file: String
let line: Int
let declaration: String
let type: DeclarationType
enum DeclarationType {
case `class`, `struct`, `enum`, `protocol`
case method, property, initializer
}
}
print("Documentation Coverage Report")
print("==============================")
print("")
print("Missing Documentation:")
print("")
print("Coverage: \(coveredCount)/\(totalCount) (\(percentage)%)")
Documentation Best Practices
-
Write for Your Audience
- External users: Focus on how to use
- Internal developers: Include why and how
-
Use Active Voice
- "Creates a petal" not "A petal is created"
- "Calculates the angle" not "The angle is calculated"
-
Be Concise
- Summary: One sentence
- Overview: 2-3 paragraphs max
- Details: As needed
-
Provide Context
- Why does this exist?
- When should it be used?
- What are the alternatives?
-
Include Examples
- Realistic use cases
- Common patterns
- Edge cases
-
Link Related Items
- Use
Type for symbols
- Use doc:Article for articles
- Cross-reference related APIs
-
Keep It Updated
- Update docs with code changes
- Review during PR process
- Audit periodically
Integration with CI/CD
GitHub Actions
name: Documentation
on:
push:
branches: [main]
pull_request:
jobs:
build-docs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Build Documentation
run: |
swift package plugin generate-documentation \
--target PaleoRose \
--output-path ./docs
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
Configuration
Store documentation settings in .docc-config.json:
{
"hostingBasePath": "/PaleoRose",
"targets": ["PaleoRose", "CodableSQLiteNonThread"],
"outputPath": "./docs",
"theme": {
"color": "#007AFF",
"iconPath": "./Resources/icon.png"
},
"excludedPaths": [
"*/Tests/*",
"*/Mocks/*"
],
"generateTutorials": true,
"generateArticles": true
}