Skip to content

Commit e249d93

Browse files
committed
Merge branch 'main' into DOCSS-1818-deploys-updates
2 parents ef53cc0 + 8757aae commit e249d93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7075
-480
lines changed

API_DOCS_INTEGRATION.md

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# API Documentation Integration
2+
3+
This project integrates API documentation with the Antora documentation site, providing two versions of API docs that are built during the main site build process and served alongside the main documentation.
4+
5+
## Architecture Overview
6+
7+
### Build Process
8+
9+
1. **UI Build**: Antora UI bundle is created
10+
2. **Antora Build**: Main documentation site is generated
11+
3. **API Docs Build**: Both API v1 and v2 documentation are built and integrated
12+
13+
### API Documentation Versions
14+
15+
**API v1** - Static Documentation
16+
17+
- Source: `api-v1/` directory (complete static site)
18+
- Build: Simple file copying
19+
- Output: `build/api/v1/` (preserves all assets: fonts, images, CSS, JS)
20+
- URL: `/api/v1/`
21+
22+
**API v2** - Live Documentation
23+
24+
- Source: Live CircleCI API (`https://circleci.com/api/v2/openapi.json`)
25+
- Build: Sophisticated pipeline with fetching, patching, bundling, and HTML generation
26+
- Output: `build/api/v2/index.html`
27+
- URL: `/api/v2/`
28+
29+
## File Structure
30+
31+
```
32+
project-root/
33+
├── api-v1/ # Static API v1 documentation
34+
│ ├── index.html # Main v1 docs (217KB)
35+
│ ├── fonts/ # Font assets
36+
│ ├── images/ # Image assets
37+
│ ├── javascripts/ # JS assets
38+
│ └── stylesheets/ # CSS assets
39+
├── openapi-patch.json # JSON patches for v2 API customization
40+
├── redocly.yaml # Redocly config (currently unused in build)
41+
├── gulp.d/tasks/
42+
│ └── build-api-docs.js # API documentation build pipeline
43+
└── build/ # Generated output
44+
└── api/
45+
├── v1/ # Complete static v1 site
46+
└── v2/ # Generated v2 documentation
47+
└── index.html # Single-page API docs (1.6MB)
48+
```
49+
50+
## Build Pipeline Details
51+
52+
### API v1 Build (Simple)
53+
54+
1. Check if `api-v1/` directory exists
55+
2. Copy entire directory structure to `build/api/v1/`
56+
3. Preserve all assets (fonts, images, CSS, JS)
57+
58+
### API v2 Build (Sophisticated)
59+
60+
1. **Fetch**: Download live OpenAPI spec from CircleCI API
61+
2. **Prepare**: Ready spec for processing (future code sample enrichment)
62+
3. **Patch**: Apply JSON patches from `openapi-patch.json`
63+
4. **Bundle**: Optimize spec and remove unused components
64+
5. **Lint**: Quality check the processed spec
65+
6. **Build**: Generate HTML documentation with Redocly CLI
66+
7. **Cleanup**: Remove temporary processing files
67+
68+
## Navigation Integration
69+
70+
### Header Dropdown
71+
72+
- "API Reference" button in main site header
73+
- Dropdown shows "API v1" and "API v2" options
74+
- Implemented in `ui/src/partials/header-content.hbs`
75+
76+
### Sidebar Navigation
77+
78+
- API links in component explorer navigation
79+
- Links appear in reference section sidebar
80+
- Implemented in `ui/src/partials/component-explorer-nav.hbs`
81+
82+
### Content Page Links
83+
84+
- Direct links from documentation pages
85+
- Uses relative paths `/api/v1/` and `/api/v2/`
86+
- Implemented in Antora content files
87+
88+
## Build Commands
89+
90+
```bash
91+
# Build everything (UI + Antora + API docs)
92+
npm run build:docs
93+
94+
# Build just API documentation
95+
npm run build:api-docs
96+
97+
# Development server with auto-rebuild
98+
npm run start:dev
99+
```
100+
101+
## Configuration and Customization
102+
103+
### API v1 Customization
104+
105+
- Edit files directly in `api-v1/` directory
106+
- Changes appear immediately on next build
107+
- Maintains complete static site structure
108+
109+
### API v2 Customization
110+
111+
- **Content**: Edit `openapi-patch.json` to modify the API spec
112+
- **Styling**: Modify Redocly CLI build command arguments
113+
- **Processing**: Edit pipeline steps in `gulp.d/tasks/build-api-docs.js`
114+
115+
### JSON Patching System
116+
117+
The `openapi-patch.json` file allows customizing the live CircleCI API spec:
118+
119+
```json
120+
{
121+
"info": {
122+
"description": "Custom description override"
123+
},
124+
"paths": {
125+
"/custom-endpoint": {
126+
"get": {
127+
"summary": "Added custom endpoint"
128+
}
129+
}
130+
}
131+
}
132+
```
133+
134+
## Dependencies
135+
136+
### Required
137+
138+
- `@redocly/cli`: OpenAPI processing and doc generation
139+
- `jq`: JSON processing (system dependency for patching)
140+
- `curl`: API fetching (system dependency)
141+
142+
### Development
143+
144+
- Redocly CLI automatically rebuilds during development
145+
- File watching triggers rebuilds for both versions
146+
- Browser auto-reloads when documentation changes
147+
148+
## Troubleshooting
149+
150+
### Common Issues
151+
152+
1. **Build failures**: Check network connectivity for v2 API fetching
153+
2. **Missing v1 docs**: Ensure `api-v1/` directory exists with content
154+
3. **Patch errors**: Validate `openapi-patch.json` syntax with `jq`
155+
4. **Navigation issues**: Check relative paths in Antora content files
156+
157+
### Debug Commands
158+
159+
```bash
160+
# Test API v2 endpoint accessibility
161+
curl -s https://circleci.com/api/v2/openapi.json | head
162+
163+
# Validate patch file syntax
164+
jq . openapi-patch.json
165+
166+
# Lint API specification
167+
npx @redocly/cli lint [path-to-spec]
168+
169+
# Build API docs in isolation
170+
gulp build:api-docs
171+
```
172+
173+
### Build Logs
174+
175+
The build process provides detailed logging:
176+
177+
- ✅ Success indicators for each pipeline step
178+
- ⚠️ Warnings for non-critical issues (continues build)
179+
- ❌ Errors that halt the build process
180+
- 📁 File operation details and sizes
181+
182+
## Development Workflow
183+
184+
### Adding New API Versions
185+
186+
1. Create `buildApiV3()` function in `build-api-docs.js`
187+
2. Add directory creation logic
188+
3. Update main build orchestration
189+
4. Add navigation links to UI templates
190+
5. Update Antora content files
191+
192+
### Modifying Build Pipeline
193+
194+
1. Edit `gulp.d/tasks/build-api-docs.js`
195+
2. Test with `npm run build:api-docs`
196+
3. Verify output in `build/api/` directories
197+
4. Check integration with `npm run start:dev`
198+
199+
### CI/CD Integration
200+
201+
The build integrates with existing CircleCI pipeline:
202+
203+
- No additional CI configuration needed
204+
- API docs build as part of main site build
205+
- Both versions deploy together to production
206+
- Automatic updates when CircleCI API changes (v2)
207+
208+
## Performance Notes
209+
210+
- **API v1**: Fast build (~1 second, file copying)
211+
- **API v2**: Slower build (~30 seconds, network + processing)
212+
- **Output sizes**: v1 maintains original assets, v2 generates 1.6MB HTML
213+
- **Caching**: v2 uses temporary files for efficient rebuilds
214+
- **Development**: Hot reload works for both versions

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This technical documentation consists of several specialized files:
2828
| [DEVELOPMENT.md](DEVELOPMENT.md) | Development setup and workflows |
2929
| [CONTENT_AUTHORING.md](CONTENT_AUTHORING.md) | Writing and formatting guidelines |
3030
| [TECHNICAL_REFERENCE.md](TECHNICAL_REFERENCE.md) | Detailed technical specifications |
31+
| [API_DOCS_INTEGRATION.md](API_DOCS_INTEGRATION.md) | API documentation integration guide |
3132
| [CONTRIBUTING.md](CONTRIBUTING.md) | Guidelines for contributors |
3233

