Skip to content

Commit

Permalink
Update to use the latest typedoc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdemartini committed Jan 7, 2021
1 parent df0978e commit 243ffa4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"semver": "^7.3.4",
"signale": "^1.4.0",
"sort-package-json": "~1.48.0",
"typedoc": "^0.20.11",
"typedoc-plugin-markdown": "^3.0.11",
"typedoc": "^0.20.13",
"typedoc-plugin-markdown": "^3.3.0",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand Down
34 changes: 18 additions & 16 deletions packages/scripts/src/helpers/docs/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PackageInfo } from '../interfaces';
import { listMdFiles, getName, writeIfChanged } from '../misc';
import signale from '../signale';

const app = new Application();


function isOverview(filePath: string): boolean {
return path.basename(filePath, '.md') === 'overview';
Expand All @@ -25,7 +25,7 @@ async function writeDocFile(filePath: string, { title, sidebarLabel }: { title:

// fix paths
contents = contents
.replace(/(\]\([\w\.\/]*)index\.md/g, '$1overview.md');
.replace(/(\]\([\w\.\/]*)README\.md/g, '$1overview.md');
// build final content
contents = `---
title: ${title}
Expand Down Expand Up @@ -53,10 +53,10 @@ function getAPIName(overview: string, outputDir: string, filePath: string) {
}

async function fixDocs(outputDir: string, { displayName }: PackageInfo) {
const overviewFilePath = listMdFiles(outputDir).find((filePath) => path.basename(filePath, '.md') === 'index');
const overviewFilePath = listMdFiles(outputDir).find((filePath) => path.basename(filePath, '.md') === 'README');
if (!overviewFilePath) {
signale.error(
'Error: Package documentation was not generated correctly',
'Error: Package documentation was not generated correctly' +
", this means the package my not work with the typedoc's version of TypeScript."
);
return;
Expand Down Expand Up @@ -84,25 +84,27 @@ async function fixDocs(outputDir: string, { displayName }: PackageInfo) {
await Promise.all(promises);
}

app.options.addReader(new TSConfigReader());
app.bootstrap({
theme: 'markdown',
exclude: ['test', 'node_modules'],
excludePrivate: true,
excludeExternals: true,
hideGenerator: true,
readme: 'none',
});


export async function generateTSDocs(pkgInfo: PackageInfo, outputDir: string): Promise<void> {
signale.await(`building typedocs for package ${pkgInfo.name}`);

const cwd = process.cwd();
try {
process.chdir(pkgInfo.dir);

app.options.setValue('name', pkgInfo.name);
app.options.setValue('tsconfig', path.join(pkgInfo.dir, 'tsconfig.json'));
const app = new Application();
app.options.addReader(new TSConfigReader());
app.bootstrap({
name: pkgInfo.name,
tsconfig: path.join(pkgInfo.dir, 'tsconfig.json'),
theme: 'markdown',
exclude: ['test', 'node_modules'],
excludePrivate: true,
excludeExternals: true,
hideGenerator: true,
readme: 'none',
});
app.options.setValue("entryPoints", app.expandInputFiles(['src']));

if (app.logger.hasErrors()) {
signale.error(`found errors typedocs for package ${pkgInfo.name}`);
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10397,17 +10397,17 @@ typedoc-default-themes@0.12.0:
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.0.tgz#42451948e55a148c1350eb2aa68829be5c2b06b3"
integrity sha512-0hHBxwmfxE0rkIslOiO39fJyYwaScQEhUIxcpqx3uS1BL3zhFW5oQfUaPx2cv2XLL/GXhYFxhdFLoVmNptbxEQ==

typedoc-plugin-markdown@^3.0.11:
version "3.2.1"
resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.2.1.tgz#c11d1107893811b4d4d8f9443885a34d2a53e502"
integrity sha512-gepVk2zFFrTGaKywLEgwz6EARYjOGcx9rHF8M8a+fqz/iTp6Zobvw+7x01BJ9V4tbuXI3M9Y2/wMYwC378/msg==
typedoc-plugin-markdown@^3.3.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.4.0.tgz#5634f2aa74053f514b882f36782769c157c3a9aa"
integrity sha512-aHLWI4jeSpSDgMbRByinRp+b2u4kHXySiccZc7lKSExH4Md44ds21oH0g+xZ5lBv9dhZdTz7mhTCrbAm5Nh24w==
dependencies:
handlebars "^4.7.6"

typedoc@^0.20.11:
version "0.20.11"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.11.tgz#f210384a7a63af617e517e1c920189f4e5b9b6fb"
integrity sha512-sGHLq9bPuaAFPQUW1sdMZYWrw2+QhpAQV48Z13J6ptK/mDZy231B1WwGgzXOsnEBIuZyL9BIsoMjPfn3KCq7Tg==
typedoc@^0.20.13:
version "0.20.13"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.13.tgz#9d56df76d0b421a71a33336dc64b1a466dc8f2fd"
integrity sha512-SJVFn6NJd5bWJHMPgEkDUrKIEfMbja6ftIJv/tgd0xQZp5cWxGTdEnmRr56+egIQZkAJFB39eDvmNV4Lqqy4Gw==
dependencies:
colors "^1.4.0"
fs-extra "^9.0.1"
Expand Down

0 comments on commit 243ffa4

Please sign in to comment.