diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 617f27a0cb75..d574c9880c32 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -113,6 +113,10 @@ jobs: working-directory: bindings/nodejs run: pnpm install --frozen-lockfile + - name: Build docs theme + working-directory: bindings/nodejs + run: pnpm run build:theme + - name: Build bindings/nodejs Docs working-directory: bindings/nodejs run: pnpm run docs diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index d94bbe3046ad..820a87f057e0 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -52,6 +52,7 @@ "@swc-node/register": "^1.6.2", "@swc/core": "^1.3.38", "@types/node": "^18.14.5", + "@types/react": "^18.2.48", "benny": "^3.7.1", "dotenv": "^16.0.3", "prettier": "^2.8.4", @@ -65,6 +66,7 @@ "scripts": { "build": "napi build --platform --features \"${NAPI_FEATURES:-}\" --target \"${NAPI_TARGET:-}\" --release --js generated.js --dts generated.d.ts && node ./scripts/header.js", "build:debug": "napi build --platform --features \"${NAPI_FEATURES:-}\" --target \"${NAPI_TARGET:-}\" --js generated.js --dts generated.d.ts && node ./scripts/header.js", + "build:theme": "tsc -p ./tsconfig.theme.json", "docs": "typedoc", "format": "prettier --write .", "test": "vitest", @@ -75,7 +77,7 @@ "prettier": { "overrides": [ { - "files": "./**/*.{js,ts,mjs}", + "files": "./**/*.{js,ts,mjs,jsx,tsx}", "options": { "arrowParens": "always", "parser": "typescript", diff --git a/bindings/nodejs/pnpm-lock.yaml b/bindings/nodejs/pnpm-lock.yaml index 0ec994c052f7..f8570bc03028 100644 --- a/bindings/nodejs/pnpm-lock.yaml +++ b/bindings/nodejs/pnpm-lock.yaml @@ -20,6 +20,9 @@ devDependencies: '@types/node': specifier: ^18.14.5 version: 18.19.3 + '@types/react': + specifier: ^18.2.48 + version: 18.2.48 benny: specifier: ^3.7.1 version: 3.7.1 @@ -1581,6 +1584,22 @@ packages: undici-types: 5.26.5 dev: true + /@types/prop-types@15.7.11: + resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} + dev: true + + /@types/react@18.2.48: + resolution: {integrity: sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w==} + dependencies: + '@types/prop-types': 15.7.11 + '@types/scheduler': 0.16.8 + csstype: 3.1.3 + dev: true + + /@types/scheduler@0.16.8: + resolution: {integrity: sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==} + dev: true + /@vitest/expect@0.34.6: resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==} dependencies: @@ -1763,6 +1782,10 @@ packages: engines: {node: '>=4.0.0'} dev: true + /csstype@3.1.3: + resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + dev: true + /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} diff --git a/bindings/nodejs/theme/index.tsx b/bindings/nodejs/theme/index.tsx new file mode 100644 index 000000000000..1f82e4577b14 --- /dev/null +++ b/bindings/nodejs/theme/index.tsx @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { DefaultTheme, PageEvent, Reflection, Options, DefaultThemeRenderContext, Application, JSX } from 'typedoc' + +export class FooterWithASFCopyright extends DefaultThemeRenderContext { + constructor(theme: DefaultTheme, page: PageEvent, options: Options) { + super(theme, page, options) + + this.footer = () => { + return ( + <> +
+

+ Copyright © 2022-2024, The Apache Software Foundation Apache OpenDAL, OpenDAL, Apache, Apache Incubator, + the Apache feather, the Apache Incubator logo and the Apache OpenDAL project logo are either registered + trademarks or trademarks of the Apache Software Foundation. +

+
+ + ) as unknown as JSX.Element + } + } +} + +export class FooterOverrideTheme extends DefaultTheme { + private _contextCache?: FooterWithASFCopyright + + override getRenderContext(pageEvent: PageEvent): FooterWithASFCopyright { + this._contextCache ||= new FooterWithASFCopyright(this, pageEvent, this.application.options) + + return this._contextCache + } +} + +export function load(app: Application) { + app.renderer.defineTheme('opendal', FooterOverrideTheme) +} diff --git a/bindings/nodejs/tsconfig.json b/bindings/nodejs/tsconfig.json index 59d4898adafe..b420b5189094 100644 --- a/bindings/nodejs/tsconfig.json +++ b/bindings/nodejs/tsconfig.json @@ -10,5 +10,5 @@ "allowSyntheticDefaultImports": true }, "include": ["."], - "exclude": ["node_modules", "benchmark"] + "exclude": ["node_modules", "benchmark", "theme"] } diff --git a/bindings/nodejs/tsconfig.theme.json b/bindings/nodejs/tsconfig.theme.json new file mode 100644 index 000000000000..1948e88b442b --- /dev/null +++ b/bindings/nodejs/tsconfig.theme.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "strict": true, + "esModuleInterop": true, + "outDir": "theme/dist", + + "jsx": "react", + "jsxFactory": "JSX.createElement", + "jsxFragmentFactory": "JSX.Fragment" + }, + "include": ["theme"] +} diff --git a/bindings/nodejs/typedoc.json b/bindings/nodejs/typedoc.json index bffcecb71394..651a1675ed06 100644 --- a/bindings/nodejs/typedoc.json +++ b/bindings/nodejs/typedoc.json @@ -8,6 +8,8 @@ "excludeExternals": true, "includeVersion": true, "githubPages": false, + "plugin": ["./theme/dist/index.js"], + "theme": "opendal", "navigationLinks": { "Homepage": "https://opendal.apache.org/", "GitHub": "https://github.com/apache/incubator-opendal/tree/main/bindings/nodejs"