microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/html-program-viewer/src/emitter.ts
11lines · modecode
| 1 | import { Program, resolvePath } from "@cadl-lang/compiler"; |
| 2 | import { renderProgram } from "./ui.js"; |
| 3 | |
| 4 | export async function $onEmit(program: Program) { |
| 5 | const html = renderProgram(program); |
| 6 | const htmlPath = resolvePath(program.compilerOptions.outputPath!, "cadl-program.html"); |
| 7 | await program.host.writeFile( |
| 8 | htmlPath, |
| 9 | `<!DOCTYPE html><html lang="en"><link rel="stylesheet" href="style.css"><body>${html}</body></html>` |
| 10 | ); |
| 11 | } |
| 12 | |