Skip to content

Commit 5bb7c82

Browse files
committed
docs(annotations): add annotations API documentation
Add comprehensive documentation for the annotations subsystem: - New annotations.mdx with full API reference - Cross-reference from pdf-page.mdx to annotations - Update meta.json navigation to include annotations - Update document.md command with correct directory structure - Fix lint-staged to skip content directory JSON files
1 parent df8be3a commit 5bb7c82

File tree

5 files changed

+590
-67
lines changed

5 files changed

+590
-67
lines changed

.lintstagedrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"*.{ts,tsx,js,jsx,json}": ["biome check --write"]
2+
"*.{ts,tsx,js,jsx,json}": ["biome check --write"],
3+
"content/**/*.json": []
34
}

.opencode/commands/document.md

Lines changed: 101 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,96 +9,126 @@ You are creating proper markdown documentation for a module or feature in the li
99

1010
1. **Identify the scope** - What does `$ARGUMENTS` refer to? (file, directory, or feature name)
1111
2. **Read the source code** - Understand the public API, types, and behavior
12-
3. **Read existing docs** - Check if there's documentation to update
13-
4. **Write comprehensive documentation** - Create or update markdown docs
12+
3. **Read existing docs** - Check `content/docs/` for documentation to update
13+
4. **Write comprehensive documentation** - Create or update MDX docs
1414

1515
## Documentation Structure
1616

