Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 8c3e931

Browse files
authored
Improve the rendering of the docs (#5160)
* 🎨 Improve the docs layout and performance * 🎨 Update the tsconfig to avoid docs generating issue * 🎨 Update github reference
1 parent 80b07dd commit 8c3e931

File tree

10 files changed

+816
-454
lines changed

10 files changed

+816
-454
lines changed

docs/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DISABLE_NEW_JSX_TRANSFORM=true

docs/docusaurus.config.js

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1717

1818
const lightCodeTheme = require('prism-react-renderer/themes/github');
1919
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
20+
const { join } = require('path');
21+
22+
const packages = [
23+
'web3',
24+
'web3-eth',
25+
'web3-eth-contract',
26+
'web3-utils',
27+
'web3-validator',
28+
'web3-common',
29+
'web3-core',
30+
'web3-errors',
31+
'web3-net',
32+
'web3-eth-abi',
33+
'web3-eth-accounts',
34+
'web3-eth-ens',
35+
'web3-eth-iban',
36+
'web3-eth-personal',
37+
'web3-providers-http',
38+
'web3-providers-ws',
39+
'web3-providers-ipc',
40+
];
2041

2142
/** @type {import('@docusaurus/types').Config} */
2243
const config = {
@@ -44,46 +65,23 @@ const config = {
4465
plugins: [
4566
'@docusaurus/theme-live-codeblock',
4667
[
47-
'docusaurus-plugin-typedoc',
48-
49-
// Plugin / TypeDoc options
68+
'docusaurus-plugin-typedoc-api',
5069
{
51-
entryPoints: [
52-
'../packages/web3',
53-
'../packages/web3-common',
54-
'../packages/web3-core',
55-
'../packages/web3-errors',
56-
'../packages/web3-eth',
57-
'../packages/web3-eth-abi',
58-
'../packages/web3-eth-accounts',
59-
'../packages/web3-eth-contract',
60-
'../packages/web3-eth-ens',
61-
'../packages/web3-eth-iban',
62-
'../packages/web3-eth-personal',
63-
'../packages/web3-net',
64-
'../packages/web3-providers-http',
65-
'../packages/web3-providers-ws',
66-
'../packages/web3-providers-ipc',
67-
'../packages/web3-utils',
68-
'../packages/web3-validator',
69-
],
70-
entryPointStrategy: 'packages',
71-
cleanOutputDir: true,
72-
sidebar: {
73-
fullNames: true,
70+
projectRoot: join(__dirname, '..'),
71+
// Monorepo
72+
packages: packages.map(p => `packages/${p}`),
73+
minimal: false,
74+
debug: true,
75+
changelogs: true,
76+
readmes: false,
77+
tsconfigName: 'docs/tsconfig.docs.json',
78+
typedocOptions: {
79+
plugin: [
80+
'typedoc-monorepo-link-types',
81+
'typedoc-plugin-extras',
82+
'typedoc-plugin-mdn-links',
83+
],
7484
},
75-
plugin: [
76-
// Link the cross package types
77-
'typedoc-monorepo-link-types',
78-
// Provide some extra formatting features for the generated docs
79-
'typedoc-plugin-extras',
80-
// Provide support to allow relative includes in the JSDoc comments.
81-
'@droppedcode/typedoc-plugin-relative-includes',
82-
// Adds support for linking references to global types like `HTMLElement`, `Date`
83-
'typedoc-plugin-mdn-links',
84-
],
85-
// Don't cross reference the non-exported members
86-
noMissingExports: true,
8785
},
8886
],
8987
],
@@ -97,7 +95,7 @@ const config = {
9795
sidebarPath: require.resolve('./sidebars.js'),
9896
// Please change this to your repo.
9997
// Remove this to remove the "edit this page" links.
100-
editUrl: 'https://github.com/ChainSafe/web3.js/tree/main/website/',
98+
editUrl: 'https://github.com/ChainSafe/web3.js/tree/4.x/docs',
10199
},
102100
theme: {
103101
customCss: require.resolve('./src/css/custom.css'),
@@ -123,13 +121,12 @@ const config = {
123121
position: 'left',
124122
},
125123
{
126-
to: 'docs/api/', // 'api' is the 'out' directory
127-
activeBasePath: 'docs',
124+
to: 'api', // 'api' is the 'out' directory
128125
label: 'API',
129126
position: 'left',
130127
},
131128
{
132-
href: 'https://github.com/ChainSafe/web3.js',
129+
href: 'https://github.com/ChainSafe/web3.js/tree/4.x/',
133130
label: 'GitHub',
134131
position: 'right',
135132
},

docs/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
"typecheck": "tsc"
1616
},
1717
"dependencies": {
18-
"@docusaurus/core": "2.0.0-beta.20",
19-
"@docusaurus/preset-classic": "2.0.0-beta.20",
20-
"@docusaurus/theme-live-codeblock": "^2.0.0-beta.20",
18+
"@docusaurus/core": "^2.0.0-beta.21",
19+
"@docusaurus/preset-classic": "^2.0.0-beta.21",
20+
"@docusaurus/theme-live-codeblock": "^2.0.0-beta.21",
2121
"@mdx-js/react": "^1.6.22",
2222
"clsx": "^1.1.1",
2323
"prism-react-renderer": "^1.3.1",
2424
"react": "^17.0.2",
2525
"react-dom": "^17.0.2"
2626
},
2727
"devDependencies": {
28-
"@docusaurus/module-type-aliases": "2.0.0-beta.20",
28+
"@docusaurus/module-type-aliases": "^2.0.0-beta.21",
2929
"@tsconfig/docusaurus": "^1.0.5",
30-
"typescript": "^4.6.4",
31-
"docusaurus-plugin-typedoc": "^0.17.5"
30+
"docusaurus-plugin-typedoc-api": "^2.0.1",
31+
"typescript": "^4.6.4"
3232
},
3333
"browserslist": {
3434
"production": [

docs/src/components/HomepageFeatures/index.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
This file is part of web3.js.
3+
4+
web3.js is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Lesser General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
web3.js is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public License
15+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
118
import React from 'react';
219
import clsx from 'clsx';
320
import styles from './styles.module.css';

docs/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function HomepageHeader() {
3333
<div className={styles.buttons}>
3434
<Link
3535
className="button button--secondary button--lg"
36-
to="/docs/intro">
36+
to="/docs/guides/intro">
3737
Docusaurus Tutorial - 5min ⏱️
3838
</Link>
3939
</div>

docs/tsconfig.docs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"declarationDir": "dts",
5+
"outDir": "dts"
6+
},
7+
"include": ["../packages/*/src/**/*", "../packages/*/types/**/*"]
8+
}

0 commit comments

Comments
 (0)