Skip to content

Commit 7fdfe1f

Browse files
Set up GitHub Pages for documentation hosting
1 parent 7e633a4 commit 7fdfe1f

File tree

6 files changed

+160
-41
lines changed

6 files changed

+160
-41
lines changed

.github/workflows/pages.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Setup Pages
27+
uses: actions/configure-pages@v3
28+
- name: Upload artifact
29+
uses: actions/upload-pages-artifact@v1
30+
with:
31+
path: './docs'
32+
- name: Deploy to GitHub Pages
33+
id: deployment
34+
uses: actions/deploy-pages@v1

README.md

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,95 @@
1-
# OpenAPI to DocC Symbol Graph
1+
# OpenAPI Integration with DocC
22

3-
A tool to convert OpenAPI documents into DocC symbol graphs, enabling seamless integration of API documentation with Swift's DocC documentation system.
3+
This project provides tools and examples for integrating OpenAPI specifications with Apple's DocC documentation system. It allows developers to create beautiful, interactive documentation for REST APIs that matches the style and quality of Swift API documentation.
44

5-
## Features
5+
## Overview
66

7-
- Converts OpenAPI documents (JSON/YAML) to DocC symbol graphs
8-
- Supports all HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
9-
- Generates comprehensive documentation for:
10-
- API endpoints
11-
- Request parameters
12-
- Request bodies
13-
- Response types
14-
- Preserves OpenAPI descriptions and metadata
15-
- Command-line interface for easy integration
7+
OpenAPI is the industry standard for documenting HTTP services, but Swift developers are already familiar with DocC for their Swift and Objective-C API documentation. This project bridges that gap by converting OpenAPI specifications into a format that DocC can understand and render.
168

17-
## Installation
9+
## Key Features
1810

19-
### Requirements
11+
- Convert OpenAPI 3.1.0 specifications to DocC-compatible format
12+
- Generate beautiful API documentation
13+
- Provide a consistent documentation experience for Swift developers
14+
- Support for documenting endpoints, schemas, parameters, and more
2015

21-
- Swift 5.7 or later
22-
- macOS 12.0 or later
16+
## Getting Started
2317

24-
### Building from Source
18+
### Prerequisites
19+
20+
- Xcode 15.0 or later
21+
- Swift 6.0 or later
22+
- Python 3 (for local documentation serving)
23+
24+
### Installation
2525

26-
1. Clone the repository:
2726
```bash
28-
git clone https://github.com/yourusername/OpenAPItoSymbolGraph.git
29-
cd OpenAPItoSymbolGraph
27+
git clone https://github.com/ayushshrivastv/OpenAPI-integration-with-DocC.git
28+
cd OpenAPI-integration-with-DocC
29+
swift build
3030
```
3131

32-
2. Build the package:
32+
### Usage
33+
34+
1. Convert your OpenAPI specification to a SymbolGraph:
35+
3336
```bash
34-
swift build -c release
37+
swift run openapi-to-symbolgraph path/to/your/api.yaml --output-path api.symbolgraph.json
3538
```
3639

37-
3. The executable will be available at `.build/release/openapi-to-symbolgraph`
40+
2. Create a DocC documentation catalog (see `API.docc` as an example)
3841

39-
## Usage
42+
3. Generate the documentation:
4043

4144
```bash
42-
openapi-to-symbolgraph <input-path> [--output-directory <directory>] [--output-file <filename>]
45+
xcrun docc convert YourAPI.docc --fallback-display-name YourAPI --fallback-bundle-identifier com.example.YourAPI --fallback-bundle-version 1.0.0 --additional-symbol-graph-dir ./ --output-path ./docs
4346
```
4447