17-
Create documentation in the appropriate location:
18-
- **API docs**: `docs/api/<module>.md`
19-
- **Guides**: `docs/guides/<topic>.md`
20-
- **Examples**: Include in the relevant doc or `docs/examples/`
17+
This project uses [Fumadocs](https://fumadocs.dev) for documentation. All docs live in `content/docs/` as MDX files.
2118

22-
### API Documentation Format
23-
24-
```markdown
25-
# <Module Name>
19+
```
20+
content/docs/
21+
├── index.mdx # Landing page
22+
├── meta.json # Root navigation order
23+
├── getting-started/ # Quickstart guides
24+
│ ├── installation.mdx
25+
│ ├── create-pdf.mdx
26+
│ └── parse-pdf.mdx
27+
├── guides/ # Feature guides
28+
│ ├── drawing.mdx
29+
│ ├── encryption.mdx
30+
| |-- ...
31+
├── api/ # API reference
32+
│ ├── pdf.mdx
33+
│ ├── pdf-page.mdx
34+
│ ├── pdf-form.mdx
35+
│ ├── ...
36+
├── concepts/ # Conceptual docs
37+
│ ├── pdf-structure.mdx
38+
│ ├── object-model.mdx
39+
│ └── incremental-saves.mdx
40+
├── advanced/ # Advanced topics
41+
│ └── library-authors.mdx
42+
└── migration/ # Migration guides
43+
└── from-pdf-lib.mdx
44+
```
2645

27-
Brief description of what this module does and when to use it.
46+
### Where to Put Documentation
2847

29-
## Installation
48+
| Type | Location | When to use |
49+
|------|----------|-------------|
50+
| **API Reference** | `content/docs/api/<class>.mdx` | Documenting a class like `PDF`, `PDFPage`, `PDFForm` |
51+
| **Feature Guide** | `content/docs/guides/<feature>.mdx` | How-to guides for features (forms, signatures, etc.) |
52+
| **Concept** | `content/docs/concepts/<topic>.mdx` | Explaining PDF concepts (structure, objects, etc.) |
53+
| **Getting Started** | `content/docs/getting-started/` | Installation and first steps |
3054

31-
If there are specific imports needed.
55+
### Navigation (meta.json)
3256

33-
## Quick Start
57+
Each directory has a `meta.json` that controls navigation order:
3458

35-
```typescript
36-
// Minimal working example
59+
```json
60+
{
61+
"title": "API Reference",
62+
"pages": ["index", "---Classes---", "pdf", "pdf-page", "pdf-form", "annotations", "---Other---", "errors"]
63+
}
3764
```
3865

39-
## API Reference
66+
- Use `---Label---` for section dividers
67+
- Order determines sidebar appearance
4068

41-
### `ClassName`
69+
### MDX File Format
4270

43-
Description of the class.
71+
```mdx
72+
---
73+
title: ModuleName
74+
description: Brief description for SEO and previews.
75+
---
4476

45-
#### Constructor
77+
import { Callout } from 'fumadocs-ui/components/callout';
4678

47-
```typescript
48-
new ClassName(options: Options)
49-
```
79+
# ModuleName
5080

51-
| Parameter | Type | Description |
52-
|-----------|------|-------------|
53-
| options | `Options` | Configuration options |
81+
Brief description of what this module does and when to use it.
5482

55-
#### Methods
83+
<Callout type="warn" title="my title">
84+
Use callouts sparingly for important warnings or beta features.
85+
</Callout>
5686

57-
##### `methodName(param: Type): ReturnType`
87+
## Quick Start
88+
89+
\`\`\`typescript
90+
import { PDF } from "@libpdf/core";
91+
// Minimal working example
92+
\`\`\`
93+
94+
---
95+
96+
## methodName(options)
5897

5998
Description of what the method does.
6099

61-
**Parameters:**
62-
- `param` - Description
100+
| Param | Type | Default | Description |
101+
|-------|------|---------|-------------|
102+
| `param` | `string` | required | What it does |
103+
| `[optional]` | `number` | `10` | Optional param |
63104

64-
**Returns:** Description of return value
105+
**Returns**: `ReturnType`
65106

66-
**Example:**
67-
```typescript
107+
\`\`\`typescript
68108
// Usage example
69-
```
109+
\`\`\`
70110

71-
### Types
111+
---
72112

73-
#### `TypeName`
113+
## Types
74114

75-
```typescript
115+
### TypeName
116+
117+
\`\`\`typescript
76118
interface TypeName {
77119
property: string;
78120
}
121+
\`\`\`
79122
```
80123

81-
## Examples
82-
83-
### Common Use Case
84-
85-
```typescript
86-
// Full working example
87-
```
88-
89-
### Advanced Usage
90-
91-
```typescript
92-
// More complex example
93-
```
124+
### Fumadocs Components
94125

95-
## Error Handling
126+
```mdx
127+
import { Callout } from 'fumadocs-ui/components/callout';
96128

97-
Document common errors and how to handle them.
98-
99-
## See Also
100-
101-
- Links to related documentation
129+
<Callout type="info">Informational note</Callout>
130+
<Callout type="warn">Warning message</Callout>
131+
<Callout type="error">Error/danger message</Callout>
102132
```
103133

104134
## Guidelines
@@ -116,25 +146,31 @@ Document common errors and how to handle them.
116146
- Progress from simple to complex
117147

118148
### Formatting
119-
- Use proper markdown headers (h1 for title, h2 for sections)
149+
- Use `---` horizontal rules between major sections
120150
- Use code fences with `typescript` language tag
121151
- Use tables for parameter/option documentation
122-
- Use admonitions sparingly (> **Note:** ...)
152+
- Use Fumadocs `<Callout>` components sparingly
153+
154+
### Cross-References
155+
- Link to related docs: `[PDFPage](/docs/api/pdf-page)`
156+
- Add "See Also" sections when helpful
157+
- Update `meta.json` when adding new pages
123158

124159
### Maintenance
125160
- Include types inline so docs don't get stale
126161
- Reference source file locations for complex behavior
127-
- Date or version-stamp if behavior may change
162+
- Use `<Callout type="warn">` for beta/unstable features
128163

129164
## Process
130165

131166
1. **Explore the code** - Read source files to understand the API
132-
2. **Identify the audience** - Who will read this? What do they need?
133-
3. **Draft the structure** - Outline sections before writing
134-
4. **Write content** - Fill in each section
135-
5. **Add examples** - Create working code samples
136-
6. **Review** - Read through for clarity and accuracy
167+
2. **Check existing docs** - Look in `content/docs/` for related pages
168+
3. **Identify the audience** - Who will read this? What do they need?
169+
4. **Draft the structure** - Outline sections before writing
170+
5. **Write content** - Fill in each section with examples
171+
6. **Update navigation** - Add to relevant `meta.json` if new page
172+
7. **Add cross-references** - Link from related docs
137173

138174
## Begin
139175

140-
Analyze `$ARGUMENTS`, read the relevant source code, and create comprehensive markdown documentation.
176+
Analyze `$ARGUMENTS`, read the relevant source code, and create comprehensive MDX documentation in `content/docs/`.

0 commit comments

Comments
 (0)