From 4530ed9a3ac4e579f6a0d862d2b3e45fcbcd63a8 Mon Sep 17 00:00:00 2001 From: Orasund Date: Mon, 23 Nov 2026 11:28:15 +0100 Subject: [PATCH 1/3] Add Api Reference page to docs --- website/src/config.ts | 1 + website/src/jsDocsUtils.mjs | 36 +++++++++++++++++++ website/src/pages/reference.astro | 27 ++++++++++++++ .../src/repl/components/panel/Reference.jsx | 35 ++---------------- 4 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 website/src/jsDocsUtils.mjs create mode 100644 website/src/pages/reference.astro diff --git a/website/src/config.ts b/website/src/config.ts index eb098d009..54781d6aa 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -118,6 +118,7 @@ export const SIDEBAR: Sidebar = { { text: 'Sounds', link: 'technical-manual/sounds' }, { text: 'Docs', link: 'technical-manual/docs' }, { text: 'Testing', link: 'technical-manual/testing' }, + { text: 'API Reference', link: 'reference' } // { text: 'Internals', link: 'technical-manual/internals' }, ], }, diff --git a/website/src/jsDocsUtils.mjs b/website/src/jsDocsUtils.mjs new file mode 100644 index 000000000..1d25a36e3 --- /dev/null +++ b/website/src/jsDocsUtils.mjs @@ -0,0 +1,36 @@ +/** + * compute the list of all function with jsDoc documentation + * + * returns the list of functions in the same structure as the jsdoc json + */ +export const computeAvailableFunctions = (jsdocJson) => { + const seen = new Set(); // avoid repetition + const functions = []; + for (const doc of jsdocJson.docs) { + if (!isValid(doc)) continue; + if (seen.has(doc.name)) continue; + + // jsdoc also uses "tags" for when you use @something in the comments and it doesn't know what + // @something is. We only want data from comments like `@tags superdough` here. + // If nothing is specified, we default to "untagged" for debugging + doc.tags = doc.tags?.filter((t) => t && typeof t === 'string') || ['untagged']; + + const synonyms = doc.synonyms || []; + let names = [doc.name]; + seen.add(doc.name); + for (const s of synonyms) { + if (!s || seen.has(s)) continue; + names.push(s); + seen.add(s); + } + doc.allNames = names.join(' '); + doc.synonyms = names.slice(1); + functions.push(doc); + } + return functions.sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); +}; + +const isValid = ({ name, description, tags = [] }) => { + const isSuperdirtOnly = tags.includes('superdirt') && !tags.includes('superdough'); + return name && !name.startsWith('_') && !!description && !isSuperdirtOnly; +}; diff --git a/website/src/pages/reference.astro b/website/src/pages/reference.astro new file mode 100644 index 000000000..2e688cdfb --- /dev/null +++ b/website/src/pages/reference.astro @@ -0,0 +1,27 @@ +--- +import MainLayout from '../layouts/MainLayout.astro'; +import jsdocJson from '../../../doc.json'; +import { computeAvailableFunctions } from '../jsDocsUtils.mjs'; +import { JsDoc } from '@src/docs/JsDoc.jsx'; +const functions = computeAvailableFunctions(jsdocJson); +const frontmatter = { title: 'Reference', description: '', layout: '' }; +const headings = functions.map((entry) => ({ + depth: 1, + slug: entry.longname, + text: entry.name, +})); +--- + + +

Api Reference

+

+ This is the long list of functions you can use. Remember that you don't need to remember all of those and that you + can already make music with a small set of functions! +

+ {functions.map((entry) => ( + +

{entry.name}

+ +
+ ))} +
diff --git a/website/src/repl/components/panel/Reference.jsx b/website/src/repl/components/panel/Reference.jsx index a140c4724..0675b4cea 100644 --- a/website/src/repl/components/panel/Reference.jsx +++ b/website/src/repl/components/panel/Reference.jsx @@ -3,38 +3,9 @@ import { memo, useEffect, useMemo, useState, Fragment } from 'react'; import jsdocJson from '../../../../../doc.json'; import { Textbox } from '@src/repl/components/panel/SettingsTab'; import { settingsMap, useSettings } from '@src/settings.mjs'; +import { computeAvailableFunctions } from '@src/jsDocsUtils.mjs'; -const isValid = ({ name, description, tags = [] }) => { - const isSuperdirtOnly = tags.includes('superdirt') && !tags.includes('superdough'); - return name && !name.startsWith('_') && !!description && !isSuperdirtOnly; -}; - -const availableFunctions = (() => { - const seen = new Set(); // avoid repetition - const functions = []; - for (const doc of jsdocJson.docs) { - if (!isValid(doc)) continue; - if (seen.has(doc.name)) continue; - - // jsdoc also uses "tags" for when you use @something in the comments and it doesn't know what - // @something is. We only want data from comments like `@tags superdough` here. - // If nothing is specified, we default to "untagged" for debugging - doc.tags = doc.tags?.filter((t) => t && typeof t === 'string') || ['untagged']; - - const synonyms = doc.synonyms || []; - let names = [doc.name]; - seen.add(doc.name); - for (const s of synonyms) { - if (!s || seen.has(s)) continue; - names.push(s); - seen.add(s); - } - doc.allNames = names.join(' '); - doc.synonyms = names.slice(1); - functions.push(doc); - } - return functions.sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); -})(); +const availableFunctions = computeAvailableFunctions(jsdocJson) const tagCounts = {}; const ignoredTags = ['superdirt']; @@ -199,7 +170,7 @@ export const Reference = memo(function Reference() {

- {entry.name} + {entry.name}

{entry.tags && ( From 4b989018a70de8e2166bd0973d4048cb7369322f Mon Sep 17 00:00:00 2001 From: Orasund Date: Mon, 23 Nov 2026 11:32:20 +0100 Subject: [PATCH 2/3] formating --- website/src/config.ts | 2 +- website/src/repl/components/panel/Reference.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/src/config.ts b/website/src/config.ts index 54781d6aa..703ed271f 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -118,7 +118,7 @@ export const SIDEBAR: Sidebar = { { text: 'Sounds', link: 'technical-manual/sounds' }, { text: 'Docs', link: 'technical-manual/docs' }, { text: 'Testing', link: 'technical-manual/testing' }, - { text: 'API Reference', link: 'reference' } + { text: 'API Reference', link: 'reference' }, // { text: 'Internals', link: 'technical-manual/internals' }, ], }, diff --git a/website/src/repl/components/panel/Reference.jsx b/website/src/repl/components/panel/Reference.jsx index 0675b4cea..a44070e75 100644 --- a/website/src/repl/components/panel/Reference.jsx +++ b/website/src/repl/components/panel/Reference.jsx @@ -5,7 +5,7 @@ import { Textbox } from '@src/repl/components/panel/SettingsTab'; import { settingsMap, useSettings } from '@src/settings.mjs'; import { computeAvailableFunctions } from '@src/jsDocsUtils.mjs'; -const availableFunctions = computeAvailableFunctions(jsdocJson) +const availableFunctions = computeAvailableFunctions(jsdocJson); const tagCounts = {}; const ignoredTags = ['superdirt']; From 16b2dba3b1d31030b8f945828a76a437772f4ab5 Mon Sep 17 00:00:00 2001 From: Orasund Date: Tue, 24 Nov 2026 09:59:38 +0100 Subject: [PATCH 3/3] Use "Reference" instead of "Api Reference" --- website/src/config.ts | 2 +- website/src/pages/reference.astro | 2 +- website/src/repl/components/panel/Reference.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/website/src/config.ts b/website/src/config.ts index 703ed271f..37596219e 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -118,7 +118,7 @@ export const SIDEBAR: Sidebar = { { text: 'Sounds', link: 'technical-manual/sounds' }, { text: 'Docs', link: 'technical-manual/docs' }, { text: 'Testing', link: 'technical-manual/testing' }, - { text: 'API Reference', link: 'reference' }, + { text: 'Reference', link: 'reference' }, // { text: 'Internals', link: 'technical-manual/internals' }, ], }, diff --git a/website/src/pages/reference.astro b/website/src/pages/reference.astro index 2e688cdfb..62f79fd14 100644 --- a/website/src/pages/reference.astro +++ b/website/src/pages/reference.astro @@ -13,7 +13,7 @@ const headings = functions.map((entry) => ({ --- -

Api Reference

+

Reference

This is the long list of functions you can use. Remember that you don't need to remember all of those and that you can already make music with a small set of functions! diff --git a/website/src/repl/components/panel/Reference.jsx b/website/src/repl/components/panel/Reference.jsx index 08a89dbc0..82bbb03c7 100644 --- a/website/src/repl/components/panel/Reference.jsx +++ b/website/src/repl/components/panel/Reference.jsx @@ -144,7 +144,7 @@ export const Reference = memo(function Reference() { id="reference-container" >

-

API Reference

+

Reference

This is the long list of functions you can use. Remember that you don't need to remember all of those and that you can already make music with a small set of functions!