docs.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var acquit = require('acquit');
  2. require('acquit-ignore')();
  3. var content = require('fs').readFileSync('./test/examples.test.js').toString();
  4. var blocks = acquit.parse(content);
  5. var mdOutput =
  6. '# kareem\n\n' +
  7. ' [![Build Status](https://travis-ci.org/vkarpov15/kareem.svg?branch=master)](https://travis-ci.org/vkarpov15/kareem)\n' +
  8. ' [![Coverage Status](https://img.shields.io/coveralls/vkarpov15/kareem.svg)](https://coveralls.io/r/vkarpov15/kareem)\n\n' +
  9. 'Re-imagined take on the [hooks](http://npmjs.org/package/hooks) module, ' +
  10. 'meant to offer additional flexibility in allowing you to execute hooks ' +
  11. 'whenever necessary, as opposed to simply wrapping a single function.\n\n' +
  12. 'Named for the NBA\'s all-time leading scorer Kareem Abdul-Jabbar, known ' +
  13. 'for his mastery of the [hook shot](http://en.wikipedia.org/wiki/Kareem_Abdul-Jabbar#Skyhook)\n\n' +
  14. '<img src="http://upload.wikimedia.org/wikipedia/commons/0/00/Kareem-Abdul-Jabbar_Lipofsky.jpg" width="220">\n\n' +
  15. '# API\n\n';
  16. for (var i = 0; i < blocks.length; ++i) {
  17. var describe = blocks[i];
  18. mdOutput += '## ' + describe.contents + '\n\n';
  19. mdOutput += describe.comments[0] ?
  20. acquit.trimEachLine(describe.comments[0]) + '\n\n' :
  21. '';
  22. for (var j = 0; j < describe.blocks.length; ++j) {
  23. var it = describe.blocks[j];
  24. mdOutput += '#### It ' + it.contents + '\n\n';
  25. mdOutput += it.comments[0] ?
  26. acquit.trimEachLine(it.comments[0]) + '\n\n' :
  27. '';
  28. mdOutput += '```javascript\n';
  29. mdOutput += it.code + '\n';
  30. mdOutput += '```\n\n';
  31. }
  32. }
  33. require('fs').writeFileSync('README.md', mdOutput);