- Parses DocC JSON output from
.doccarchiveor processed documentation folders - Generates custom SDK schema with full type information, method signatures, and documentation
- Comprehensive documentation extraction - extracts abstracts, discussions, examples, and code listings from DocC comments
- Filters by access level with optional
--public-onlyflag - Fast parallel processing of JSON files
- Rich metadata extraction including parameters, return types, async/throws modifiers
- Cross-reference resolution for type relationships and protocol conformances
- Automatic protocol unmangling - converts mangled Swift protocol names (e.g.,
s8SendableP,Se) to clean names (Sendable) - Smart conformance filtering - filters out stdlib protocols while keeping custom protocols
- Flexible grouping options - group types by prefix or custom configuration
- Articles and tutorials support - optionally include documentation articles
- Navigation structure generation for easy website integration
# For Apple Silicon Macs
curl -L https://github.com/AppGram/docc2json/releases/download/v1.0.0/docc2json-darwin-arm64 -o docc2json
chmod +x docc2json
sudo mv docc2json /usr/local/bin/
go build -o bin/docc2json ./cmd/docc2jsongo install ./cmd/docc2json# Convert full SDK documentation
docc2json -i ./docs/data -o output.json
# From a .doccarchive
docc2json -i ./AppGramSDK.doccarchive -o output.json
# Public API only
docc2json -i ./docs/data -o sdk-public.json --public-only
# With verbose logging
docc2json -i ./docs -o output.json -v
# Compact JSON output (no indentation)
docc2json -i ./docs -o output.json --compact
# Filter out specific protocols from conformances
docc2json -i ./docs -o output.json --filter-protocols "Se,ScA,objc"
# Group types by name prefix (e.g., Wish, WishStatus, WishFilters -> Wish group)
docc2json -i ./docs -o output.json --group-by-prefix
# Use custom grouping configuration
docc2json -i ./docs -o output.json --group-by-prefix --group-config ./group-config.yaml
# Include articles and tutorials
docc2json -i ./docs -o output.json --include-articles
# Complete example with all features
docc2json \
-i ../iOS/AppGramSDK/docs/data \
-o sdk.json \
--include-articles \
--group-by-prefix \
--group-config ./group-config.yaml \
--filter-protocols "Se,ScA,objc,SE,SQ,SH,SY,SL" \
--keep-all-conformances \
--verbose| Flag | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Path to .doccarchive or docs/data folder (required) | - |
--output |
-o |
Output JSON file path | output.json |
--public-only |
-p |
Include only public API symbols | false |
--module |
-m |
Module name (auto-detect if not provided) | auto-detected |
--verbose |
-v |
Enable verbose logging | false |
--compact |
- | Output compact JSON (no indentation) | false |
--filter-protocols |
- | Comma-separated list of protocol names to exclude from conformances | - |
--keep-all-conformances |
- | Keep all conformances without filtering (for debugging) | false |
--group-by-prefix |
- | Group types by name prefix (e.g., Wish, WishFilters → Wish group) | false |
--group-config |
- | Path to YAML file with custom grouping configuration | - |
--include-articles |
- | Include documentation articles and tutorials | false |
--version |
- | Print version information | - |
The tool automatically processes protocol conformances with smart filtering:
Swift and Objective-C protocols often appear as mangled names in DocC output. The tool automatically converts these to clean names:
s8SendableP,Se→SendableSQ,s9EquatableP→EquatableSH,s8HashableP→Hashables12IdentifiableP→Identifiable7SwiftUI4ViewP→Viewobjc→NSObjectProtocolScA→NSSecureCoding- And many more...
By default, the tool filters out Swift standard library and framework protocols:
Filtered (won't appear in output):
Sendable,Equatable,Hashable,Codable,IdentifiableView,ObservableObjectError,CustomStringConvertible, etc.
Kept (will appear in output):
- Your custom protocols
- Third-party framework protocols
- Any protocol not in the stdlib list
Use --filter-protocols to exclude additional protocols:
# Filter out your internal protocols
docc2json -i ./docs -o output.json --filter-protocols "InternalProtocol,DebugOnly"To see all conformances without any filtering (useful for debugging):
docc2json -i ./docs -o output.json --keep-all-conformances --verboseThe tool supports flexible grouping of types, protocols, and enums for better organization in documentation sites.
Use --group-by-prefix to automatically group types by their name prefixes:
docc2json -i ./docs -o output.json --group-by-prefixThis will group types like:
Wish,WishStatus,WishFilters→ Wish groupSurvey,SurveyMap,SurveyData→ Survey groupAppGramSDK,AppGramTheme,AppGramConfig→ AppGram group
For more control, create a group-config.yaml file:
groups:
# Feedback and Wishes
Feedback:
description: "User feedback and wish management"
types:
- Wish
- WishFilters
- Vote
- Comment
enums:
- WishStatus
- WishSortOption
patterns:
- "Wish*"
- "*Wish"
# Surveys
Survey:
description: "Survey and mapping functionality"
patterns:
- "Survey*"
types:
- SurveyMap
- SurveyData
# UI Components
UI:
description: "User interface components"
patterns:
- "*View"
- "*Theme"
protocols:
- ViewConfigurableThen use it with:
docc2json -i ./docs -o output.json --group-by-prefix --group-config ./group-config.yamlConfiguration options:
types: Explicit list of type namesprotocols: Explicit list of protocol namesenums: Explicit list of enum namespatterns: Wildcard patterns ("Prefix*","*Suffix","*Infix*")description: Group description for documentation
Types not matching any group will be placed in an "Other" group.
The tool fully extracts DocC documentation including:
- Abstract: Brief one-line description
- Discussion: Detailed explanation from
## Discussionsections - Examples: Code examples from
## Examplesections with full code listings - Parameters: Parameter descriptions for methods
- Return values: Return value documentation
- Throws: Exception documentation
/// Represents a feedback item (wish) submitted by users.
///
/// ## Discussion
/// Wishes are user-submitted feedback items that can be voted on and commented on.
/// They represent feature requests, bug reports, or other feedback.
///
/// ## Example
/// ```swift
/// let wish = Wish(
/// id: "wish123",
/// title: "Dark mode support",
/// description: "Please add dark mode"
/// )
/// ```
public struct Wish { ... }{
"name": "Wish",
"description": {
"abstract": "Represents a feedback item (wish) submitted by users.",
"discussion": "Wishes are user-submitted feedback items that can be voted on and commented on. They represent feature requests, bug reports, or other feedback.",
"examples": [{
"title": "Example",
"code": "let wish = Wish(\n id: \"wish123\",\n title: \"Dark mode support\",\n description: \"Please add dark mode\"\n)"
}]
}
}Include documentation articles and tutorials with --include-articles:
docc2json -i ./docs -o output.json --include-articlesThis will include:
- Getting started guides
- Tutorials
- Conceptual documentation
- Best practices articles
The tool generates a JSON file with the following structure:
{
"schemaVersion": "1.0.0",
"metadata": {
"sdkName": "AppGramSDK",
"platform": "iOS",
"language": "swift",
"generatedAt": "2025-12-28T10:30:00Z"
},
"modules": [{
"name": "AppGramSDK",
"types": [/* classes, structs, actors */],
"protocols": [/* protocols */],
"enums": [/* enumerations */]
}],
"navigation": {
"categories": [
{
"title": "Types",
"items": ["AppGramSDK", "Configuration", ...]
}
]
}
}Each type includes:
- kind: "class", "struct", or "actor"
- name: Type name
- access: "public", "internal", or "private"
- declaration: Full Swift declaration
- conformances: Protocols the type conforms to
- inheritance: Parent classes
- properties: Array of property definitions
- methods: Array of method definitions
- initializers: Array of initializers
- description: Documentation object containing:
- abstract: Brief description
- discussion: Detailed explanation
- examples: Code examples with titles
- returnValue: Return value documentation (for methods)
- throws: Exception documentation (for methods)
- topicSections: Grouped navigation structure
Each method includes:
- name: Method name
- access: Access level
- isStatic: Whether it's a static/class method
- isAsync: Whether it's async
- throws: Whether it throws
- declaration: Full method signature
- signature: Structured signature with:
- parameters: Array with label, name, type, optionality, descriptions
- returnType: Return type
- keywords: Swift keywords (func, static, async, etc.)
Each enum includes:
- cases: Enum cases with descriptions
- properties: Computed properties
- methods: Instance and static methods
- conformances: Protocol conformances
Each protocol includes:
- requirements: Required methods, properties, and initializers
- inheritance: Inherited protocols
- conformingTypes: Types that conform to this protocol
{
"kind": "class",
"name": "AppGramSDK",
"access": "public",
"declaration": "final class AppGramSDK",
"conformances": ["Sendable"],
"properties": [{
"name": "shared",
"type": "AppGramSDK",
"isStatic": true,
"access": "public",
"declaration": "static let shared: AppGramSDK"
}],
"methods": [{
"name": "configure",
"declaration": "func configure(projectId: String, baseURL: String, theme: AppGramTheme?)",
"signature": {
"parameters": [
{
"label": "projectId",
"type": "String",
"isOptional": false
},
{
"label": "baseURL",
"type": "String",
"isOptional": false
},
{
"label": "theme",
"type": "AppGramTheme",
"isOptional": true
}
],
"returnType": "Void",
"async": false,
"throws": false
}
}]
}Tested on AppGramSDK documentation (38,618 files):
- Parsing: ~0.4 seconds (parallel)
- Transformation: ~0.03 seconds
- Total: < 1 second
- Output size:
- Types only: ~756KB for 129 symbols (103 types, 8 protocols, 18 enums)
- With articles: ~1.2MB for 129 symbols + 92 articles
docc2json/
├── cmd/docc2json/ # CLI entry point
├── internal/
│ ├── parser/ # DocC JSON parsing
│ │ ├── file_walker.go
│ │ ├── docc_parser.go
│ │ ├── token_builder.go
│ │ └── reference_resolver.go
│ ├── models/
│ │ ├── docc/ # DocC JSON structures
│ │ └── sdk/ # Output SDK structures
│ ├── transformer/ # DocC → SDK transformation
│ ├── filter/ # Access level filtering
│ └── writer/ # JSON output writer
- File Walking: Locates and collects all
.jsonfiles in the DocC output - Parallel Parsing: Parses JSON files concurrently using goroutines
- Token Reconstruction: Rebuilds method signatures from DocC's token arrays
- Reference Resolution: Resolves cross-references between symbols
- Access Filtering: Filters symbols based on access level (if --public-only)
- Transformation: Converts DocC schema to custom SDK schema
- JSON Output: Writes formatted JSON to the specified path
- AppGramSDK - 38,618 documentation files, 129 symbols + 92 articles
- Swift 5.9+ DocC output
- DocC schema version 0.3.0
- iOS SDK documentation with full discussion and example extraction
- Go 1.21 or higher
- DocC generated documentation (
.doccarchiveor processeddocs/folder)
- spf13/cobra - CLI framework
- uber-go/zap - Structured logging
- Documentation Websites: Generate JSON for custom documentation sites
- IDE Integration: Provide autocomplete and inline docs
- SDK Analysis: Programmatically analyze SDK structure
- Cross-Platform Docs: Generate documentation for other platforms
- Fixed Discussion extraction: Corrected heading text extraction from DocC JSON to properly capture Discussion, Example, and other documentation sections
- Added flexible grouping: Support for automatic prefix-based grouping and custom YAML configuration
- Articles support: Optional inclusion of documentation articles and tutorials
- Enhanced documentation: Full extraction of abstracts, discussions, and code examples from DocC comments
- Discussion sections: Fixed issue where DocC heading text was incorrectly extracted from
InlineContentinstead ofTextfield, causing Discussion and Example sections to be lost
MIT License
Built by AppGram for converting iOS SDK documentation to web-friendly JSON format.
1.1.0 - Enhanced documentation extraction and flexible grouping (2025-12-28)
