Skip to content

Commit 138500f

Browse files
committed
v1
1 parent 2b9a86b commit 138500f

1 file changed

Lines changed: 184 additions & 4 deletions

File tree

README.md

Lines changed: 184 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ A fast Go CLI tool that parses Apple's DocC JSON documentation output and conver
66

77
- **Parses DocC JSON output** from `.doccarchive` or processed documentation folders
88
- **Generates custom SDK schema** with full type information, method signatures, and documentation
9+
- **Comprehensive documentation extraction** - extracts abstracts, discussions, examples, and code listings from DocC comments
910
- **Filters by access level** with optional `--public-only` flag
1011
- **Fast parallel processing** of JSON files
1112
- **Rich metadata extraction** including parameters, return types, async/throws modifiers
1213
- **Cross-reference resolution** for type relationships and protocol conformances
1314
- **Automatic protocol unmangling** - converts mangled Swift protocol names (e.g., `s8SendableP`, `Se`) to clean names (`Sendable`)
1415
- **Smart conformance filtering** - filters out stdlib protocols while keeping custom protocols
16+
- **Flexible grouping options** - group types by prefix or custom configuration
17+
- **Articles and tutorials support** - optionally include documentation articles
1518
- **Navigation structure generation** for easy website integration
1619

1720
## Installation
@@ -50,6 +53,26 @@ docc2json -i ./docs -o output.json --compact
5053

5154
# Filter out specific protocols from conformances
5255
docc2json -i ./docs -o output.json --filter-protocols "Se,ScA,objc"
56+
57+
# Group types by name prefix (e.g., Wish, WishStatus, WishFilters -> Wish group)
58+
docc2json -i ./docs -o output.json --group-by-prefix
59+
60+
# Use custom grouping configuration
61+
docc2json -i ./docs -o output.json --group-by-prefix --group-config ./group-config.yaml
62+
63+
# Include articles and tutorials
64+
docc2json -i ./docs -o output.json --include-articles
65+
66+
# Complete example with all features
67+
docc2json \
68+
-i ../iOS/AppGramSDK/docs/data \
69+
-o sdk.json \
70+
--include-articles \
71+
--group-by-prefix \
72+
--group-config ./group-config.yaml \
73+
--filter-protocols "Se,ScA,objc,SE,SQ,SH,SY,SL" \
74+
--keep-all-conformances \
75+
--verbose
5376
```
5477

5578
### Command-Line Flags
@@ -64,6 +87,9 @@ docc2json -i ./docs -o output.json --filter-protocols "Se,ScA,objc"
6487
| `--compact` | - | Output compact JSON (no indentation) | `false` |
6588
| `--filter-protocols` | - | Comma-separated list of protocol names to exclude from conformances | - |
6689
| `--keep-all-conformances` | - | Keep all conformances without filtering (for debugging) | `false` |
90+
| `--group-by-prefix` | - | Group types by name prefix (e.g., Wish, WishFilters → Wish group) | `false` |
91+
| `--group-config` | - | Path to YAML file with custom grouping configuration | - |
92+
| `--include-articles` | - | Include documentation articles and tutorials | `false` |
6793
| `--version` | - | Print version information | - |
6894

6995
## Protocol Conformances
@@ -114,6 +140,139 @@ To see all conformances without any filtering (useful for debugging):
114140
docc2json -i ./docs -o output.json --keep-all-conformances --verbose
115141
```
116142

