Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Dec 16, 2024
1 parent f9f2109 commit 88e4cdf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ lerna-debug.log
/data
/classes
/docs
/versioned_docs
/tmp
1 change: 0 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const config: Config = {
{
docs: {
sidebarPath: require.resolve('./sidebars.js'),
exclude: ['ref/**'],
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
Expand Down
4 changes: 2 additions & 2 deletions plugins/cls-loader/src/components/RefIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function RefIndex({ options, classes, history }: RefIndexProps) {
<Heading as="h1">Welcome to the Class Reference</Heading>
</header>

<section className="tsd-panel">
{/* <section className="tsd-panel">
<h3 className="tsd-panel-header">Packages</h3>
<div className="tsd-panel-content">
<ul className="tsd-index-list">
Expand All @@ -98,7 +98,7 @@ export default function RefIndex({ options, classes, history }: RefIndexProps) {
))}
</ul>
</div>
</section>
</section> */}
</div>

<Footer />
Expand Down
49 changes: 26 additions & 23 deletions plugins/cls-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import type {
PropVersionMetadata,
} from "@docusaurus/plugin-content-docs";
import { CURRENT_VERSION_NAME } from "@docusaurus/plugin-content-docs/server";
import type { LoadContext, Plugin, PluginContentLoadedActions, RouteConfig } from "@docusaurus/types";
import type {
LoadContext,
Plugin,
PluginContentLoadedActions,
RouteConfig,
} from "@docusaurus/types";
import { DEFAULT_PLUGIN_ID, normalizeUrl } from "@docusaurus/utils";
import { generateJson } from "./plugin/data";
import { extractSidebar } from "./plugin/sidebar";
Expand Down Expand Up @@ -80,14 +85,11 @@ export default function clsLoaderPlugin(
const classes = await getClassesFromFolder(
path.join(options.projectRoot, metadata.versionLabel),
metadata.versionPath + "/",
context.generatedFilesDir,
context.generatedFilesDir
);

// Generate sidebars (this runs before the main sidebar is loaded)
const sidebars = extractSidebar(
classes,
options.sortSidebar
);
const sidebars = extractSidebar(classes, options.sortSidebar);

// await fs.promises.writeFile(
// path.join(
Expand All @@ -104,6 +106,10 @@ export default function clsLoaderPlugin(
// ),
// `import type { SidebarConfig } from '@docusaurus/plugin-content-docs';\nexport = Array<SidebarConfig>;`
// );
generateClassDocs(
path.join(context.generatedFilesDir, "cls-loader-docs", metadata.versionLabel),
classes
);

return {
...metadata,
Expand Down Expand Up @@ -137,7 +143,8 @@ export default function clsLoaderPlugin(
const rootRoutes = await Promise.all(
content.loadedVersions.map(async (loadedVersion) => {
const version = loadedVersion.versionName;
generateClassDocs(actions, path.join(context.siteDir, "docs", version), loadedVersion.classes);
// generateClassDocs(actions, path.join(context.siteDir, "versioned_docs", `version-${loadedVersion.versionLabel}`), loadedVersion.classes);
// generateClassDocs(actions, path.join(context.generatedFilesDir, "cls-loader", version), loadedVersion.classes);

// Define version metadata for all pages. We need to use the same structure as
// "docs" so that we can utilize the same React components.
Expand Down Expand Up @@ -203,21 +210,17 @@ export default function clsLoaderPlugin(

const indexPermalink = normalizeUrl([loadedVersion.versionPath]);

if (loadedVersion.classes.length > 1) {
// Only write out the ApiIndex only when we have multiple packages
// otherwise we will have 2 top-level entries in the route entries
routes.push({
path: indexPermalink,
exact: true,
component: path.join(__dirname, "./components/RefIndex.js"),
modules: {
options: optionsData,
classes: classesData,
versionMetadata,
},
sidebar: "ref",
});
}
routes.push({
path: indexPermalink,
exact: true,
component: path.join(__dirname, "./components/RefIndex.js"),
modules: {
options: optionsData,
classes: classesData,
versionMetadata,
},
sidebar: "ref",
});

// console.log("indexPermalink", indexPermalink);
// Wrap in the `DocVersionRoot` component:
Expand Down Expand Up @@ -254,4 +257,4 @@ export default function clsLoaderPlugin(
});
},
};
}
}
5 changes: 2 additions & 3 deletions plugins/cls-loader/src/plugin/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ ${asCode(classDef.Class.code)}
${noCode ? "" : originalCode}
`;
return documentation;
documentation += membersToMarkdown(
classFile,
"Parameters",
Expand All @@ -314,10 +313,10 @@ export async function generateDocFile(classFile, folder, mdFile) {
return mdFileFull;
}

export async function generateClassDocs(actions, folder, classes) {
export async function generateClassDocs(folder, classes) {
classes.forEach(async (item) => {
if (item.isPackage) {
generateClassDocs(actions, `${folder}/${item.name}`, item.items);
generateClassDocs(`${folder}/${item.name}`, item.items);
} else {
item.fileContent = await generateDocFile(
item.fullPath,
Expand Down

0 comments on commit 88e4cdf

Please sign in to comment.