TypeScript documentation for mono-repo
In a mono-repo, you can generate TypeScript documentation for all packages using TypeDoc. This guide will show you how to generate documentation for a mono-repo with multiple packages.
Prerequisites
A mono-repo with multiple TypeScript packages
We will use Lerna monorepo in this guide as an example.
Steps to generate type documentation
- Install TypeDoc as a dev dependency in the root of the mono-repo:
npm install --save-dev typedoc
- Create configuration file
typedoc.jsonfor the packages
{
"entryPoints": ["src/index.ts"],
"out": "docs/package-1",
"tsconfig": "./tsconfig.json"
}
{
"entryPoints": ["src/index.ts"],
"out": "docs",
"tsconfig": "./tsconfig.json"
}
entryPoints: The entry point of the packageout: The output directory for the documentationtsconfig: The path to thetsconfig.jsonfile
- Add a script to the root
package.jsonto generate documentation for all packages:
Firstly, we need to create a docs folder in the root of the mono-repo.
Then modify the package.json file to include the following scripts:
{
"scripts": {
"docs": " yarn build-docs && cp -r packages/package-1/docs/package-1 packages/package-2/docs/package-2 docs",
"build-docs": " yarn build-docs:package-1 && yarn build-docs:package-2",
"build-docs:package-1": " typedoc --skipErrorChecking --options packages/package-1/typedoc.json",
"build-docs:package-2": " typedoc --skipErrorChecking --options packages/package-2/typedoc.json"
}
}
- Run the following command to generate the documentation:
npm run docs
build-docs:pacakge-1: Generate documentation for package-1 under
packages/package-1/docs/package-1build-docs:pacakge-2: Generate documentation for package-2 under
packages/package-2/docs/package-2docs: Copy the generated documentation to the
docsfolder in the root of the mono-repo
Preview the Typedoc page
We will utilize the light-server package to preview the generated documentation.
- Install
light-serveras a dev dependency:
npm install --save-dev light-server
- Add a script to the root
package.jsonto preview the documentation:
{
"scripts": {
"serve-docs": "light-server -s ./docs -p 4000"
}
}
Execute npm run serve-docs to establish a server at http://localhost:4000 to preview the generated documentation like below:

Host the documentation on GitHub Pages
To host the documentation on GitHub Pages, follow these steps:
Login to the GitHub account which contains the mono-repo then select the
Settingstab.Click the
Pagestab on the left sidebar.Under the
Build and deploysection,- Select
Deploy from a branchas the source. - Choose the branch where the documentation is generated.
- Select the folder where the documentation is located.
- Select
Then click Save to deploy the documentation. When we click the Actions tab, we can see the deployment status (also history) of the documentation. This also shows the URL where the documentation is hosted.
When we access the URL, we will see the page like below:

Oops! Looks like github pages requires a index.html file to be present in the root of the docs folder. We can fix this by adding a index.html file in the root of the docs folder.
You can put what ever content you want in the index.html file. Here is an example embedding a iframe of my docusaurus documentation as the root of the docs folder:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Colorful Life</title>
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<iframe
src="https://docs.dev-eric.work/"
width="100%"
height="600px"
frameborder="0"
></iframe>
</body>
</html>
Then commit and push the changes to the repository. The documentation will be hosted on GitHub Pages.