45-
### Arguments
48+
## Viewing the Documentation
49+
50+
### Online Documentation
51+
52+
The latest documentation is automatically deployed to GitHub Pages and can be viewed at:
53+
54+
[https://ayushshrivastv.github.io/OpenAPI-integration-with-DocC/](https://ayushshrivastv.github.io/OpenAPI-integration-with-DocC/)
55+
56+
### Local Documentation Server
4657

47-
- `input-path`: Path to the OpenAPI document (JSON or YAML)
48-
- `--output-directory`: Directory where the symbol graph will be saved (default: current directory)
49-
- `--output-file`: Name of the output file (default: openapi.symbolgraph.json)
58+
You can serve the documentation locally using one of these methods:
5059

51-
### Example
60+
#### Using the helper script:
5261

5362
```bash
54-
openapi-to-symbolgraph api.yaml --output-directory docs --output-file api.symbolgraph.json
63+
./serve-docs.sh
5564
```
5665

57-
## Integration with DocC
66+
#### Using Python 3 directly:
5867

59-
1. Generate the symbol graph:
6068
```bash
61-
openapi-to-symbolgraph api.yaml
69+
python3 -m http.server 8000 --directory docs
6270
```
6371

64-
2. Add the symbol graph to your DocC documentation:
65-
```swift
66-
import DocC
72+
Then open your browser to http://localhost:8000
6773

68-
let documentation = Documentation(
69-
symbolGraphs: ["openapi.symbolgraph.json"]
70-
)
71-
```
74+
## Example
75+
76+
Check out the `DocsExample` directory for a working example of a REST API documented with DocC. It showcases how endpoints, schemas, and examples appear in the DocC format.
77+
78+
## How It Works
79+
80+
1. The OpenAPI specification is parsed using `OpenAPIKit`
81+
2. The specification is converted to a SymbolGraph, which is the format DocC uses for documentation
82+
3. DocC processes the SymbolGraph and generates the documentation
83+
4. The documentation can be served as a static website or deployed to GitHub Pages
84+
85+
## GitHub Pages Deployment
86+
87+
This repository is configured to automatically deploy documentation to GitHub Pages whenever changes are pushed to the main branch. The deployment process:
88+
89+
1. Uses the GitHub Actions workflow defined in `.github/workflows/pages.yml`
90+
2. Takes the contents of the `docs` directory
91+
3. Deploys them to GitHub Pages
92+
4. Makes the documentation available at the URL: [https://ayushshrivastv.github.io/OpenAPI-integration-with-DocC/](https://ayushshrivastv.github.io/OpenAPI-integration-with-DocC/)
7293

7394
## Contributing
7495

docs/.nojekyll

Whitespace-only changes.

docs/404.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Page Not Found - API Documentation</title>
7+
<style>
8+
body {
9+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
10+
line-height: 1.6;
11+
color: #333;
12+
max-width: 800px;
13+
margin: 0 auto;
14+
padding: 40px 20px;
15+
text-align: center;
16+
}
17+
h1 {
18+
color: #0066cc;
19+
font-size: 36px;
20+
margin-bottom: 20px;
21+
}
22+
p {
23+
font-size: 18px;
24+
margin-bottom: 30px;
25+
}
26+
a {
27+
color: #0066cc;
28+
text-decoration: none;
29+
}
30+
a:hover {
31+
text-decoration: underline;
32+
}
33+
</style>
34+
</head>
35+
<body>
36+
<h1>Page Not Found</h1>
37+
<p>The documentation page you're looking for doesn't exist or has been moved.</p>
38+
<p><a href="/OpenAPI-integration-with-DocC/">Return to Documentation Home</a></p>
39+
</body>
40+
</html>

docs/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
baseurl: "/OpenAPI-integration-with-DocC"
2+
url: "https://ayushshrivastv.github.io"

serve-docs.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Script to serve the documentation locally
3+
4+
# Check if python3 is available
5+
if command -v python3 &> /dev/null; then
6+
echo "Starting server with python3..."
7+
python3 -m http.server 8000 --directory docs
8+
# Check if python is available as a fallback
9+
elif command -v python &> /dev/null; then
10+
# Check Python version to ensure it's Python 3
11+
PYTHON_VERSION=$(python --version 2>&1)
12+
if [[ $PYTHON_VERSION == *"Python 3"* ]]; then
13+
echo "Starting server with python..."
14+
python -m http.server 8000 --directory docs
15+
else
16+
echo "Error: Python 3 is required to run the server."
17+
exit 1
18+
fi
19+
else
20+
echo "Error: Python 3 is not installed. Please install Python 3 to run the server."
21+
exit 1
22+
fi

0 commit comments

Comments
 (0)