143+
## Type Grouping
144+
145+
The tool supports flexible grouping of types, protocols, and enums for better organization in documentation sites.
146+
147+
### Automatic Prefix-Based Grouping
148+
149+
Use `--group-by-prefix` to automatically group types by their name prefixes:
150+
151+
```bash
152+
docc2json -i ./docs -o output.json --group-by-prefix
153+
```
154+
155+
This will group types like:
156+
- `Wish`, `WishStatus`, `WishFilters`**Wish** group
157+
- `Survey`, `SurveyMap`, `SurveyData`**Survey** group
158+
- `AppGramSDK`, `AppGramTheme`, `AppGramConfig`**AppGram** group
159+
160+
### Custom Grouping with YAML Configuration
161+
162+
For more control, create a `group-config.yaml` file:
163+
164+
```yaml
165+
groups:
166+
# Feedback and Wishes
167+
Feedback:
168+
description: "User feedback and wish management"
169+
types:
170+
- Wish
171+
- WishFilters
172+
- Vote
173+
- Comment
174+
enums:
175+
- WishStatus
176+
- WishSortOption
177+
patterns:
178+
- "Wish*"
179+
- "*Wish"
180+
181+
# Surveys
182+
Survey:
183+
description: "Survey and mapping functionality"
184+
patterns:
185+
- "Survey*"
186+
types:
187+
- SurveyMap
188+
- SurveyData
189+
190+
# UI Components
191+
UI:
192+
description: "User interface components"
193+
patterns:
194+
- "*View"
195+
- "*Theme"
196+
protocols:
197+
- ViewConfigurable
198+
```
199+
200+
Then use it with:
201+
202+
```bash
203+
docc2json -i ./docs -o output.json --group-by-prefix --group-config ./group-config.yaml
204+
```
205+
206+
**Configuration options:**
207+
- `types`: Explicit list of type names
208+
- `protocols`: Explicit list of protocol names
209+
- `enums`: Explicit list of enum names
210+
- `patterns`: Wildcard patterns (`"Prefix*"`, `"*Suffix"`, `"*Infix*"`)
211+
- `description`: Group description for documentation
212+
213+
Types not matching any group will be placed in an "Other" group.
214+
215+
## Documentation Extraction
216+
217+
The tool fully extracts DocC documentation including:
218+
219+
- **Abstract**: Brief one-line description
220+
- **Discussion**: Detailed explanation from `## Discussion` sections
221+
- **Examples**: Code examples from `## Example` sections with full code listings
222+
- **Parameters**: Parameter descriptions for methods
223+
- **Return values**: Return value documentation
224+
- **Throws**: Exception documentation
225+
226+
### Example from Swift Source:
227+
228+
```swift
229+
/// Represents a feedback item (wish) submitted by users.
230+
///
231+
/// ## Discussion
232+
/// Wishes are user-submitted feedback items that can be voted on and commented on.
233+
/// They represent feature requests, bug reports, or other feedback.
234+
///
235+
/// ## Example
236+
/// ```swift
237+
/// let wish = Wish(
238+
/// id: "wish123",
239+
/// title: "Dark mode support",
240+
/// description: "Please add dark mode"
241+
/// )
242+
/// ```
243+
public struct Wish { ... }
244+
```
245+
246+
### Extracted JSON:
247+
248+
```json
249+
{
250+
"name": "Wish",
251+
"description": {
252+
"abstract": "Represents a feedback item (wish) submitted by users.",
253+
"discussion": "Wishes are user-submitted feedback items that can be voted on and commented on. They represent feature requests, bug reports, or other feedback.",
254+
"examples": [{
255+
"title": "Example",
256+
"code": "let wish = Wish(\n id: \"wish123\",\n title: \"Dark mode support\",\n description: \"Please add dark mode\"\n)"
257+
}]
258+
}
259+
}
260+
```
261+
262+
## Articles and Tutorials
263+
264+
Include documentation articles and tutorials with `--include-articles`:
265+
266+
```bash
267+
docc2json -i ./docs -o output.json --include-articles
268+
```
269+
270+
This will include:
271+
- Getting started guides
272+
- Tutorials
273+
- Conceptual documentation
274+
- Best practices articles
275+
117276
## Output Schema
118277

119278
The tool generates a JSON file with the following structure:
@@ -157,7 +316,12 @@ Each type includes:
157316
- **properties**: Array of property definitions
158317
- **methods**: Array of method definitions
159318
- **initializers**: Array of initializers
160-
- **description**: Documentation with abstract and discussion
319+
- **description**: Documentation object containing:
320+
- **abstract**: Brief description
321+
- **discussion**: Detailed explanation
322+
- **examples**: Code examples with titles
323+
- **returnValue**: Return value documentation (for methods)
324+
- **throws**: Exception documentation (for methods)
161325
- **topicSections**: Grouped navigation structure
162326

163327
### Method Representation
@@ -244,7 +408,9 @@ Tested on AppGramSDK documentation (38,618 files):
244408
- **Parsing**: ~0.4 seconds (parallel)
245409
- **Transformation**: ~0.03 seconds
246410
- **Total**: < 1 second
247-
- **Output size**: 756KB for 171 symbols (143 types, 8 protocols, 20 enums)
411+
- **Output size**:
412+
- Types only: ~756KB for 129 symbols (103 types, 8 protocols, 18 enums)
413+
- With articles: ~1.2MB for 129 symbols + 92 articles
248414

249415
## Architecture
250416

@@ -277,9 +443,10 @@ docc2json/
277443

278444
## Tested With
279445

280-
- **AppGramSDK** - 38,618 documentation files, 171 public symbols
446+
- **AppGramSDK** - 38,618 documentation files, 129 symbols + 92 articles
281447
- **Swift 5.9+** DocC output
282448
- **DocC schema version** 0.3.0
449+
- **iOS SDK documentation** with full discussion and example extraction
283450

284451
## Requirements
285452

@@ -298,6 +465,19 @@ docc2json/
298465
- **SDK Analysis**: Programmatically analyze SDK structure
299466
- **Cross-Platform Docs**: Generate documentation for other platforms
300467

468+
## Recent Improvements
469+
470+
### v1.1.0 (2025-12-28)
471+
472+
- **Fixed Discussion extraction**: Corrected heading text extraction from DocC JSON to properly capture Discussion, Example, and other documentation sections
473+
- **Added flexible grouping**: Support for automatic prefix-based grouping and custom YAML configuration
474+
- **Articles support**: Optional inclusion of documentation articles and tutorials
475+
- **Enhanced documentation**: Full extraction of abstracts, discussions, and code examples from DocC comments
476+
477+
### Key Bug Fixes
478+
479+
- **Discussion sections**: Fixed issue where DocC heading text was incorrectly extracted from `InlineContent` instead of `Text` field, causing Discussion and Example sections to be lost
480+
301481
## License
302482

303483
MIT License
@@ -308,4 +488,4 @@ Built by [AppGram](https://github.com/AppGram) for converting iOS SDK documentat
308488

309489
## Version
310490

311-
1.0.0
491+
1.1.0 - Enhanced documentation extraction and flexible grouping (2025-12-28)

0 commit comments

Comments
 (0)