Skip to content

Commit

Permalink
chore: add config to generate markdown API docs (#389)
Browse files Browse the repository at this point in the history
This adds a minimal [docusaurus](https://docusaurus.io) config file that
allows us to use
[docusaurus-plugin-typedoc](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc)
to generate markdown files that are compatible with docusaurus.

**Context**

As part of web3-storage/web3.storage#2190, I
want to render the typedoc outputs for all our "user facing" packages.
The idea is that I would make a shallow clone of this repo when building
the docs site and run `pnpm run docs:markdown` to generate the markdown
files, then copy them into the content dir, along with the outputs of
`w3up-client` and whatever other packages we end up putting in there.

The plugin really wants to be part of a docusaurus project, but it will
run with just the `@docusaurus/core` dependency and a minimal config
file. `@docusaurus/core` has a peer dependency on `react` and
`react-dom`, so I added some [pnpm
config](https://pnpm.io/package_json#pnpmpeerdependencyrules) to ignore
missing react peer deps.


Here's a quick screenshot of my WIP docs build, as a teaser of things to
come:


![image](https://user-images.githubusercontent.com/678715/214158679-2442f419-1ab7-45df-a2ce-188a4c0de40a.png)
  • Loading branch information
yusefnapora authored Jan 24, 2023
1 parent ba31138 commit 6e83725
Show file tree
Hide file tree
Showing 3 changed files with 9,665 additions and 3,899 deletions.
35 changes: 35 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Minimal [Docusaurus](https://docusaurus.io) configuration to allow us
// to generate docusaurus-compatible markdown from typedoc output.

const config = {
title: 'Web3.Storage Documentation',
tagline: 'The simple file storage service for IPFS and Filecoin',
url: 'https://docs.web3.storage',
baseUrl: '/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',

// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},

plugins: [
[
'docusaurus-plugin-typedoc',
{
tsconfig: './tsconfig.json',
out: 'markdown',
sidebar: {
categoryLabel: 'w3protocol',
},
},
],
],
}

module.exports = config
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
"test": "pnpm -r --if-present run test",
"check": "pnpm -r --if-present run check",
"build": "pnpm -r --if-present run build",
"docs": "pnpm run build && typedoc --out docs"
"docs": "pnpm run build && typedoc --out docs",
"docs:markdown": "pnpm run build && docusaurus generate-typedoc"
},
"devDependencies": {
"@docusaurus/core": "^2.2.0",
"docusaurus-plugin-typedoc": "^0.18.0",
"lint-staged": "^13.1.0",
"prettier": "2.8.3",
"simple-git-hooks": "^2.8.1",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "4.9.4",
"wrangler": "^2.8.0"
},
Expand All @@ -43,5 +47,12 @@
"typedoc": "^0.23.22",
"typedoc-plugin-missing-exports": "^1.0.0"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"react*"
]
}
}
}
Loading

0 comments on commit 6e83725

Please sign in to comment.