Skip to content

Commit 46d0cf7

Browse files
SgtPookiCopilot
andauthored
docs: generate api docs and publish to gh pages (#260)
* docs: generate api docs and publish to gh pages * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * fix: typedoc warnings are addressed * fix: correct type exports --------- Co-authored-by: Copilot <[email protected]>
1 parent 70dd804 commit 46d0cf7

File tree

14 files changed

+123
-25
lines changed

14 files changed

+123
-25
lines changed

.github/workflows/docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v5
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: 'lts/*'
29+
cache: 'npm'
30+
31+
- name: Install Dependencies
32+
run: npm install --no-progress
33+
34+
- name: Build TypeScript
35+
run: npm run build
36+
37+
- name: Generate API Documentation
38+
run: npm run docs
39+
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v5
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: './docs/api'
47+
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package-lock.json
44
boxo/
55
kubo/
66
dist/
7+
docs/
78
.vite/
89
*.car
910
test-output/

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,20 @@ Upload IPFS files directly to Filecoin via the command line. Perfect for develop
4343
### GitHub Action
4444
Automatically publish websites or build artifacts to IPFS and Filecoin as part of your CI/CD pipeline. Ideal for static websites, documentation sites, and automated deployment workflows.
4545

46-
- **Repository**: This repo ([see upload-action/](./upload-action))
46+
- **Repository**: This repo ([see upload-action/](./upload-action/README.md))
4747
- **Documentation**:
4848
- [GitHub Action Walkthrough](https://docs.filecoin.io/builder-cookbook/filecoin-pin/github-action)
4949
- **Example in Production**: [filecoin-pin-website CI pipeline](https://github.com/filecoin-project/filecoin-pin-website/tree/main/.github/workflows)
5050

51-
### JavaScript "core" Library
52-
Opinionated JavaScript library with utilities for common functionality across different use cases. Use these modules directly in your Node.js or browser applications.
51+
### JavaScript Library
52+
Use Filecoin Pin programmatically in your Node.js or browser applications. The library provides both a high-level API for common use cases and granular core modules for advanced customization.
5353

54-
- **Repository**: This repo (see [`src/core/`](./src/core) and package exports).
55-
- **Installation**: `npm install filecoin-pin`
56-
- **Exports**: Core modules for CAR files, payments, Synapse SDK integration, uploads, and UnixFS operations
54+
- **Repository**: This repo ([filecoin-project/filecoin-pin](https://github.com/filecoin-project/filecoin-pin))
55+
- **Documentation**:
56+
- [API Reference](https://filecoin-project.github.io/filecoin-pin/) (TypeDoc-generated documentation)
57+
- High-level API: `import { … } from 'filecoin-pin'` (recommended for most use cases)
58+
- Core modules: `import { … } from 'filecoin-pin/core/*'` (CAR files, payments, Synapse SDK, uploads, UnixFS)
59+
- **Installation**: `npm install --save filecoin-pin`
5760

5861
### IPFS Pinning Server (Daemon Mode)
5962
Run a localhost IPFS Pinning Service API server that implements the [IPFS Pinning Service API specification](https://ipfs.github.io/pinning-services-api-spec/). This allows you to use standard IPFS tooling (like `ipfs pin remote`) while storing data on Filecoin.
@@ -69,7 +72,7 @@ Web-based management console for monitoring and managing your Filecoin Pin deplo
6972
- **Tracking**: See [issue #74](https://github.com/filecoin-project/filecoin-pin/issues/74) for updates. Please leave a comment about your usecase if this would be particularly beneficial.
7073

7174
## Documentation
72-
See [/documentation](/documentation/).
75+
See [/documentation](/documentation/README.md).
7376

7477
## Examples
7578

@@ -285,10 +288,10 @@ Interested in contributing? Please read our [Contributing Guidelines](CONTRIBUTI
285288

286289
### Documentation
287290

288-
- **[documentation/](documentation/)** - (Coming Soon) Additional documentation about how filecoin-pin works, design decisions, etc.
291+
- **[documentation/](documentation/README.md)** - Additional documentation about how filecoin-pin works, design decisions, etc.
289292
- **[docs.filecoin.io](https://docs.filecoin.io/builder-cookbook/filecoin-pin)** - Filecoin Pin guides and tutorials
290293

291294

292295
## License
293296

294-
Dual-licensed under [MIT](LICENSE-MIT) + [Apache 2.0](LICENSE-APACHE)
297+
Dual-licensed under [MIT + Apache 2.0](LICENSE.md)

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"!**/__snapshots__",
3333
"!**/components.d.ts",
3434
"!**/mockServiceWorker.js",
35-
"!**/cars"
35+
"!**/cars",
36+
"!docs"
3637
]
3738
},
3839
"vcs": {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"lint": "tsc && biome check --no-errors-on-unmatched --files-ignore-unknown=true .",
8888
"lint:fix": "biome check --no-errors-on-unmatched --files-ignore-unknown=true --fix .",
8989
"typecheck": "tsc --noEmit",
90+
"docs": "typedoc",
9091
"prepublishOnly": "npm run build"
9192
},
9293
"repository": {
@@ -131,6 +132,7 @@
131132
"@vitest/coverage-v8": "^4.0.13",
132133
"playwright-chromium": "^1.56.1",
133134
"tsx": "^4.20.5",
135+
"typedoc": "^0.28.14",
134136
"typescript": "^5.9.2",
135137
"vitest": "^4.0.13"
136138
},

src/core/data-set/get-data-set-pieces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { METADATA_KEYS, type StorageContext, type Synapse, WarmStorageService }
1111
import { isStorageContextWithDataSetId } from './type-guards.js'
1212
import type {
1313
DataSetPiecesResult,
14+
DataSetWarning,
1415
GetDataSetPiecesOptions,
1516
PieceInfo,
1617
StorageContextWithDataSetId,
17-
Warning,
1818
} from './types.js'
1919

2020
/**
@@ -57,7 +57,7 @@ export async function getDataSetPieces(
5757
}
5858

5959
const pieces: PieceInfo[] = []
60-
const warnings: Warning[] = []
60+
const warnings: DataSetWarning[] = []
6161

6262
// Use the async generator to fetch all pieces
6363
try {
@@ -119,7 +119,7 @@ async function enrichPiecesWithMetadata(
119119
synapse: Synapse,
120120
storageContext: StorageContextWithDataSetId,
121121
pieces: PieceInfo[],
122-
warnings: Warning[],
122+
warnings: DataSetWarning[],
123123
logger?: GetDataSetPiecesOptions['logger']
124124
): Promise<void> {
125125
const dataSetId = storageContext.dataSetId

src/core/data-set/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export interface DataSetPiecesResult {
3838
/** Total size of all pieces in bytes (sum of individual piece sizes) */
3939
totalSizeBytes?: bigint
4040
/** Non-fatal warnings encountered during retrieval */
41-
warnings?: Warning[]
41+
warnings?: DataSetWarning[]
4242
}
4343

4444
/**
4545
* Structured warning for non-fatal issues
4646
*/
47-
export interface Warning {
47+
export interface DataSetWarning {
4848
/** Machine-readable warning code (e.g., 'METADATA_FETCH_FAILED') */
4949
code: string
5050
/** Human-readable warning message */

src/core/payments/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ export async function checkAllowances(synapse: Synapse): Promise<{
375375
}
376376
}
377377

378+
/**
379+
* Result of setting maximum allowances for WarmStorage
380+
*/
381+
export interface SetMaxAllowancesResult {
382+
/** Transaction hash of the allowance update */
383+
transactionHash: string
384+
/** Updated allowance status after the transaction */
385+
currentAllowances: ServiceApprovalStatus
386+
}
387+
378388
/**
379389
* Set WarmStorage allowances to maximum
380390
*
@@ -384,10 +394,7 @@ export async function checkAllowances(synapse: Synapse): Promise<{
384394
* @param synapse - Initialized Synapse instance
385395
* @returns Transaction hash and updated allowances
386396
*/
387-
export async function setMaxAllowances(synapse: Synapse): Promise<{
388-
transactionHash: string
389-
currentAllowances: ServiceApprovalStatus
390-
}> {
397+
export async function setMaxAllowances(synapse: Synapse): Promise<SetMaxAllowancesResult> {
391398
const warmStorageAddress = synapse.getWarmStorageAddress()
392399

393400
// Set to maximum allowances

src/core/unixfs/car-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { Logger } from 'pino'
1818
import { CARWritingBlockstore } from '../car/index.js'
1919

2020
// Spinner type for progress reporting
21-
type Spinner = {
21+
export type Spinner = {
2222
start(msg: string): void
2323
stop(msg: string): void
2424
message(msg: string): void

src/core/utils/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type AnyProgressEvent = { type: string; data?: unknown }
1+
export type AnyProgressEvent = { type: string; data?: unknown }
22

33
export type ProgressEvent<T extends string = string, D = undefined> = D extends undefined
44
? { type: T }

0 commit comments

Comments
 (0)