Files
puter/doc/contributors/extensions/gen.js
KernelDeimos e6b3cb3666 fix: get event docs back in sync
I used 'fix' for this instead of 'doc' because I am also adding a
package for code that generates markdown, so this doesn't have the
zero-risk nature typically associated with a "doc: " commit.
2025-02-25 17:52:54 -05:00

39 lines
1010 B
JavaScript

import dedent from 'dedent';
import events from './events.json.js';
const mdlib = {};
mdlib.h = (out, n, str) => {
out(`${'#'.repeat(n)} ${str}\n\n`);
}
const N_START = 3;
const out = str => process.stdout.write(str);
for ( const event of events ) {
mdlib.h(out, N_START, `\`${event.id}\``);
out(dedent(event.description) + '\n\n');
for ( const k in event.properties ) {
const prop = event.properties[k];
mdlib.h(out, N_START + 1, `Property \`${k}\``);
out(prop.summary + '\n');
out(`- **Type**: ${prop.type}\n`);
out(`- **Mutability**: ${prop.mutability}\n`);
if ( prop.notes ) {
out(`- **Notes**:\n`);
for ( const note of prop.notes ) {
out(` - ${note}\n`);
}
}
out('\n');
}
if ( event.example ) {
mdlib.h(out, N_START + 1, `Example`);
out(`\`\`\`${event.example.language}\n${dedent(event.example.code)}\n\`\`\`\n`);
}
out('\n');
}