Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| note:sun_jun_22_2025 [2025/06/22 02:34] – created lingao | note:sun_jun_22_2025 [2025/06/22 14:52] (current) – lingao | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Code Formatter ====== | ====== Code Formatter ====== | ||
| - | * https:// | + | * :!: https:// |
| - | * https:// | + | * https:// |
| + | * :!: https:// | ||
| + | |||
| + | ===== How to write a code formatter ===== | ||
| + | |||
| + | reference: https:// | ||
| + | |||
| + | prettier is based on [[https:// | ||
| + | |||
| + | ===== code gen ===== | ||
| + | |||
| + | <code ts> | ||
| + | type LowcodeInterface = { | ||
| + | identifier: string; | ||
| + | fields: { name: string, type: string, comment?: string }[]; | ||
| + | comment?: string; | ||
| + | } | ||
| + | |||
| + | function printField(field: | ||
| + | return (field.comment ? ' | ||
| + | + " | ||
| + | } | ||
| + | |||
| + | function printInterface(lowcodeInterface: | ||
| + | return (lowcodeInterface.comment ? '/* ' + lowcodeInterface.comment + " */\n" : "" | ||
| + | + " | ||
| + | + lowcodeInterface.fields.map(printField).join(' | ||
| + | + " | ||
| + | } | ||
| + | |||
| + | export { printInterface }; | ||
| + | </ | ||