Skip to content

Commit

Permalink
[docs] Add bridge framework docs (MystenLabs#20619)
Browse files Browse the repository at this point in the history
## Description 

Adds the bridge framework docs. Had to rename files to support duplicate
name between folder and file. This is a docusaurus autogen issue.

## Test plan 

View the preview site References > Framework > Bridge


https://sui-docs-git-fork-ronny-mysten-bridge-fw-sui-foundation.vercel.app/references/framework/bridge

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
ronny-mysten authored Dec 16, 2024
1 parent 39e3d38 commit 5376911
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions docs/site/src/plugins/framework/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,7 +34,6 @@ const DOCS_PATH = path.join(
"../../../../content/references/framework",
);


const frameworkPlugin = (context, options) => {
return {
name: "sui-framework-plugin",
Expand Down Expand Up @@ -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,
Expand All @@ -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(/<a\s+(.*?)\.md(.*?)>/g, `<a $1$2>`)
.replace(
/(title: .*)Module `(0x[1-9a-f]{1,4}::)(.*)`/g,
Expand All @@ -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("-")
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5376911

Please sign in to comment.