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.

55 lines
1.5 KiB

4 years ago
  1. 'use strict';
  2. const { readFileSync, readdirSync, writeFileSync } = require('fs');
  3. // Get all markdown stubs
  4. const header = readFileSync('bundler/header.md', 'utf-8');
  5. const badges = readFileSync('bundler/badges.md', 'utf-8');
  6. const installation = readFileSync('bundler/installation.md', 'utf-8');
  7. const api = readFileSync('bundler/api.md', 'utf-8');
  8. const strictnessAndComparisons = readFileSync('bundler/strictness_and_comparisons.md', 'utf-8');
  9. const notImplemented = readFileSync('bundler/not_implemented.md', 'utf-8');
  10. const contribute = readFileSync('bundler/contribute.md', 'utf-8');
  11. const license = readFileSync('bundler/license.md', 'utf-8');
  12. // Get all API docs
  13. const methods = readdirSync('docs/api', 'utf-8');
  14. // Build table of contents
  15. const tableOfContents = methods.map((file) => {
  16. const methodName = file.replace('.md', '');
  17. return `- [${methodName}](#${methodName.toLowerCase()})`;
  18. }).join('\n');
  19. // Build methods "readme"
  20. const methodDocumentation = methods.map((file) => {
  21. let content = readFileSync(`docs/api/${file}`, 'utf-8');
  22. const lines = content.split('\n');
  23. lines[0] = `###${lines[0]}`;
  24. lines.pop();
  25. lines.pop();
  26. content = lines.join('\n');
  27. content = content.replace(/(\r\n|\r|\n){2,}/g, '$1\n');
  28. return content;
  29. }).join('\n\n');
  30. writeFileSync(
  31. 'README.md',
  32. [
  33. header,
  34. badges,
  35. installation,
  36. api,
  37. tableOfContents,
  38. strictnessAndComparisons,
  39. notImplemented,
  40. methodDocumentation,
  41. contribute,
  42. license,
  43. ].join('\n\n'),
  44. );