Tweaking docs

This commit is contained in:
thepaperpilot 2022-07-14 21:59:46 -05:00
parent 58c9523565
commit 32d527edeb
6 changed files with 37 additions and 35 deletions

View file

@ -25,7 +25,7 @@ module.exports = {
},
nav: [
{ text: "Guide", link: "/guide/", activeMatch: "^/guide/" },
{ text: "API", link: "/api/", activeMatch: "^/api/" },
{ text: "API", link: "/api/overview", activeMatch: "^/api/" },
{ text: "Forums", link: "https://forums.moddingtree.com" }
],
socialLinks: [

View file

@ -1,7 +1,7 @@
<template>
<Layout>
<template #home-hero-before>
<Profectus v-if="showLogo" style="height: 30vmin; margin: auto; display: block" />
<Profectus v-if="showLogo" style="height: 30vmin; margin: auto; display: block; margin-top: 10px;" />
<div v-else style="height: 30vmin; margin: auto; display: block" />
</template>
</Layout>

View file

@ -26,20 +26,15 @@ body {
border: 1px solid var(--vp-c-divider-light);
}
.vp-doc h1:first-child {
position: sticky;
top: 16px;
z-index: 20;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.content,
.VPNav.no-sidebar {
background: var(--vp-c-bg) !important;
}
.VPNavBar {
border-bottom: 0 !important;
}
.vp-doc :not(pre) > code {
color: var(--vp-c-text-light-1);
background-color: var(--vp-code-block-bg);

View file

@ -9,6 +9,7 @@
--vp-c-divider-light: #4C566A;
--vp-c-brand: #5E81AC;
--vp-c-brand-light: #81A1C1;
--vp-c-brand-dark: #81A1C1;
--vp-button-brand-border: #81A1C1;
--vp-button-brand-text: #ECEFF4;
--vp-button-brand-hover-text: #ECEFF4;

3
overview.md Normal file
View file

@ -0,0 +1,3 @@
# Profectus API
This section of the docs is generated via the doc comments inside the Profectus source code. It can be used as a reference while developing, but should also appear in your preferred IDE as appropriate.

View file

@ -14,32 +14,35 @@ function walk(dir, cb) {
}));
}
walk("./components", (dir, file, resolve) => {
const relPath = path.relative("./components", dir);
let dest = path.resolve("./docs/api", relPath);
if (relPath.includes("features")) {
dest = path.resolve("./docs/api/modules", relPath);
}
const filePath = path.resolve(dir, file);
const stream = fs.createReadStream(filePath);
let lineCount = 0;
stream.on("data", buffer => {
let idx = -1;
lineCount--; // Because the loop will run once for idx=-1
do {
idx = buffer.indexOf(10, idx + 1);
lineCount++;
} while (idx !== -1);
if (lineCount > 4) {
stream.destroy();
fs.mkdirSync(dest, { recursive: true });
fs.copyFileSync(filePath, path.resolve(dest, path.basename(file)));
(async () => {
fs.copyFileSync("./overview.md", "./docs/api/overview.md");
fs.unlinkSync("./docs/api/index.md");
await walk("./components", (dir, file, resolve) => {
const relPath = path.relative("./components", dir);
let dest = path.resolve("./docs/api", relPath);
if (relPath.includes("features")) {
dest = path.resolve("./docs/api/modules", relPath);
}
resolve();
const filePath = path.resolve(dir, file);
const stream = fs.createReadStream(filePath);
let lineCount = 0;
stream.on("data", buffer => {
let idx = -1;
lineCount--; // Because the loop will run once for idx=-1
do {
idx = buffer.indexOf(10, idx + 1);
lineCount++;
} while (idx !== -1);
if (lineCount > 4) {
stream.destroy();
fs.mkdirSync(dest, { recursive: true });
fs.copyFileSync(filePath, path.resolve(dest, path.basename(file)));
}
resolve();
});
});
}).then(() => {
const frontmatter = Buffer.from("---\neditLink: false\n---\n");
walk("./docs/api", function addFrontmatter(dir, file, resolve) {
await walk("./docs/api", function addFrontmatter(dir, file, resolve) {
if (path.extname(file) !== ".md") return;
const filePath = path.resolve(dir, file);
if (dir.endsWith("interfaces")) {
@ -67,4 +70,4 @@ walk("./components", (dir, file, resolve) => {
fs.closeSync(fd);
resolve();
});
});
})();