From cc13e94bb3cf050c3fc4b45ffccb6d08f0c7a2e0 Mon Sep 17 00:00:00 2001 From: Maxi Date: Wed, 27 Mar 2024 15:29:34 +0100 Subject: [PATCH] chore: improved rpc docs co-author: @Eligioo --- .npmrc | 4 - .vitepress/config.ts | 53 +- .vitepress/scripts/rpc-docs.ts | 52 +- .vitepress/theme/MainLayout.vue | 2 - .vitepress/theme/components/Doc.vue | 2 +- .vitepress/theme/components/RegisterSW.vue | 4 +- .vitepress/uno.config.ts | 6 +- build/rpc-docs/index.md | 38 +- dev-dist/registerSW.js | 1 - dev-dist/suppress-warnings.js | 0 dev-dist/sw.js | 103 - dev-dist/workbox-7ee2d773.js | 1 - dev-dist/workbox-9e942ec3.js | 3499 -------------------- eslint.config.js | 2 +- package.json | 16 +- pnpm-lock.yaml | 2746 +++------------ tsconfig.json | 3 +- 17 files changed, 481 insertions(+), 6051 deletions(-) delete mode 100644 .npmrc delete mode 100644 dev-dist/registerSW.js delete mode 100644 dev-dist/suppress-warnings.js delete mode 100644 dev-dist/sw.js delete mode 100644 dev-dist/workbox-7ee2d773.js delete mode 100644 dev-dist/workbox-9e942ec3.js diff --git a/.npmrc b/.npmrc deleted file mode 100644 index a4edf86..0000000 --- a/.npmrc +++ /dev/null @@ -1,4 +0,0 @@ -shamefully-hoist=true -strict-peer-dependencies=false -auto-install-peers=true -public-hoist-pattern[]=workbox-window diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 0e6943b..c751427 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -1,10 +1,8 @@ import { existsSync, readFileSync } from 'node:fs' import { basename, dirname, join } from 'node:path' -import { env } from 'node:process' import { defineConfig } from 'vitepress' import container from 'markdown-it-container' import { spawn } from 'cross-spawn' -import { withPwa } from '@vite-pwa/vitepress' import { sidebar } from './sidebar.config' import { navigation } from './navigation.config' import { generateWebClientDocs } from './scripts/web-client' @@ -108,7 +106,7 @@ export default async () => { ['link', { rel: 'apple-touch-icon', sizes: '180x180', href: `${baseUrl}favicons/apple-touch-icon.png` }], ['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: `${baseUrl}favicons/favicon-32x32.png` }], ['link', { rel: 'icon', type: 'image/png', sizes: '16x16', href: `${baseUrl}favicons/favicon-16x16.png` }], - ['link', { rel: 'manifest', href: `${baseUrl}favicons/site.webmanifest` }], + // ['link', { rel: 'manifest', href: `${baseUrl}favicons/site.webmanifest` }], ['link', { rel: 'mask-icon', href: `${baseUrl}favicons/safari-pinned-tab.svg`, color: '#eaaf0c' }], ['link', { rel: 'shortcut icon', href: `${baseUrl}favicons/favicon.ico` }], ['meta', { name: 'msapplication-TileColor', content: '#2b5797' }], @@ -128,53 +126,10 @@ export default async () => { ['meta', { name: 'twitter:creator', content: '@nimiq' }], ['meta', { name: 'twitter:title', content: pkg.title }], ], - // pwa: { - // mode: env.DEPLOYMENT_ENV !== 'production' ? 'development' : 'production', - // disable: env.DEPLOYMENT_ENV !== 'production', - // scope: baseUrl, - // registerType: 'autoUpdate', - // injectRegister: 'script-defer', - // includeAssets: [`${baseUrl}favicons/favicon.svg`], - // manifest: { - // name: pkg.title, - // short_name: pkg.title, - // theme_color: '#ffffff', - // icons: [ - // { - // src: `${baseUrl}favicons/nimiq-hexagon-192.png`, - // sizes: '192x192', - // type: 'image/png', - // }, - // { - // src: `${baseUrl}favicons/nimiq-hexagon-512.png`, - // sizes: '512x512', - // type: 'image/png', - // }, - // { - // src: `${baseUrl}favicons/nimiq-hexagon-512.png`, - // sizes: '512x512', - // type: 'image/png', - // purpose: 'any maskable', - // }, - // ], - // }, - // workbox: { - // globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'], - // }, - // experimental: { - // includeAllowlist: true, - // }, - // devOptions: { - // enabled: env.DEPLOYMENT_ENV === 'production', - // type: 'module', - // suppressWarnings: true, - // navigateFallback: '/', - // }, - // }, - sitemap: { - hostname: 'https://onmax.github.io', - }, + // sitemap: { + // hostname: 'https://onmax.github.io', + // }, }) } diff --git a/.vitepress/scripts/rpc-docs.ts b/.vitepress/scripts/rpc-docs.ts index 8ea6703..0d05fb8 100644 --- a/.vitepress/scripts/rpc-docs.ts +++ b/.vitepress/scripts/rpc-docs.ts @@ -36,15 +36,14 @@ export async function generateRpcDocs() { // Build folder const buildFolder = join(__dirname, '../../build/rpc-docs') // Read package version of generated docs, if already built - const methodFile = join(buildFolder, '/method.md') + const methodFile = join(buildFolder, '/methods.md') if (existsSync(methodFile)) { - const re = /## Version: (\.*)/ + const re = /## Version: (.*)/ const content = readFileSync(methodFile, 'utf-8') const generatedVersion = re.exec(content)?.[1] - consola.info(`RPC specification docs ${packageVersion} already generated`) if (packageVersion === generatedVersion) { - consola.info(`RPC specification docs ${packageVersion} already generated`) + consola.info(`RPC docs ${packageVersion} already generated`) return } } @@ -59,45 +58,45 @@ export async function generateRpcDocs() { // - passphrase*: `String` // Returns: [ReturnAccount](#returnaccount) - const template = ` -
-
- -### {{ methodName }} + const template = `### \`{{ methodName }}\` + +{{ description }} -Parameters{.label .text-12 .text-neutral-800} +
+
+ +

Parameters

{{ parameters }} -Returns{.label .text-12 .text-neutral-800} +

Returns

{{ returns }}
-
- ::: code-group \`\`\`JavaScript -const options = { +const url = new URL('http://127.0.0.1:8648'); +const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: '{"jsonrpc":"2.0","method":"{{ methodName }}","params":[{{ parametersValues }}],"id":1}' -}; - -fetch('http://127.0.0.1:8648', options) - .then(response => response.json()) - .then(response => console.log(response)) - .catch(err => console.error(err)); + body: '{ + "jsonrpc":"2.0", + "method":"{{ methodName }}", + "params":[{{ parametersValues }}], + "id":1 + }' +}); +const data = await res.json(); \`\`\` \`\`\`Shell -curl --request POST \n - --url http://127.0.0.1:8648 \n - --header 'Content-Type: application/json' \n +curl --request POST --url http://127.0.0.1:8648 + --header 'Content-Type: application/json' --data '{ "jsonrpc": "2.0", "method": "{{ methodName }}", @@ -107,9 +106,7 @@ curl --request POST \n \`\`\` ::: -
-
-`.trim() +\n\n` function paramToValue(param: any) { switch (param.schema.type) { @@ -137,6 +134,7 @@ curl --request POST \n } const tmp = template .replaceAll('{{ methodName }}', method.name) + .replaceAll('{{ description }}', method.description) .replaceAll('{{ parameters }}', parameters) .replaceAll('{{ parametersValues }}', parametersValues) .replaceAll('{{ returns }}', resultProperties) diff --git a/.vitepress/theme/MainLayout.vue b/.vitepress/theme/MainLayout.vue index 0575c2a..ac31055 100644 --- a/.vitepress/theme/MainLayout.vue +++ b/.vitepress/theme/MainLayout.vue @@ -1,10 +1,8 @@