Skip to content

Commit

Permalink
Create Docs Site (#44)
Browse files Browse the repository at this point in the history
* feat: setup vitepress docs

* feat: add FedimintWallet docs

* chore: change precommit hook to lint:fix

* chore: updated typedoc command

* feat: add github pages job for docs site

* chore: add changeset

* fix: base url
  • Loading branch information
alexlwn123 authored Sep 26, 2024
1 parent 451b025 commit 20a2783
Show file tree
Hide file tree
Showing 45 changed files with 3,305 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-flowers-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fedimint/core-web': patch
---

Added a docs website powered by vitepress
60 changes: 60 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy Docs site to Pages

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [main]
paths: ['docs/**']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled

- name: Install dependencies
uses: ./.github/actions/install-deps

- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm i
- name: Build with VitePress
run: pnpm run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
8 changes: 5 additions & 3 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Deploy Vite-Core Example to GitHub Pages

on:
push:
branches: ['main']
paths: ['packages/core-web/**', 'examples/vite-core/**']
# Using github pages for docs instead of preview

# push:
# branches: ['main']
# paths: ['packages/core-web/**', 'examples/vite-core/**']
workflow_dispatch:

permissions:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ tsconfig.tsbuildinfo
/blob-report/
/playwright/.cache/

__screenshots__
__screenshots__

docs/.vitepress/dist
docs/.vitepress/cache
81 changes: 81 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { getSidebar } from './sidebar'
import { withMermaid } from 'vitepress-plugin-mermaid'

// https://vitepress.dev/reference/site-config
export default withMermaid({
title: 'Fedimint Web Sdk',
description: 'Building Fedimint Ecash into the web',
ignoreDeadLinks: false,
lang: 'en-US',
lastUpdated: true,
base: '/fedimint-web-sdk/',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
editLink: {
pattern:
'https://github.com/fedimint/fedimint-web-sdk/edit/main/docs/:path',
text: 'Suggest changes to this page',
},
footer: {
message:
'Released under the <a href="https://github.com/fedimint/fedimint-web-sdk/blob/main/LICENSE">MIT License</a>.',
},
nav: [
{ text: 'Home', link: '/' },
{ text: 'Core', link: '/core/getting-started' },
{ text: 'Packages', link: '/packages' },
{ text: 'Examples', link: '/examples' },
{
text: 'More',
items: [
{
text: 'Contributing',
link: '/dev/contributing',
},
{
text: 'Discussions ',
link: 'https://chat.fedimint.org',
},
{
text: 'Release Notes ',
link: 'https://github.com/fedimint/fedimint-web-sdk/releases',
},
],
},
],
logo: {
light: '/icon.png',
dark: '/icon.png',
alt: 'Fedimint Logo',
},
sidebar: getSidebar(),

socialLinks: [
{
icon: 'github',
link: 'https://github.com/fedimint/fedimint-web-sdk',
},
{
icon: 'discord',
link: 'https://chat.fedimint.org',
},
{
icon: 'twitter',
link: 'https://twitter.com/fedimint',
},
],

outline: [2, 3],
search: {
provider: 'local',
options: {
_render(src, env, md) {
const html = md.render(src, env)
if (env.frontmatter?.search === false) return ''
if (env.relativePath.startsWith('shared')) return ''
return html
},
},
},
},
})
38 changes: 38 additions & 0 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { DefaultTheme } from 'vitepress'
import typedocSidebar from '../core/api/typedoc-sidebar.json'

export function getSidebar() {
return {
'/core/': [
{
text: 'Getting Started',
items: [
{ text: 'Overview', link: '/core/getting-started' },
{ text: 'Installation', link: '/core/installation' },
{ text: 'Architecture', link: '/core/architecture' },
],
},
{
text: 'API',
link: '/core/api/index.md',
items: typedocSidebar,
},
{
text: 'TEMP',
items: [
{ text: 'Markdown Examples', link: '/temp/markdown-examples' },
{ text: 'Runtime API Examples', link: '/temp/api-examples' },
],
},
],
'/dev/': [
{
text: 'Dev',
items: [
{ text: 'Contributing', link: '/dev/contributing' },
{ text: 'Testing', link: '/dev/testing' },
],
},
],
} satisfies DefaultTheme.Sidebar
}
48 changes: 48 additions & 0 deletions docs/core/api/FedimintWallet/constructor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Constructor: FedimintWallet

Creates a new instance of FedimintWallet.

### new FedimintWallet()

> **new FedimintWallet**(`lazy`): [`FedimintWallet`]()
This constructor initializes a FedimintWallet instance, which manages communication
with a Web Worker. The Web Worker is responsible for running WebAssembly code that
handles the core Fedimint Client operations.

(default) When not in lazy mode, the constructor immediately initializes the
Web Worker and begins loading the WebAssembly module in the background. This
allows for faster subsequent operations but may increase initial load time.

In lazy mode, the Web Worker and WebAssembly initialization are deferred until
the first operation that requires them, reducing initial overhead at the cost
of a slight delay on the first operation.

#### Parameters

**lazy**: `boolean` = `false`

If true, delays Web Worker and WebAssembly initialization
until needed. Default is false.

#### Returns

[`FedimintWallet`](constructor.md)

#### Example

```ts
// Create a wallet with immediate initialization
const wallet = new FedimintWallet()
wallet.open()

// Create a wallet with lazy initialization
const lazyWallet = new FedimintWallet(true)
// Some time later...
lazyWallet.initialize()
lazyWallet.open()
```

#### Defined in

[FedimintWallet.ts:63](https://github.com/fedimint/fedimint-web-sdk/blob/451b02527305a23fec3a269d39bde9a3ec377df2/packages/core-web/src/FedimintWallet.ts#L63)
Loading

0 comments on commit 20a2783

Please sign in to comment.