Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React, RN, Wallets, SDK, Storage] typedoc generation #1787

Merged
merged 11 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/gorgeous-paws-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@thirdweb-dev/react-native": patch
"@thirdweb-dev/react-core": patch
"@thirdweb-dev/storage": patch
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/react": patch
"@thirdweb-dev/sdk": patch
---

Enable typedoc for packages
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ playwright-report/
.env/

# Artifacts
packages/cli/artifacts/
packages/cli/artifacts/

typedoc
1 change: 1 addition & 0 deletions packages/react-core/src/core/constants/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/** @internal */
// eslint-disable-next-line turbo/no-undeclared-env-vars, better-tree-shaking/no-top-level-side-effects
export const __DEV__ = process.env.NODE_ENV !== "production";
5 changes: 4 additions & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"fix": "eslint src/ --fix",
"clean": "rm -rf dist/",
"build": "tsc",
"push": "yalc push"
"push": "yalc push",
"typedoc": "rimraf typedoc && node ./scripts/typedoc.js"
},
"keywords": [
"react-native",
Expand Down Expand Up @@ -79,6 +80,8 @@
"react-native-mmkv": "2.5.1",
"react-native-safe-area-context": "4.5.3",
"react-native-webview": "12.1.0",
"rimraf": "^3.0.2",
"typedoc": "^0.25.2",
"typescript": "^5.1.6"
},
"optionalDependencies": {
Expand Down
38 changes: 38 additions & 0 deletions packages/react-native/scripts/typedoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const TypeDoc = require("typedoc");

async function main() {
// Application.bootstrap also exists, which will not load plugins
// Also accepts an array of option readers if you want to disable
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
const app = await TypeDoc.Application.bootstrapWithPlugins({
entryPoints: ["src/index.ts"],
excludeInternal: true,
externalPattern: [
"**/node_modules/**",
"**/packages/sdk/**",
"**/packages/wallets/**",
"**/packages/chains/**",
],
exclude: [
"**/node_modules/**",
"**/packages/sdk/**",
"**/packages/wallets/**",
"**/packages/chains/**",
],
});

const project = await app.convert();

if (project) {
// Project may not have converted correctly
const outputDir = "typedoc/";

// Rendered docs
await app.generateDocs(project, outputDir);
// Alternatively generate JSON output
await app.generateJson(project, outputDir + "/documentation.json");
}
}

main();
5 changes: 4 additions & 1 deletion packages/react-native/src/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export { useMetaMaskWallet } from "./wallets/hooks/useMetaMaskWallet";
export { useRainbowWallet } from "./wallets/hooks/useRainbowWallet";
export { useTrustWallet } from "./wallets/hooks/useTrustWallet";

export { ConnectWallet } from "./components/ConnectWallet";
export {
ConnectWallet,
type ConnectWalletProps,
} from "./components/ConnectWallet";
export { Web3Button } from "./components/Web3Button";

// utilities
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/src/evm/utils/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ export function shortenWalletAddress(str?: string, extraShort = true) {
)}`;
}

/**
* This function shortens an address if it is a valid EVM address.
*
* @param address The address to shorten
* @param extraShort If true, show the first 4 and last 3 characters
* @returns The shortened address
* @example
* ```ts
* const address = shortenIfAddress("0x1234567890123456789012345678901234567890", true); // result will be "0x1234...890"
* ```
*/
export function shortenIfAddress(address?: string, extraShort?: true): string {
if (!address) {
return "";
Expand Down
5 changes: 4 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"generate-docs:evm": "api-extractor run --local --config ./config/api-extractor-evm.json && api-documenter markdown -i ./temp -o ./docs/evm && rm -rf ./temp-evm && mv ./temp ./temp-evm",
"generate-snippets": "node ./scripts/generate-snippets-evm.mjs && node ./scripts/generate-feature-snippets-evm.mjs",
"build": "tsc && preconstruct build",
"push": "yalc push"
"push": "yalc push",
"typedoc": "rimraf typedoc && node typedoc.js"
},
"sideEffects:": false,
"devDependencies": {
Expand Down Expand Up @@ -102,7 +103,9 @@
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.2",
"stream": "npm:stream-browserify@^3.0.0",
"typedoc": "^0.25.2",
"typescript": "^5.1.6"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/evm/constants/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/** @internal */
// eslint-disable-next-line turbo/no-undeclared-env-vars, better-tree-shaking/no-top-level-side-effects
export const __DEV__ = process.env.NODE_ENV !== "production";
5 changes: 4 additions & 1 deletion packages/react/src/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export {
export { useSafe } from "./connectors/gnosis";
export { useMagic } from "./connectors/magic";

export { ConnectWallet } from "../wallet/ConnectWallet/ConnectWallet";
export {
ConnectWallet,
type ConnectWalletProps,
} from "../wallet/ConnectWallet/ConnectWallet";
export { ConnectModalInline } from "../wallet/ConnectWallet/Modal/ConnectModalInline";

export { NetworkSelector } from "../wallet/ConnectWallet/NetworkSelector";
Expand Down
39 changes: 39 additions & 0 deletions packages/react/typedoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires, better-tree-shaking/no-top-level-side-effects
const TypeDoc = require("typedoc");

async function main() {
// Application.bootstrap also exists, which will not load plugins
// Also accepts an array of option readers if you want to disable
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
const app = await TypeDoc.Application.bootstrapWithPlugins({
entryPoints: ["src/index.ts"],
excludeInternal: true,
externalPattern: [
"**/node_modules/**",
"**/packages/sdk/**",
"**/packages/wallets/**",
"**/packages/chains/**",
],
exclude: [
"**/node_modules/**",
"**/packages/sdk/**",
"**/packages/wallets/**",
"**/packages/chains/**",
],
});

const project = await app.convert();

if (project) {
// Project may not have converted correctly
const outputDir = "typedoc/";

// Rendered docs
await app.generateDocs(project, outputDir);
// Alternatively generate JSON output
await app.generateJson(project, outputDir + "/documentation.json");
}
}

// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects
main();
5 changes: 4 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"test:all": "SWC_NODE_PROJECT=./tsconfig.test.json nyc --reporter lcovonly --report-dir ./coverage/evm mocha --config './test/evm/.mocharc.json' --timeout 90000 --parallel './test/evm/**/*.test.ts'",
"test": "make test-evm",
"test:single": "SWC_NODE_PROJECT=./tsconfig.test.json mocha --config './test/evm/.mocharc.json' --timeout 90000",
"push": "yalc push"
"push": "yalc push",
"typedoc": "rimraf typedoc && node typedoc.js"
},
"devDependencies": {
"@aws-sdk/client-secrets-manager": "^3.378.0",
Expand Down Expand Up @@ -110,6 +111,8 @@
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^3.0.0",
"rimraf": "^3.0.2",
"typedoc": "^0.25.2",
"typescript": "^5.1.6",
"zksync-web3": "^0.14.3"
},
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/scripts/generate-snippets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,3 @@ export function generateSnippets(ecosystem) {
}

generateSnippets("evm");
generateSnippets("solana");
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
/**
* Mint a unique NFT
*
* @remarks Mint a unique NFT to a specified wallet.
* @remarks Mint a unique NFT to a specified wallet.
*
* @example
* ```javascript*
* ```typescript
* // Custom metadata of the NFT, note that you can fully customize this metadata with other properties.
* const metadata = {
* name: "Cool NFT",
Expand Down Expand Up @@ -262,7 +262,7 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
* @remarks Mint many unique NFTs at once to the connected wallet
*
* @example
* ```javascript*
* ```typescript
* // Custom metadata of the NFTs you want to mint.
* const metadatas = [{
* name: "Cool NFT #1",
Expand Down Expand Up @@ -294,7 +294,7 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
* @remarks Mint many unique NFTs at once to a specified wallet.
*
* @example
* ```javascript
* ```typescript
* // Address of the wallet you want to mint the NFT to
* const walletAddress = "{{wallet_address}}";
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ export class Pack extends StandardErc1155<PackContract> {

/**
* Create Pack
* @remarks Create a new pack with the given metadata and rewards and mint it to the connected wallet.
* @remarks See {@link Pack.createTo}
* @remarks Create a new pack with the given metadata and rewards and mint it to the connected wallet. See {@link Pack.createTo}
*
* @param metadataWithRewards - the metadata and rewards to include in the pack
* @example
Expand Down Expand Up @@ -396,8 +395,7 @@ export class Pack extends StandardErc1155<PackContract> {

/**
* Add Pack Contents
* @remarks Add contents to an existing pack.
* @remarks See {@link Pack.addPackContents}
* @remarks Add contents to an existing pack. See {@link Pack.addPackContents}
*
* @param packId - token Id of the pack to add contents to
* @param packContents - the rewards to include in the pack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Erc721BatchMintable implements DetectableFeature {
* @remarks Mint many unique NFTs at once to a specified wallet.
*
* @example
* ```javascript
* ```typescript
* // Address of the wallet you want to mint the NFT to
* const walletAddress = "{{wallet_address}}";
*
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/evm/core/classes/erc-721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class Erc721<
* @remarks Mint many unique NFTs at once to the connected wallet
*
* @example
* ```javascript*
* ```typescript
* // Custom metadata of the NFTs you want to mint.
* const metadatas = [{
* name: "Cool NFT #1",
Expand Down Expand Up @@ -596,7 +596,7 @@ export class Erc721<
* @remarks Mint many unique NFTs at once to a specified wallet.
*
* @example
* ```javascript
* ```typescript
* // Address of the wallet you want to mint the NFT to
* const walletAddress = "{{wallet_address}}";
*
Expand Down
30 changes: 30 additions & 0 deletions packages/sdk/typedoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires, better-tree-shaking/no-top-level-side-effects
const TypeDoc = require("typedoc");

async function main() {
// Application.bootstrap also exists, which will not load plugins
// Also accepts an array of option readers if you want to disable
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
const app = await TypeDoc.Application.bootstrapWithPlugins({
entryPoints: ["src/index.ts"],
excludeInternal: true,
externalPattern: ["**/node_modules/**"],
exclude: ["**/node_modules/**"],
pretty: false,
});

const project = await app.convert();

if (project) {
// Project may not have converted correctly
const outputDir = "typedoc/";

// Rendered docs
await app.generateDocs(project, outputDir);
// Alternatively generate JSON output
await app.generateJson(project, outputDir + "/documentation.json");
}
}

// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects
main();
5 changes: 4 additions & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"test:all": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000 --parallel './test/**/*.test.ts'",
"test": "pnpm test:all",
"test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000",
"push": "yalc push"
"push": "yalc push",
"typedoc": "rimraf typedoc && node typedoc.js"
},
"files": [
"dist/"
Expand Down Expand Up @@ -61,6 +62,8 @@
"eslint-config-thirdweb": "workspace:*",
"esm": "^3.2.25",
"mocha": "^10.2.0",
"rimraf": "^3.0.2",
"typedoc": "^0.25.2",
"typescript": "^5.1.6"
},
"dependencies": {
Expand Down
28 changes: 28 additions & 0 deletions packages/storage/typedoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const TypeDoc = require("typedoc");

async function main() {
// Application.bootstrap also exists, which will not load plugins
// Also accepts an array of option readers if you want to disable
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
const app = await TypeDoc.Application.bootstrapWithPlugins({
entryPoints: ["src/index.ts"],
excludeInternal: true,
externalPattern: ["**/node_modules/**"],
exclude: ["**/node_modules/**"],
});

const project = await app.convert();

if (project) {
// Project may not have converted correctly
const outputDir = "typedoc/";

// Rendered docs
await app.generateDocs(project, outputDir);
// Alternatively generate JSON output
await app.generateJson(project, outputDir + "/documentation.json");
}
}

main();
5 changes: 4 additions & 1 deletion packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@
"ethers": "^5.7.2",
"ethers-aws-kms-signer": "^1.3.2",
"tweetnacl": "^1.0.3",
"rimraf": "^3.0.2",
"typedoc": "^0.25.2",
"typescript": "^5.1.6"
},
"scripts": {
Expand All @@ -465,6 +467,7 @@
"clean": "rm -rf dist/",
"build": "tsc && cross-env THIRDWEB_EWS_SDK_VERSION=$npm_package_version preconstruct build",
"preconstruct:fix": "preconstruct fix",
"push": "yalc push"
"push": "yalc push",
"typedoc": "rimraf typedoc && node typedoc.js"
}
}
Loading
Loading