diff --git a/website/src/config.ts b/website/src/config.ts index eb098d009..37596219e 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: '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..62f79fd14 --- /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, +})); +--- + + +

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 768274c68..82bbb03c7 100644 --- a/website/src/repl/components/panel/Reference.jsx +++ b/website/src/repl/components/panel/Reference.jsx @@ -4,38 +4,9 @@ import jsdocJson from '../../../../../doc.json'; import { Textbox } from '@src/repl/components/panel/SettingsTab'; import { settingsMap, useSettings } from '@src/settings.mjs'; import { JsDoc } from '@src/docs/JsDoc'; +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']; @@ -173,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! @@ -200,7 +171,7 @@ export const Reference = memo(function Reference() {

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

{entry.tags && (