You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

docs-gen.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // @ts-check
  2. /*
  3. This script will generate content for the code editor's markdown docs. To change
  4. the docs, edit the file at `state/code/docs.md`.
  5. */
  6. const fs = require('fs/promises')
  7. const root = process.cwd()
  8. async function inlineFileContents(path) {
  9. console.log(`📄 Inlining contents of ${path}`)
  10. const text = await fs.readFile(`${root}${path}`, 'utf-8')
  11. return text.replaceAll('`', '\\`')
  12. }
  13. async function copyDocsToDocsContentFile() {
  14. console.log('⚙️ Generating docs-content.ts')
  15. const content =
  16. `
  17. /* eslint-disable */
  18. // HEY! DO NOT MODIFY THIS FILE. THE CONTENTS OF THIS FILE
  19. // ARE AUTO-GENERATED BY A SCRIPT AT: /scripts/docs-gen.js
  20. // ANY CHANGES WILL BE LOST WHEN THE SCRIPT RUNS AGAIN!
  21. export default {` +
  22. `
  23. name: "docs-content.ts",
  24. content: \`
  25. ${await inlineFileContents('/state/code/docs.md')}
  26. \`}`
  27. await fs.writeFile(
  28. __dirname + '/../components/code-panel/docs-content.ts',
  29. content
  30. )
  31. console.log('✅ Process complete')
  32. }
  33. // Kickoff
  34. copyDocsToDocsContentFile()