mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 06:19:33 -04:00
add autogenerated api doc to bottom of tutorial
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { docs } from '../doc.json';
|
||||
import { MiniRepl } from './MiniRepl';
|
||||
|
||||
function ApiDoc() {
|
||||
console.log('docJson', docs);
|
||||
return (
|
||||
<div>
|
||||
{docs
|
||||
.filter((item) => !item.name?.startsWith('_') && item.kind !== 'package')
|
||||
.map((item, i) => (
|
||||
<Fragment key={i}>
|
||||
{' '}
|
||||
<h2 id={`${item.memberof ? `${item.memberof}-` : ''}${item.name}`}>
|
||||
{item.memberof && item.memberof !== item.name ? `${item.memberof}.` : ''}
|
||||
{item.name}
|
||||
</h2>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: item.description.replaceAll(/\{\@link ([a-zA-Z]+)?\#?([a-zA-Z]*)\}/g, (_, a, b) => {
|
||||
// console.log(_, 'a', a, 'b', b);
|
||||
return `<a href="#${a}${b ? `-${b}` : ''}">${a}${b ? `#${b}` : ''}</a>`;
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
<ul>
|
||||
{item.params?.map((param, i) => (
|
||||
<li key={i}>
|
||||
{param.name} ({param.type?.names?.join('|')}): {param.description?.replace(/(<([^>]+)>)/gi, '')}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{item.examples?.length && <h3>Examples</h3>}
|
||||
<div className="space-y-2">
|
||||
{item.examples?.map((example, k) => (
|
||||
<MiniRepl key={k} tune={example} />
|
||||
))}
|
||||
</div>
|
||||
</Fragment>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ApiDoc;
|
||||
@@ -693,3 +693,14 @@ If you want to contribute in another way, either
|
||||
- [fork strudel repo on GitHub](https://github.com/tidalcycles/strudel)
|
||||
- [Join the Discord Channel](https://discord.gg/remJ6gQA)
|
||||
- [play with the Strudel REPL](https://strudel.tidalcycles.org/)
|
||||
|
||||
import ApiDoc from './ApiDoc';
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
# API Docs
|
||||
|
||||
The following Chapter is the technical API documentation. It is autogenerated from the jsdoc comments in the source files.
|
||||
|
||||
<ApiDoc />
|
||||
|
||||
Reference in New Issue
Block a user