3334
## Getting Started
@@ -51,6 +52,32 @@ This technical documentation consists of several specialized files:
5152
npm run start:dev
5253
```
5354

55+
4. **Test the setup** (optional):
56+
```bash
57+
./scripts/test-setup.sh
58+
```
59+
60+
### For API Documentation
61+
62+
This project includes integrated API documentation built with Redocly:
63+
64+
1. **Test the integration**:
65+
```bash
66+
./scripts/test-setup.sh
67+
```
68+
69+
2. **Build API docs**:
70+
```bash
71+
npm run build:api-docs
72+
```
73+
74+
3. **Customize API docs**:
75+
- Replace `api-spec.yaml` with your OpenAPI specification
76+
- Edit `redocly.yaml` for styling and configuration
77+
- See [API_DOCS_INTEGRATION.md](API_DOCS_INTEGRATION.md) for details
78+
79+
### Technical Reference
80+
5481
3. **Review the architecture**:
5582
- Read [ARCHITECTURE.md](ARCHITECTURE.md) for system design
5683
- Review [DEVELOPMENT.md](DEVELOPMENT.md) for development workflow

api-v1/fonts/slate.eot

1.83 KB
Binary file not shown.

api-v1/fonts/slate.svg

Lines changed: 14 additions & 0 deletions
Loading

api-v1/fonts/slate.ttf

1.68 KB
Binary file not shown.

api-v1/fonts/slate.woff

1.75 KB
Binary file not shown.

api-v1/fonts/slate.woff2

796 Bytes
Binary file not shown.

api-v1/images/circle-logo-api.svg

Lines changed: 34 additions & 0 deletions
Loading

api-v1/images/favicon.ico

97.7 KB
Binary file not shown.

api-v1/images/favicon.ico.png

2.44 KB
Loading

0 commit comments

Comments
 (0)