autogenerate doc on build tutorial

This commit is contained in:
Felix Roos 2022-05-20 22:15:05 +02:00
parent f2a70396d1
commit 6b26f999e4
4 changed files with 13 additions and 12 deletions

View file

@ -1,11 +1,11 @@
{ {
"docs": [ "docs": [
{ {
"comment": "/**\n * Intended for a debugging, drawLine renders the pattern as a string, where each character represents the same time span.\n * Should only be used with single characters as values, otherwise the character slots will be messed up.\n * Character legend: \n * \n * - \"|\" cycle separator\n * - \"-\" hold previous value\n * - \".\" silence\n *\n * @param {Pattern} pat pattern to use\n * @param {number} chars max number of characters (approximately)\n * @returns string\n * @example\n * const line = drawLine(\"0 [1 2 3]\", 10); // |0--123|0--123\n * console.log(line);\n */", "comment": "/**\n * Intended for a debugging, drawLine renders the pattern as a string, where each character represents the same time span.\n * Should only be used with single characters as values, otherwise the character slots will be messed up.\n * Character legend:\n *\n * - \"|\" cycle separator\n * - \"-\" hold previous value\n * - \".\" silence\n *\n * @param {Pattern} pattern the pattern to use\n * @param {number} chars max number of characters (approximately)\n * @returns string\n * @example\n * const line = drawLine(\"0 [1 2 3]\", 10); // |0--123|0--123\n * console.log(line);\n */",
"meta": { "meta": {
"range": [ "range": [
1408, 1414,
2778 2784
], ],
"filename": "drawLine.mjs", "filename": "drawLine.mjs",
"lineno": 25, "lineno": 25,
@ -44,8 +44,8 @@
"Pattern" "Pattern"
] ]
}, },
"description": "<p>pattern to use</p>", "description": "<p>the pattern to use</p>",
"name": "pat" "name": "pattern"
}, },
{ {
"type": { "type": {
@ -54,8 +54,7 @@
] ]
}, },
"description": "<p>max number of characters (approximately)</p>", "description": "<p>max number of characters (approximately)</p>",
"name": "chars", "name": "chars"
"defaultvalue": 60
} }
], ],
"returns": [ "returns": [

View file

@ -15,7 +15,7 @@ import Fraction, { gcd } from './fraction.mjs';
* - "-" hold previous value * - "-" hold previous value
* - "." silence * - "." silence
* *
* @param {Pattern} pat pattern to use * @param {Pattern} pattern the pattern to use
* @param {number} chars max number of characters (approximately) * @param {number} chars max number of characters (approximately)
* @returns string * @returns string
* @example * @example

View file

@ -3,7 +3,7 @@ import { docs } from '../doc.json';
import { MiniRepl } from './MiniRepl'; import { MiniRepl } from './MiniRepl';
function ApiDoc() { function ApiDoc() {
console.log('docJson', docs); // console.log('docJson', docs);
return ( return (
<div> <div>
{docs {docs
@ -23,6 +23,7 @@ function ApiDoc() {
}), }),
}} }}
/> />
<h3>Parameters</h3>
<ul> <ul>
{item.params?.map((param, i) => ( {item.params?.map((param, i) => (
<li key={i}> <li key={i}>

View file

@ -3,10 +3,11 @@
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "npm run jsdoc-json && vite",
"start": "vite", "start": "vite",
"build": "vite build", "build": "npm run jsdoc-json && vite build",
"preview": "vite preview" "preview": "vite preview",
"jsdoc-json": "jsdoc ../packages/ --template ../node_modules/jsdoc-json --destination ../doc.json -c ../jsdoc.config.json"
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {