Skip to content

Commit

Permalink
add mini plugin to remove /api instead of the previously used file co…
Browse files Browse the repository at this point in the history
…py, adjust menu header, adjust categories and navigation
  • Loading branch information
hybridherbst committed Oct 14, 2024
1 parent c3bb1c4 commit 6dd5142
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"sass-embedded": "^1.78.0",
"three": "npm:@needle-tools/three@^0.162.10",
"typedoc": "0.26.8",
"typedoc-plugin-coverage": "^3.3.0",
"typedoc-plugin-extras": "3.1.0",
"typedoc-plugin-inline-sources": "1.1.0",
"typedoc-plugin-mdn-links": "3.3.2",
Expand Down
8 changes: 8 additions & 0 deletions tools/api-plugins/api-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ a.title {
background-image: url("https://engine.needle.tools/docs/needle-logo-white.svg");
}

/*
a.title::after {
content: "API Reference";
color: initial;
Expand All @@ -48,6 +49,7 @@ a.title::after {
bottom: 1px;
position: relative;
}
*/

#tsd-search.has-focus {
background-color: transparent;
Expand Down Expand Up @@ -111,20 +113,26 @@ html[data-theme="dark"] a.title {
}
}

/*
#tsd-search .field label {
z-index: 10;
overflow: visible;
padding-left: calc(min(500px, 80%) - 40px);
margin-right: 40px;
}
*/

@media screen and (max-width: 440px) {
/*
a.title::after {
content: none;
}
*/

/*
#tsd-search .field label {
padding-left: calc(80% - 80px);
margin-right: 20px;
}
*/
}
7 changes: 7 additions & 0 deletions tools/api-plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { Application, JSX, ParameterType, ReflectionKind } from "typedoc";
*/
export function load(app) {

app.converter.on("createDeclaration", (context, refl) => {
if (refl.name.endsWith("/api")) {
console.log(refl.name + " - " + refl.getFullName());
refl.name = refl.name.replace("/api", "");
}
});

app.converter.addUnknownSymbolResolver((declaration) => {
const names = declaration.symbolReference?.path;
if (!names) return;
Expand Down
41 changes: 19 additions & 22 deletions tools/build_api_docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,13 @@ async function produceDocs(packageDir, outputDirectory) {

const readmePath = packageDir + "/README.md";

// copy the /api.ts files to /index.ts so that we get nicer paths
const files = [
packageDir + "/src/engine/api.ts",
packageDir + "/src/engine-components/api.ts",
packageDir + "/src/engine-components-experimental/api.ts",
packageDir + "/src/engine-schemes/api.ts",
]

for (const file of files) {
const indexFile = file.replace(/\/([^/]+)\.ts$/, "/index.ts");
fs.copyFileSync(file, indexFile);
}

const app = await TypeDoc.Application.bootstrapWithPlugins({
lang: "en",
entryPoints: [
packageDir + "/src/engine",
packageDir + "/src/engine-components",
packageDir + "/src/engine-components-experimental",
packageDir + "/src/engine-schemes",
packageDir + "/src/engine/api.ts",
packageDir + "/src/engine-components/api.ts",
packageDir + "/src/engine-components-experimental/api.ts",
packageDir + "/src/engine-schemes/api.ts",
],
tsconfig: "./tools/api-plugins/tsconfig.json",
// don't include references multiple times
Expand All @@ -209,6 +196,20 @@ async function produceDocs(packageDir, outputDirectory) {

// readme: "none",
excludeExternals: true,
navigation: {
includeFolders: false,
includeCategories: true,
includeGroups: false,
},
categorizeByGroup: false,
categoryOrder: ["*", "Other"],
navigationLinks: {
"API": "/",
"Docs": "https://engine.needle.tools/docs/",
"Samples": "https://engine.needle.tools/samples/",
"Pricing": "https://needle.tools/pricing/",
},

skipErrorChecking: true,
excludeInternal: true,
excludeProtected: false,
Expand All @@ -227,21 +228,17 @@ async function produceDocs(packageDir, outputDirectory) {
name: "Needle Engine",

readme: readmePath,
categorizeByGroup: true,

"visibilityFilters": {
"protected": false,
"inherited": false,
"@deprecated": false,
},

// plugin: "typedoc-neo-theme",
// theme: "./node_modules/typedoc-neo-theme/bin/default",

plugin: [
"typedoc-plugin-inline-sources",
"typedoc-plugin-mdn-links",
// "typedoc-plugin-keywords",
"typedoc-plugin-coverage",
"typedoc-plugin-extras",
"./tools/api-plugins/index.js",
"./tools/api-plugins/keywords/index.js",
Expand Down

0 comments on commit 6dd5142

Please sign in to comment.