diff --git a/docs/site/src/plugins/framework/index.js b/docs/site/src/plugins/framework/index.js
index cd3dcf793c3f2..51c4a88858d7a 100644
--- a/docs/site/src/plugins/framework/index.js
+++ b/docs/site/src/plugins/framework/index.js
@@ -9,6 +9,10 @@
import path from "path";
import fs from "fs";
+const BRIDGE_PATH = path.join(
+ __dirname,
+ "../../../../../crates/sui-framework/docs/bridge",
+);
const FRAMEWORK_PATH = path.join(
__dirname,
"../../../../../crates/sui-framework/docs/sui-framework",
@@ -30,7 +34,6 @@ const DOCS_PATH = path.join(
"../../../../content/references/framework",
);
-
const frameworkPlugin = (context, options) => {
return {
name: "sui-framework-plugin",
@@ -62,11 +65,13 @@ const frameworkPlugin = (context, options) => {
return files;
};
+ const bridgeFiles = recurseFiles(BRIDGE_PATH);
const frameworkFiles = recurseFiles(FRAMEWORK_PATH);
const stdlibFiles = recurseFiles(STDLIB_PATH);
const deepbookFiles = recurseFiles(DEEPBOOK_PATH);
const suisysFiles = recurseFiles(SUISYS_PATH);
const allFiles = [
+ bridgeFiles,
frameworkFiles,
stdlibFiles,
deepbookFiles,
@@ -81,7 +86,7 @@ const frameworkPlugin = (context, options) => {
// Remove code blocks without pre's. Render automatically adds
// pre element that messes up formatting.
// Remove empty code blocks because it looks lame.
- const reMarkdown = markdown
+ let reMarkdown = markdown
.replace(//g, ``)
.replace(
/(title: .*)Module `(0x[1-9a-f]{1,4}::)(.*)`/g,
@@ -95,8 +100,21 @@ const frameworkPlugin = (context, options) => {
let newDir = DOCS_PATH;
// Should work for nested docs, but is currently flat tree.
- parts.forEach((part) => {
- if (!part.match(/\.md$/)) {
+ parts.forEach((part, i) => {
+ if (part.match(/\.md$/)) {
+ // Autogenerated content has a problem when the parent directory
+ // is same name as file
+ if (part.replace(/\.md/, "") === parts[i - 1]) {
+ const slug = fileWrite.replace(
+ /^.*?\/content\/(.*)\.md$/,
+ `$1`,
+ );
+ reMarkdown = reMarkdown.replace(
+ /sidebar_label/,
+ `slug: /${slug}\nsidebar_label`,
+ );
+ }
+ } else {
// Capitalize lib name for nav.
let styledPart = part
.split("-")
@@ -136,6 +154,7 @@ const frameworkPlugin = (context, options) => {
}
}
});
+
fs.writeFileSync(fileWrite, reMarkdown, "utf8", (err) => {
if (err) {
console.error("An error occurred creating framework file:", err);