docs.js 1.6 KB

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