Skip to content

Commit

Permalink
just use static sidebar links for each sub-package API reference, don…
Browse files Browse the repository at this point in the history
…t rely on typedoc execution for sidebar entries.
  • Loading branch information
filmaj committed Oct 4, 2024
1 parent 807a87b commit 9317139
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const config = {
({
docs: {
sidebarItemsGenerator: async () => {
return await sidebarGenerator(PACKAGES);
return sidebarGenerator(PACKAGES);
},
path: 'content',
breadcrumbs: false,
Expand Down
28 changes: 6 additions & 22 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
// @ts-check
import fs from 'node:fs';

async function sleep(timeout) {
return new Promise((res) => {
setTimeout(res, timeout);
});
}
async function waitAndImportFile(file) {
while (!fs.existsSync(file)) {
console.log(file, 'does not exist, waiting for 50 ms');
await sleep(50);
}
return require(file);
}
/**
* Generate a sidebar object for use as reference documentation sidebar entry for each package.
* @param {string} pkg the sub-package to generate refdoc options for
*/
async function packageSidebarEntry(pkg) {
function packageSidebarEntry(pkg) {
/*
return {
type: 'category',
label: `@slack/${pkg}`,
Expand All @@ -27,17 +14,14 @@ async function packageSidebarEntry(pkg) {
},
items: await waitAndImportFile(`./content/reference/${pkg}/typedoc-sidebar.cjs`),
};
*/
}
/**
* Generate list of sidebar objects for docs site.
* @param {string[]} packages list of sub-package to generate refdoc sidebar entries for
*/
export default async function sidebarGenerator(packages) {
const apiReferenceItems = [];
for (const pkg of packages) {
apiReferenceItems.push(await packageSidebarEntry(pkg));
}
console.log('loaded typedoc sidebar items');
export default function sidebarGenerator(packages) {
const apiItems = packages.map((pkg) => ({ type: 'doc', id: `reference/${pkg}/index` }));
return [
{
type: 'doc',
Expand Down Expand Up @@ -74,7 +58,7 @@ export default async function sidebarGenerator(packages) {
{
type: 'category',
label: 'API Reference',
items: apiReferenceItems,
items: apiItems,
},
{ type: 'html', value: '<hr>' },
{
Expand Down

0 comments on commit 9317139

Please sign in to comment.