Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add bridge framework docs #20619

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix same name issue
  • Loading branch information
ronny-mysten committed Dec 13, 2024
commit 8045bd359f90bc0e4355420805c4f8bc24ae2c9e
25 changes: 18 additions & 7 deletions docs/site/src/plugins/framework/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,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 @@ -96,15 +96,25 @@ const frameworkPlugin = (context, options) => {
.replace(/<pre><code><\/code><\/pre>/g, "");
const filename = file.replace(/.*\/docs\/(.*)$/, `$1`);
const parts = filename.split("/");
const fileWrite = path.join(
DOCS_PATH,
filename.replace(/\.md$/, "-schema.md"),
);
const fileWrite = path.join(DOCS_PATH, filename);
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 @@ -144,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
Loading