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

chore: revert TS SDK changes #46

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from all commits
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
61 changes: 42 additions & 19 deletions docs-hub/vp-docs.js
Original file line number Diff line number Diff line change
@@ -7,8 +7,10 @@ const srcFolderPath = path.join(process.cwd(), `../../${process.argv[2]}`);
const subfolders = getSubfolders(srcFolderPath);

const configPath = path.join(srcFolderPath, "../.vitepress/config.ts");
const apiOrderPath = path.join(srcFolderPath, "../.typedoc/api-links.json");

const configFile = fs.readFileSync(configPath, "utf8");
const apiOrderFile = fs.readFileSync(apiOrderPath, "utf8");

const subFolderExceptions = ["guide", "api"];

@@ -77,6 +79,7 @@ function checkForUnusedFiles(srcFolderPath, subfolders) {
const fileNames = fs.readdirSync(srcFolderPath);
fileNames.forEach((file) => {
if (
file !== "api" &&
file !== "public" &&
file !== "index.md" &&
(file.endsWith("md") || file.split(".").length === 1)
@@ -92,24 +95,26 @@ function checkForUnusedFiles(srcFolderPath, subfolders) {
const subfolderNames = fs.readdirSync(folderPath);
const parentFolder = folderPath.split("/").pop();
subfolderNames.forEach((subFile) => {
const actualPath = `${parentFolder}/${
subFile === "index.md" ? "" : subFile
}`;
assert(
configFile.includes(actualPath),
`${actualPath} missing in the nav config`
);
const fullPath = path.join(srcFolderPath, actualPath);
if (fs.statSync(fullPath).isDirectory()) {
const subFolderFiles = fs.readdirSync(fullPath);
subFolderFiles.forEach((file) => {
if (file !== "index.md") {
assert(
configFile.includes(file.replace(".md", "")),
`${file} missing in the nav config`
);
}
});
if (parentFolder !== "api") {
const actualPath = `${parentFolder}/${
subFile === "index.md" ? "" : subFile
}`;
assert(
configFile.includes(actualPath),
`${actualPath} missing in the nav config`
);
const fullPath = path.join(srcFolderPath, actualPath);
if (fs.statSync(fullPath).isDirectory()) {
const subFolderFiles = fs.readdirSync(fullPath);
subFolderFiles.forEach((file) => {
if (file !== "index.md") {
assert(
configFile.includes(file.replace(".md", "")),
`${file} missing in the nav config`
);
}
});
}
}
});
});
@@ -194,14 +199,15 @@ function checkOrder(order, altSrcFolderPath = null) {
}
assert(
fileExists,
`${item} doesn't exist. The file name must match the title in the nav config.`
`${item} doesn't exist. The file name must match the title in the nav config. If this file is in the API folder, something went wrong.`
);
});
}
});
}

function extractData(inputString) {
// used for api.json order
const regex = /"([^"]+)":\s*"([^"]+)"/g;
const match = regex.exec(inputString);
if (match !== null) {
@@ -256,6 +262,23 @@ function handleVPLine(trimmedLine, lines, index, thisOrder, thisCat) {
newVPOrder.menu.push(linkName);
}
}
} else if (trimmedLine.startsWith("apiLinks")) {
// handle API order
newVPOrder.menu.push("API");
const apiJSON = JSON.parse(apiOrderFile);
const apiLines = JSON.stringify(apiJSON, null, 2).split(EOL);
apiLines.forEach((apiLine, apiIndex) => {
const trimmedAPILine = apiLine.trimStart();
const results = handleVPLine(
trimmedAPILine,
apiLines,
apiIndex,
newVPOrder,
category
);
category = results.category;
newVPOrder = results.newVPOrder;
});
}

return { newVPOrder, category };