Skip to content

Commit

Permalink
docs: add typedoc generation and GH Pages publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Oct 24, 2024
1 parent 9fdb692 commit 1fced85
Show file tree
Hide file tree
Showing 7 changed files with 484 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Setup PNPM Project Environment
description: Configure the environment with the essentials (node, pnpm etc.)

inputs:
node-version:
description: "Node version to use to setup environment."
default: 20
pnpm-version:
description: "Version of pnpm to install."
default: 9
working-directory:
description: "Working directory to setup environment in."
default: "${{ github.workspace }}"

runs:
using: composite
steps:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version || '' }}
registry-url: "https://registry.npmjs.org"

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: ${{ inputs.pnpm-version || '' }}
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: "${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: ${{inputs.working-directory}}
shell: bash
run: pnpm install
69 changes: 69 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Generate Documentation

on:
push:
branches: ["main"]
paths:
- src/**
- package.json
- .github/workflows/docs.yaml
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup build environment
uses: ./.github/actions/setup

- name: Generate documentation
shell: bash
run: pnpm run build:docs

- name: Archive documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: |
docs/
deploy:
name: Deploy Documentation
needs: build
if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

permissions:
contents: read
pages: write
id-token: write

runs-on: ubuntu-latest
steps:
- name: Download generated documentation
uses: actions/download-artifact@v4
with:
name: docs

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# typedoc
docs/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pnpm-lock.yaml
package-lock.json
yarn.locl
docs/**
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"types": "build/index.d.ts",
"scripts": {
"build": "tsc",
"build:docs": "npx typedoc",
"test": "nyc mocha",
"format": "prettier -w -u .",
"lint": "eslint .",
Expand All @@ -46,6 +47,7 @@
"nock": "^13.3.8",
"nyc": "^15.1.0",
"prettier": "^3.1.0",
"typedoc": "^0.26.10",
"typescript": "^5.2.2"
},
"lint-staged": {
Expand Down
Loading

0 comments on commit 1fced85

Please sign in to comment.