Skip to content

Commit

Permalink
feat: ✨ typedoc integration added
Browse files Browse the repository at this point in the history
This will build docs automatically on CI and commit the changes back to the repository
  • Loading branch information
AkashRajpurohit committed Mar 25, 2024
1 parent ce41c1f commit 0a167cd
Show file tree
Hide file tree
Showing 18 changed files with 1,817 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Release

on: [push, workflow_dispatch]
name: CI

on:
push:
branches:
- main
- feat/*
- fix/*
paths-ignore:
- docs/**
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -77,8 +85,8 @@ jobs:
path: coverage/

release:
# Release only when code is pushed to main branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
# Release only when code is pushed to main branch and [skip ci] is not present
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip ci]')}}
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
Expand Down Expand Up @@ -129,3 +137,54 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm semantic-release

build_docs:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
needs: [release]
steps:
- name: Checkout 🧳
uses: actions/checkout@v4

- name: Install Node.js 🔥
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm 👀
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory 🏪
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache 💰
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies ⏬
run: pnpm install --no-frozen-lockfile

- name: Build Docs ⏰
run: pnpm build:docs

- name: Commit and Push 🚀
if: always()
uses: stefanzweifel/[email protected]
with:
commit_message: 'docs: :rocket: docs updated [skip ci]'
commit_user_name: FindingAkash
commit_user_email: [email protected]
commit_author: FindingAkash <[email protected]>
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<h3 align="center">A project template to bootstrap NPM package with Typescript</h3>
<br />
<p align="center">
<a href="https://github.com/AkashRajpurohit/ts-npm-template/actions/workflows/test-and-release.yml">
<img alt="Build states" src="https://github.com/AkashRajpurohit/ts-npm-template/actions/workflows/test-and-release.yml/badge.svg?branch=main">
<a href="https://github.com/AkashRajpurohit/ts-npm-template/actions/workflows/ci.yml">
<img alt="Build states" src="https://github.com/AkashRajpurohit/ts-npm-template/actions/workflows/ci.yml/badge.svg?branch=main">
</a>
<a href="https://www.npmjs.com/package/@akashrajpurohit/ts-npm-template">
<img alt="npm latest version" src="https://img.shields.io/npm/v/@akashrajpurohit/ts-npm-template/latest.svg">
Expand All @@ -26,6 +26,8 @@
<a href="https://github.com/AkashRajpurohit/ts-npm-template/issues/new?template=bug_report.md">Bug report</a>
·
<a href="https://github.com/AkashRajpurohit/ts-npm-template/issues/new?template=feature_request.md">Feature request</a>
·
<a href="https://akashrajpurohit.github.io/ts-npm-template">Read Docs</a>
</p>
</p>
<br />
Expand Down Expand Up @@ -55,7 +57,7 @@ If you want to generate a code coverage badge for your package, you need to foll

You need to add the `GIST_SECRET` in the [github actions secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) if you are planning to add the code coverage badge.

Once you have followed the steps above and created a gist, uncomment these lines in the [workflow file](./.github/workflows/test-and-release.yml)
Once you have followed the steps above and created a gist, uncomment these lines in the [workflow file](./.github/workflows/ci.yml)

```
- name: Get Coverage for badge 🔢
Expand All @@ -75,13 +77,22 @@ Once you have followed the steps above and created a gist, uncomment these lines
namedLogo: vitest
```

> Note: Make sure you change the `<gist-id>` and `<file-name>` in the [test-and-release.yml](./.github/workflows/test-and-release.yml) file along with the gist id in the coverage badge link in the README.md file.
> Note: Make sure you change the `<gist-id>` and `<file-name>` in the [ci.yml](./.github/workflows/ci.yml) file along with the gist id in the coverage badge link in the README.md file.
## Auto generate docs 📚

The project is configured to auto-generate the documentation using [typedoc](https://typedoc.org/). The documentation is generated in the `docs` folder.

You can enable github pages to serve the documentation by following the steps mentioned in the [github pages documentation](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).

As part of the CI pipeline, the documentation is generated and pushed to the `main` branch with `[skip ci]` commit message so the new release is not triggered. The commit is generated from the Github user `FindingAkash` which is a bot user. You can change the user by updating the [workflow file](./.github/workflows/ci.yml).

## Technology Stack 🚀
## Technology stack 🚀

- 🙏🏾 [Typescript](https://www.typescriptlang.org/) with [tsup](https://tsup.egoist.dev/) build tool.
- ⚡️ [Vitest](https://vitest.dev/) - Unit Test Framework
- 📦 [Semantic Release](https://semantic-release.gitbook.io/semantic-release/) - Fully automated version management and package publishing.
- 📖 [Typedoc](https://typedoc.org/) - Generate documentation of your package.
- 🔀 [Github Actions](https://github.com/features/actions) - CI pipelines
- 💪 [PNPM](https://pnpm.io/) - Package manager

Expand Down
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
92 changes: 92 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
:root {
--light-hl-0: #000000;
--dark-hl-0: #D4D4D4;
--light-hl-1: #000000;
--dark-hl-1: #C8C8C8;
--light-hl-2: #001080;
--dark-hl-2: #9CDCFE;
--light-hl-3: #0070C1;
--dark-hl-3: #4FC1FF;
--light-hl-4: #A31515;
--dark-hl-4: #CE9178;
--light-hl-5: #098658;
--dark-hl-5: #B5CEA8;
--light-hl-6: #AF00DB;
--dark-hl-6: #C586C0;
--light-hl-7: #267F99;
--dark-hl-7: #4EC9B0;
--light-hl-8: #795E26;
--dark-hl-8: #DCDCAA;
--light-hl-9: #008000;
--dark-hl-9: #6A9955;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
pre, code { background: var(--code-background); }
Loading

0 comments on commit 0a167cd

Please sign in to comment.